Skip to content

Svelte Testing Library setup docs need additional info for SvelteKit #1388

Closed
@scottdotweb

Description

@scottdotweb

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions