Skip to content

Commit 1cfbe66

Browse files
authored
Update setup.mdx
As I found out with my SvelteKit 5 project, we need to add `"types": ["@testing-library/jest-dom"]` to the `compilerOptions` in the project's `tsconfig.json`. Otherwise my VSCode complains that it can't find e.g. `toBeInTheDocument` (Property 'toBeInTheDocument' does not exist on type 'Assertion<HTMLElement>'.ts(2339)). I'm no TypeScript Pro, so feel free to reword what I wrote. :-)
1 parent a605e93 commit 1cfbe66

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

docs/svelte-testing-library/setup.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,18 @@ runner that's ESM compatible.
138138
[resolve-conditions]:
139139
https://vitejs.dev/config/shared-options.html#resolve-conditions
140140

141+
### TypeScript
142+
143+
If you use TypeScript and want to use [`@testing-library/jest-dom`][@testing-library/jest-dom] you need to tell the TypeScript compiler about [`@testing-library/jest-dom`][@testing-library/jest-dom] by adding it in your `tsconfig.json` to the `compilerOptions`.
144+
145+
```json title="package.json"
146+
{
147+
"compilerOptions": {
148+
"types": ["@testing-library/jest-dom"],
149+
}
150+
}
151+
```
152+
141153
## Jest
142154

143155
[`@testing-library/svelte`][@testing-library/svelte] is ESM-only, which means

0 commit comments

Comments
 (0)