-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathvitest.config.mts
More file actions
100 lines (98 loc) · 3.14 KB
/
vitest.config.mts
File metadata and controls
100 lines (98 loc) · 3.14 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { defineConfig } from 'vitest/config'
const isCoverageEnabled =
process.env.npm_lifecycle_event === 'cover' ||
process.argv.includes('--coverage')
export default defineConfig({
resolve: {
preserveSymlinks: false,
},
test: {
globals: false,
environment: 'node',
include: [
// NOTE: No root-level tests exist. All tests are in individual packages.
// Each package (e.g., packages/cli/) has its own vitest.config.mts.
// This root config serves as a fallback default configuration only.
],
exclude: [
'**/node_modules/**',
'**/dist/**',
'**/.{idea,git,cache,output,temp}/**',
'**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*',
'**/*.test.{js,ts,mjs,cjs,mts}',
// Exclude E2E tests from regular test runs.
'**/*.e2e.test.mts',
],
passWithNoTests: true,
reporters: ['default'],
setupFiles: ['./test/setup.mts'],
// Use threads for better performance
pool: 'threads',
poolOptions: {
threads: {
singleThread: false,
maxThreads: isCoverageEnabled ? 1 : 16,
minThreads: isCoverageEnabled ? 1 : 4,
// IMPORTANT: isolate: false for performance and test compatibility
//
// Tradeoff Analysis:
// - isolate: true = Full isolation, slower, breaks nock/module mocking
// - isolate: false = Shared worker context, faster, mocking works
//
// We choose isolate: false because:
// 1. Significant performance improvement (faster test runs)
// 2. Nock HTTP mocking works correctly across all test files
// 3. Vi.mock() module mocking functions properly
// 4. Test state pollution is prevented through proper beforeEach/afterEach
// 5. Our tests are designed to clean up after themselves
//
// Tests requiring true isolation should use pool: 'forks' or be marked
// with { pool: 'forks' } in the test file itself.
isolate: false,
// Use worker threads for better performance
useAtomics: true,
},
},
testTimeout: 30_000,
hookTimeout: 30_000,
bail: process.env.CI ? 1 : 0, // Exit on first failure in CI for faster feedback.
sequence: {
concurrent: true, // Run tests concurrently within suites for better parallelism.
},
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html', 'lcov', 'clover'],
exclude: [
'**/*.config.*',
'**/node_modules/**',
'**/[.]**',
'**/*.d.mts',
'**/*.d.ts',
'**/virtual:*',
'bin/**',
'coverage/**',
'dist/**',
'external/**',
'pnpmfile.*',
'scripts/**',
'src/**/types.mts',
'test/**',
'perf/**',
// Explicit root-level exclusions
'/scripts/**',
'/test/**',
],
include: ['src/**/*.mts', 'src/**/*.ts'],
all: true,
clean: true,
skipFull: false,
ignoreClassMethods: ['constructor'],
thresholds: {
lines: 0,
functions: 0,
branches: 0,
statements: 0,
},
},
},
})