-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Description
Describe the bug
vitest.config.ts
:
export default mergeConfig(
viteConfig,
defineConfig({
test: {
setupFiles: './scripts/setup-tests.ts',
},
// ....
}),
)
./scripts/setup-tests.ts
:
import matchers from '@testing-library/jest-dom/matchers'
import { expect } from 'vitest'
expect.extend(matchers)
tsconfig.json
:
{
"compilerOptions": {
"types": ["node", "@testing-library/jest-dom"],
// ...
}
}
I am getting typescript errors:
components/button/index.test.tsx:67:38 - error TS2339: Property 'toHaveClass' does not exist on type 'Assertion<HTMLElement>'.
67 expect(getByText(trimmedText)).not.toHaveClass('full')
~~~~~~~~~~~
components/button/index.test.tsx:68:31 - error TS2339: Property 'toHaveClass' does not exist on type 'Assertion<HTMLElement>'.
68 expect(getByText(fullText)).toHaveClass('full')
~~~~~~~~~~~
components/button/index.test.tsx:105:36 - error TS2339: Property 'toBeInTheDocument' does not exist on type 'Assertion<HTMLElement>'.
105 expect(screen.getByRole('link')).toBeInTheDocument()
System Info
System:
OS: macOS 13.3
CPU: (10) arm64 Apple M1 Pro
Memory: 413.16 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.15.0 - ~/.asdf/installs/nodejs/18.15.0/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 9.5.0 - ~/.asdf/plugins/nodejs/shims/npm
Browsers:
Chrome: 112.0.5615.49
Firefox: 111.0.1
Safari: 16.4
npmPackages:
@vitejs/plugin-react: ^3.1.0 => 3.1.0
@vitest/coverage-c8: ^0.30.0 => 0.30.0
vite: ^4.2.1 => 4.2.1
vitest: ^0.30.0 => 0.30.0
Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
andreasremdt, janhesters, gudleik, jagin, Meemaw and 1 more
Metadata
Metadata
Assignees
Labels
No labels