-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.unit.mts
More file actions
103 lines (97 loc) · 2.73 KB
/
vitest.config.unit.mts
File metadata and controls
103 lines (97 loc) · 2.73 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
import { defineConfig, mergeConfig } from "vitest/config";
import { commonConfig } from "./vitest.config.common.mjs";
/**
* Vitest configuration for unit and integration tests
*
* Extends common config with:
* - Code coverage enabled (95% thresholds)
* - Includes all tests except property-based and memory tests
* - Default test timeout (10s)
* - 4 workers for parallelism
*
* @see https://vitest.dev/config/
*/
export default mergeConfig(
commonConfig,
defineConfig({
test: {
/**
* Coverage configuration
* Enabled with strict 95% thresholds
*/
coverage: {
enabled: true,
provider: "v8",
reporter: [
["text", { skipFull: true }],
"json",
"json-summary",
"lcov",
],
reportsDirectory: "./coverage",
exclude: [
"**/node_modules/**",
"**/dist/**",
"**/coverage/**",
"**/examples/**",
"**/tests/**",
"**/*.config.*",
"**/*.d.ts",
"**/*.test.{ts,tsx}",
"**/*.spec.{ts,tsx}",
"**/types.ts", // Exclude type definitions
"**/test-utils/**",
// Barrel exports (except matchers/index.ts which has logic)
"**/hooks/index.ts",
"**/profiler/components/index.ts",
"**/profiler/core/index.ts",
"**/profiler/api/index.ts",
"**/utils/index.ts",
"**/matchers/sync/index.ts",
"**/matchers/async/index.ts",
// Internal debugging/metrics (not production code)
"**/profiler/core/CacheMetrics.ts",
"**/profiler/core/constants.ts",
],
thresholds: {
statements: 100,
branches: 100,
functions: 100,
lines: 100,
},
},
/**
* Reporter configuration
*/
reporters: ["default"],
/**
* Test filtering
* Exclude memory-intensive property and memory tests from default run.
* Run them separately with:
* - npm run test:properties (property-based tests)
*/
include: ["tests/**/*.test.{ts,tsx}", "tests/**/*.spec.{ts,tsx}"],
exclude: [
"node_modules",
"dist",
".idea",
".git",
".cache",
"tests/property/**/*.properties.{ts,tsx}",
],
/**
* Timeout configuration
* Increase if your components have complex lifecycle or async operations
*/
testTimeout: 10000,
hookTimeout: 10000,
/**
* Worker configuration (Vitest 4+)
* Limit parallelism to prevent memory exhaustion
*/
maxWorkers: 4,
// Use threads pool for better performance with async tests
pool: "threads",
},
}),
);