-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.ts
More file actions
80 lines (78 loc) · 2.19 KB
/
vitest.config.ts
File metadata and controls
80 lines (78 loc) · 2.19 KB
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';
import path from 'path';
import { defineConfig } from 'vitest/config';
const enforceCoverageThresholds = process.env['VITEST_ENFORCE_THRESHOLDS'] !== 'false';
const coverageThresholds = {
global: {
statements: 95,
branches: 95,
functions: 95,
lines: 95,
},
} as const;
export default defineConfig({
plugins: [react()],
test: {
// Resource controls: run one file at a time and recycle the fork between files
// This reduces retained heap from long-lived JSDOM/module state across the suite
pool: 'forks',
poolOptions: {
forks: {
singleFork: false,
},
},
maxWorkers: 1,
minWorkers: 1,
globals: true,
environment: 'jsdom',
setupFiles: ['./tests/setup.ts'],
include: ['tests/unit/**/*.{test,spec}.{js,ts,tsx}', 'tests/integration/**/*.{test,spec}.{js,ts,tsx}'],
exclude: ['tests/e2e/**/*'],
css: false,
// Resource optimization settings
isolate: true, // Better memory cleanup between test files
testTimeout: 30000, // 30 second timeout to prevent hanging
hookTimeout: 10000, // 10 second hook timeout
teardownTimeout: 10000, // 10 second teardown timeout for graceful cleanup
// Better React 18+ support
env: {
IS_REACT_ACT_ENVIRONMENT: 'true',
NODE_ENV: 'test'
},
coverage: {
provider: 'v8',
reporter: ['text', 'json-summary', 'html', 'lcov'],
include: ['src/**/*.{js,ts,jsx,tsx}'],
exclude: [
'node_modules/',
'tests/setup.ts',
'tests/e2e/',
'**/*.d.ts',
'**/*.config.*',
'**/coverage/**',
'.next/**',
'src/types/**',
'src/**/*.stories.*',
'src/**/*.test.*',
'src/**/*.spec.*',
// UI interaction hooks covered by E2E tests
'src/hooks/ui/useChartHover.ts',
'src/hooks/ui/useClickOutside.ts',
'src/hooks/ui/useAsyncRetryButton.ts',
],
reportOnFailure: true,
all: true,
...(enforceCoverageThresholds ? { thresholds: coverageThresholds } : {}),
},
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
css: {
postcss: {
plugins: []
}
}
});