-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.bench.mts
More file actions
99 lines (82 loc) · 2.63 KB
/
vitest.config.bench.mts
File metadata and controls
99 lines (82 loc) · 2.63 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
import { defineConfig, mergeConfig } from "vitest/config";
import { commonConfig } from "./vitest.config.common.mjs";
/**
* Vitest configuration for benchmarking
*
* Benchmarks measure performance with process isolation for stable results.
*
* Extends common config with overrides:
* - Coverage disabled
* - Process isolation (forks pool)
* - Minimal features enabled (globals: false)
* - Separate setup file for RTL cleanup
* - Extended timeout (10 minutes)
* - Single worker for stability
*
* @see https://vitest.dev/config/
*/
export default mergeConfig(
commonConfig,
defineConfig({
cacheDir: "./.vitest-bench", // Separate cache for benchmarks
// Build optimization for benchmarks
optimizeDeps: {
force: true, // Force optimization
},
// Disable logging for clean results
logLevel: "error",
test: {
// Settings for benchmark stability (Vitest 4+)
pool: "forks", // Process isolation (OVERRIDE common config's threads)
isolate: true, // Full isolation
execArgv: [
// Node.js flags
"--expose-gc", // Access to GC
"--max-old-space-size=4096", // More memory per process
// "--predictable", // Predictability (optional, slower)
],
// Disable unnecessary features for benchmarks (OVERRIDE common config)
globals: false,
clearMocks: false,
mockReset: false,
restoreMocks: false,
unstubEnvs: false,
unstubGlobals: false,
// Setup files for benchmarks (OVERRIDE common config)
setupFiles: ["./tests/setup.bench.ts"], // Includes RTL cleanup
// Timeouts for long benchmarks
testTimeout: 600000, // 10 minutes per test
hookTimeout: 60000, // 1 minute for hooks
// Only benchmarks
includeSource: [],
include: [], // Clear regular tests
// Benchmark settings
benchmark: {
// Reporters
reporters: ["default"],
// Output results
outputJson: "./.bench/results.json",
// Benchmark paths
include: [
"./tests/benchmarks/**/*.bench.ts",
"./tests/benchmarks/**/*.bench.tsx",
],
exclude: ["node_modules", "dist", "**/*.test.ts"],
// Result verbosity
includeSamples: false,
},
// Disable coverage for benchmarks
coverage: {
enabled: false,
},
// Output settings
reporters: ["basic"], // Minimal output
outputFile: "./.bench/output.txt",
// Disable watch for benchmarks
watch: false,
// Parallelism
maxConcurrency: 1, // One test at a time for stability
maxWorkers: 1, // One worker
},
}),
);