vitest-svelte-kit
vitest-svelte-kit copied to clipboard
Specify custom Vitest config
Hi! Thanks for your work on this package @nickbreaton!
I'm using this package with my vitest.config.js
but I have existent configuration here:
{
plugins: [svelte({ hot: !process.env.VITEST }), Icons({ compiler: 'svelte' })],
test: {
watch: false,
clearMocks: true,
environment: 'jsdom',
include: ['test/**/*.ts'],
exclude: [
'node_modules',
'dist',
'.idea',
'.git',
'.cache',
'test/__mock__/**/*.ts',
'.coverage',
'.svelte-kit',
],
deps: {
inline: ['@splidejs/svelte-splide', 'msw', /@sentry/],
},
coverage: { reporter: ['lcovonly'], reportsDirectory: '.coverage' },
},
}
I would like to be able to provide this config along with the one provided by the package to Vitest. Would this be possible? Thanks in advance!
I would recommend putting it inside your svelte.config.js
's vite
section like this:
https://github.com/nickbreaton/vitest-svelte-kit/blob/ef2dfd132f378ced89bdfc350df80fa57486bf56/tests/vite-plugins/svelte.config.js#L12-L14
You don't need the svelte plugin in there though, since it will already be included.
If you need to conditionally include something in your vite config just for test, you can use the VITEST
environment variable as mentioned in your docs within the svelte.config.js
file as well:
https://github.com/nickbreaton/vitest-svelte-kit/blob/ef2dfd132f378ced89bdfc350df80fa57486bf56/tests/process-env-vitest/svelte.config.js#L13