testing-library/testing-library-docs

Svelte Testing Library setup docs need additional info for SvelteKit

scottdotweb opened this issue · 1 comments

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.

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.