-
Notifications
You must be signed in to change notification settings - Fork 9
/
vitest.config.ts
42 lines (40 loc) · 1.19 KB
/
vitest.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
35
36
37
38
39
40
41
42
import { defineConfig } from 'vitest/config'
import solidPlugin from 'vite-plugin-solid'
export default defineConfig(({ mode }) => {
// to test in server environment, run with "--mode ssr" or "--mode test:ssr" flag
// loads only server.test.ts file
const testSSR = mode === 'test:ssr' || mode === 'ssr'
return {
plugins: [
solidPlugin({
// https://github.com/solidjs/solid-refresh/issues/29
hot: false,
// For testing SSR we need to do a SSR JSX transform
solid: { generate: testSSR ? 'ssr' : 'dom' },
}),
],
test: {
watch: false,
isolate: !testSSR,
env: {
NODE_ENV: testSSR ? 'production' : 'development',
DEV: testSSR ? '' : '1',
SSR: testSSR ? '1' : '',
PROD: testSSR ? '1' : '',
},
environment: testSSR ? 'node' : 'jsdom',
transformMode: { web: [/\.[jt]sx$/] },
...(testSSR
? {
include: ['test/server.test.{ts,tsx}'],
}
: {
include: ['test/*.test.{ts,tsx}'],
exclude: ['test/server.test.{ts,tsx}'],
}),
},
resolve: {
conditions: testSSR ? ['node'] : ['browser', 'development'],
},
}
})