-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathvitest.integration.config.ts
More file actions
114 lines (102 loc) · 3.08 KB
/
vitest.integration.config.ts
File metadata and controls
114 lines (102 loc) · 3.08 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
import { cpus } from "node:os";
import tsconfigPaths from "vite-tsconfig-paths";
import { configDefaults, defineConfig } from "vitest/config";
const isCI = !!process.env.CI;
const cpuCount = cpus().length;
const MAX_CI_THREADS = 12; // Reduced to leave headroom
const MAX_LOCAL_THREADS = 16;
// Allow override via env var for CI rollout testing
const envCiThreads = process.env.VITEST_CI_THREADS
? Number.parseInt(process.env.VITEST_CI_THREADS, 10)
: undefined;
const computedCiThreads = Math.min(
MAX_CI_THREADS,
Math.max(4, Math.floor(cpuCount * 0.85)), // Increased utilization
);
const ciThreads =
envCiThreads && !Number.isNaN(envCiThreads)
? envCiThreads
: computedCiThreads;
const localThreads = Math.min(MAX_LOCAL_THREADS, Math.max(4, cpuCount));
// Runtime observability for CI rollout
if (isCI) {
// const shardId = process.env.SHARD_INDEX || "unknown";
// console.log(
// `[Vitest Config] Shard ${shardId}: cpuCount=${cpuCount}, computedCiThreads=${computedCiThreads}, ciThreads=${ciThreads}`,
// );
if (ciThreads < cpuCount) {
// console.warn(
// `[Vitest Config] Thread count reduced from ${cpuCount} to ${ciThreads} to prevent over-subscription`,
// );
}
if (envCiThreads) {
// console.log(
// `[Vitest Config] Using VITEST_CI_THREADS override: ${ciThreads}`,
// );
}
}
// Integration tests: includes global setup for server/db
export default defineConfig({
plugins: [tsconfigPaths()],
test: {
// Define integration test patterns
include: [
"test/drizzle/**/*.{test,spec}.ts",
"test/graphql/**/*.{test,spec}.ts",
"test/install/**/*.{test,spec}.ts",
],
exclude: [
...configDefaults.exclude,
"dist/**",
"coverage/**",
"docs/**",
"**/*.d.ts",
"data/**",
"docker/**",
"drizzle_migrations/**",
"envFiles/**",
"scripts/**",
"**/scripts/**",
],
coverage: {
provider: "v8",
reporter: ["text", "lcov", "html", "json"],
// Restrict integration coverage to integration-owned source paths
include: ["src/drizzle/**", "src/graphql/**", "src/install/**"],
// Only include files that are actually touched by tests
all: false,
exclude: [
...(configDefaults.coverage?.exclude ?? []),
"dist/**",
"coverage/**",
"docs/**",
"**/*.d.ts",
"data/**",
"docker/**",
"drizzle_migrations/**",
"envFiles/**",
"**/scripts/**",
"vitest.*.config.ts",
],
},
// https://vitest.dev/config/#globalsetup
globalSetup: ["./test/setup.ts"],
// https://vitest.dev/config/#passwithnotests
passWithNoTests: true,
hookTimeout: 30000, // 30 seconds for hooks
testTimeout: 60000, // 60 seconds per test
pool: "threads", // for faster test execution and to avoid postgres max-limit error
isolate: true,
maxWorkers: isCI ? ciThreads : localThreads,
// Set maxConcurrency lower than maxWorkers to prevent single heavy test files
// from consuming all workers and blocking other test files
maxConcurrency: isCI
? Math.max(1, Math.floor(ciThreads / 2))
: Math.max(1, Math.floor(localThreads / 2)),
fileParallelism: true,
sequence: {
shuffle: false,
concurrent: false,
},
},
});