Closed scottdotweb closed 4 months ago
The setup docs for Svelte Testing Library say
Add vitest.config.js, or update your existing vite.config.js, with the svelte and svelteTesting Vite plugins.
vitest.config.js
vite.config.js
svelte
svelteTesting
And specifies the config as:
import {defineConfig} from 'vitest/config' import {svelte} from '@sveltejs/vite-plugin-svelte' import {svelteTesting} from '@testing-library/svelte/vite' export default defineConfig({ plugins: [svelte(), svelteTesting()], test: { environment: 'jsdom', setupFiles: ['./vitest-setup.js'], }, })
However when using SvelteKit you need to use its Vite plugin, which will already be in your config. So in that case it would look like this:
import {defineConfig} from 'vitest/config' import {sveltekit} from '@sveltejs/kit/vite' import {svelteTesting} from '@testing-library/svelte/vite' export default defineConfig({ plugins: [sveltekit(), svelteTesting()], test: { environment: 'jsdom', setupFiles: ['./vitest-setup.js'], }, })
I'd do a PR but I'm using all of this for the first time, so probably not the right person to go editing the docs right now.
Thanks @scottdotjs :) Tagging @mcous which wrote that part.
The setup docs for Svelte Testing Library say
And specifies the config as:
However when using SvelteKit you need to use its Vite plugin, which will already be in your config. So in that case it would look like this:
I'd do a PR but I'm using all of this for the first time, so probably not the right person to go editing the docs right now.