-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvite.config.ts
34 lines (32 loc) · 993 Bytes
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig, type UserConfig } from 'vite';
import type { UserConfig as VitestConfig } from 'vitest/config';
const config: UserConfig & { test: VitestConfig['test'] } = defineConfig(({ mode }) => ({
plugins: [sveltekit()],
define: {
// Eliminate in-source test code
'import.meta.vitest': 'undefined',
},
test: {
// Can't patch `expect` otherwise
globals: true,
// Importing CSS only inside components won't do it in vitest
css: {
include: [/.+\.css/],
},
environment: 'jsdom',
// in-source testing
includeSource: ['src/**/*.{js,ts,svelte}'],
// Add @testing-library/jest-dom matchers & mocks of SvelteKit modules
setupFiles: ['./setupTest.ts'],
// Exclude files in c8
coverage: {
exclude: ['setupTest.ts'],
},
include: ['src/**/*.test.{js,ts}'],
},
resolve: {
conditions: mode === 'test' ? ['browser'] : [],
},
}));
export default config;