Skip to content

Commit 1785eb9

Browse files
authored
docs: add sveltekit update and alt config
I struggled setting this up with sveltekit, and was only able to get it working with the added `mergeConfig`
1 parent f8c520a commit 1785eb9

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

docs/svelte-testing-library/setup.mdx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,28 @@ with any testing framework and runner you're comfortable with.
7575
```
7676
### SvelteKit
7777

78-
To use Vitest with SvelteKit install `vitest-svelte-kit`, which includes a preconfigured Vitest configuration for SvelteKit projects.
79-
You can take a look at the [`vitest-svelte-kit` configuration docs](https://github.com/nickbreaton/vitest-svelte-kit/tree/master/packages/vitest-svelte-kit#configuring) for further instructions.
78+
Previously `vitest-svelte-kit` could be used, but it is not necessary anymore and depreceated since `svelte-kit` is now a vite plugin.
79+
80+
If you struggle getting this working with the above vitest configuration, use the `mergeConfig` instead in `vitest.config.ts`:
81+
82+
```ts
83+
84+
import { mergeConfig } from 'vite'
85+
import { defineConfig } from 'vitest/config'
86+
import viteConfig from './vite.config'
87+
88+
// use vite.config (set for sveltekit) and add vitest specific config
89+
export default mergeConfig(
90+
viteConfig,
91+
defineConfig({
92+
test: {
93+
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
94+
globals: true,
95+
environment: 'jsdom',
96+
},
97+
})
98+
)
99+
```
80100

81101
## Jest
82102

0 commit comments

Comments
 (0)