-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.ts
More file actions
137 lines (120 loc) · 4.91 KB
/
vitest.config.ts
File metadata and controls
137 lines (120 loc) · 4.91 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// =============================================================================
// Vitest Configuration
// https://vitest.dev/config/
// =============================================================================
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
// =========================================================================
// Environment Configuration
// =========================================================================
environment: "node",
globals: true,
setupFiles: ["./src/env.ts"],
// =========================================================================
// Test File Patterns
// =========================================================================
include: ["tests/**/*.{test,spec}.ts"],
exclude: ["node_modules", "dist", "coverage", "results", "reports"],
// =========================================================================
// Timeouts
// Generous timeouts for SDK integration tests
// =========================================================================
testTimeout: 30000,
hookTimeout: 30000,
// =========================================================================
// Coverage Configuration
// =========================================================================
coverage: {
enabled: true,
provider: "v8",
reporter: ["text", "json", "html", "lcov"],
reportsDirectory: "./coverage",
// Files to include in coverage
include: ["src/**/*.ts"],
// Files to exclude from coverage
exclude: [
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.d.ts",
"src/types/**",
"src/index.ts", // CLI entry point
"src/**/index.ts", // Re-export modules
],
// Coverage thresholds
// Note: Vitest 4 uses more accurate V8 coverage remapping,
// which may report lower coverage than v3. Thresholds adjusted accordingly.
thresholds: {
branches: 65,
functions: 75,
lines: 78,
statements: 78,
},
},
// =========================================================================
// Reporter Configuration
// Verbose output in CI for better debugging, default locally
// JUnit reporter in CI for Codecov Test Analytics
// =========================================================================
reporters: process.env.CI
? ["verbose", "html", "junit"]
: ["default", "html"],
outputFile: {
html: "./coverage/test-report.html",
junit: "./coverage/test-report.junit.xml",
},
// =========================================================================
// Parallelization
// Vitest 4 uses top-level pool options (poolOptions removed)
// =========================================================================
pool: "threads",
threads: {
singleThread: false,
isolate: true,
},
// =========================================================================
// Test Isolation and Cleanup
// =========================================================================
clearMocks: true,
restoreMocks: true,
mockReset: true,
// Randomize test order to catch order-dependent tests
sequence: {
shuffle: true,
},
// =========================================================================
// Watch Mode Configuration
// =========================================================================
watch: false,
watchExclude: ["node_modules", "dist", "coverage", "results", "reports"],
// =========================================================================
// Retry and Bail Configuration
// =========================================================================
retry: process.env.CI ? 2 : 1,
bail: process.env.CI ? 1 : 0,
// =========================================================================
// TypeScript Type Checking in Tests
// =========================================================================
typecheck: {
enabled: false, // Enable when needed: slower but catches type errors
include: ["tests/**/*.ts"],
},
// =========================================================================
// Snapshot Configuration
// =========================================================================
snapshotFormat: {
escapeString: true,
printBasicPrototype: true,
},
// =========================================================================
// Console Output Handling
// =========================================================================
onConsoleLog(log, type) {
// Fail tests that log unexpected errors
if (type === "stderr" && log.includes("Error:")) {
return false; // Suppress in output but let it fail via assertions
}
return true; // Allow other console output
},
},
});