-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Expand file tree
/
Copy pathvitest.config.mjs
More file actions
105 lines (99 loc) · 2.42 KB
/
vitest.config.mjs
File metadata and controls
105 lines (99 loc) · 2.42 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
import {defineConfig} from "vitest/config";
/*
* Sequential execution keeps our shared test server stable:
* - All suites bind to port 8080
* - Fixtures and temp paths are reused between tests
* - Debugging becomes predictable
*
* Parallel execution would require dynamic ports and isolated fixtures,
* so we intentionally cap Vitest at a single worker for now.
*
* Projects separate unit, e2e (Playwright), and electron tests with
* appropriate timeouts for each test type.
*/
export default defineConfig({
test: {
// Shared settings for all test types
globals: true,
environment: "node",
setupFiles: ["./tests/utils/vitest-setup.js"],
// Stop test execution on first failure
bail: 3,
// Automatically restore all mocks after each test to prevent leaks
restoreAllMocks: true,
// Shared exclude patterns
exclude: [
"**/node_modules/**",
"**/dist/**",
"tests/unit/mocks/**",
"tests/unit/helpers/**",
"tests/electron/helpers/**",
"tests/e2e/helpers/**",
"tests/e2e/mocks/**",
"tests/configs/**",
"tests/utils/**"
],
// Projects with specific configurations per test type
projects: [
{
test: {
name: "unit",
globals: true,
environment: "node",
setupFiles: ["./tests/utils/vitest-setup.js"],
include: [
"tests/unit/**/*_spec.js",
"tests/unit/defaultmodules/calendar/calendar_fetcher_utils_bad_rrule.js"
],
testTimeout: 20000,
hookTimeout: 10000
}
},
{
test: {
name: "e2e",
globals: true,
environment: "node",
setupFiles: ["./tests/utils/vitest-setup.js"],
include: ["tests/e2e/**/*_spec.js"],
testTimeout: 60000,
hookTimeout: 30000
}
},
{
test: {
name: "electron",
globals: true,
environment: "node",
setupFiles: ["./tests/utils/vitest-setup.js"],
include: ["tests/electron/**/*_spec.js"],
testTimeout: 120000,
hookTimeout: 30000
}
}
],
// Coverage configuration
coverage: {
provider: "v8",
reporter: ["lcov", "text"],
include: [
"clientonly/**/*.js",
"js/**/*.js",
"defaultmodules/**/*.js",
"serveronly/**/*.js"
],
exclude: [
"**/node_modules/**",
"**/tests/**",
"**/dist/**"
]
},
/*
* Pool settings for isolated test execution. Keep maxWorkers at 1 so
* port 8080 and shared fixtures remain safe across the full suite.
*/
pool: "forks",
maxWorkers: 1,
isolate: true
}
});