-
-
Notifications
You must be signed in to change notification settings - Fork 219
/
vitest.config.ts
80 lines (79 loc) · 2.15 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import react from '@vitejs/plugin-react-swc';
import magicalSvg from 'vite-plugin-magical-svg';
import tsconfigPaths from 'vite-tsconfig-paths';
import { defineConfig } from 'vitest/config';
const testFiles = ['./src/**/*.test.{js,jsx,ts,tsx}'];
export default defineConfig({
plugins: [
react({
devTarget: 'es2022',
jsxImportSource: '@emotion/react',
}),
tsconfigPaths(),
magicalSvg({
target: 'react',
svgo: false,
}),
],
cacheDir: '../../.cache/vitest/nextjs-app',
test: {
globals: true,
deps: {
optimizer: {
web: {
enabled: true,
},
ssr: { enabled: true },
},
},
typecheck: {
enabled: false,
},
// threads is good, vmThreads is faster (perf++) but comes with possible memory leaks
// @link https://vitest.dev/config/#vmthreads
pool: 'forks',
poolOptions: {
vmThreads: {
// useAtomics -> perf+
// @link https://vitest.dev/config/#pooloptions-threads-useatomics
useAtomics: true,
},
threads: {
// minThreads: 4,
// maxThreads: 16,
// useAtomics -> perf+
// @link https://vitest.dev/config/#pooloptions-threads-useatomics
useAtomics: true,
// isolate to false makes perf++ but comes with limitations
// @link https://vitest.dev/config/#pooloptions-threads-isolate
isolate: true,
},
},
environmentMatchGlobs: [
['**/*.ts', 'node'],
['**/*.tsx', 'happy-dom'],
],
passWithNoTests: false,
setupFiles: './config/tests/setupVitest.ts',
coverage: {
provider: 'v8',
reporter: ['text', 'clover'],
extension: ['js', 'jsx', 'ts', 'tsx'],
},
include: testFiles,
// you might want to disable it, if you don't have tests that rely on CSS
// since parsing CSS is slow
// css: true,
// To mimic Jest behaviour regarding mocks.
// @link https://vitest.dev/config/#clearmocks
clearMocks: true,
mockReset: true,
restoreMocks: true,
exclude: [
'**/node_modules/**',
'**/dist/**',
'**/.next/**',
'**/.{idea,git,cache,output,temp}/**',
],
},
});