diff --git a/backend/vitest.config.ts b/backend/vitest.config.ts index eb261fd5..fd4035ef 100644 --- a/backend/vitest.config.ts +++ b/backend/vitest.config.ts @@ -8,11 +8,19 @@ export default defineConfig({ exclude: ['dist/**', 'node_modules/**'], // Each test file gets its own worker so singletons are fresh between files. pool: 'forks', + // Cap concurrency: each worker dynamic-imports the full Express stack + // (TypeScript transform + DB init + every migration), so an uncapped + // fork pool that scales with availableParallelism saturates CPU and + // the suite spends most of its wall time waiting on cold-start + // contention. Four parallel workers is a sweet spot on both CI + // runners and laptops. + maxWorkers: 4, + minWorkers: 1, // Timeout generous for DB init and HTTP calls. testTimeout: 30_000, // Every test file dynamic-imports the full Express stack; each fork pays // TypeScript transformation cost and can take tens of seconds under - // CPU contention when all 64 fork workers run at once. + // CPU contention. hookTimeout: 45_000, // Sequential within each file (DB state is shared per file). sequence: { concurrent: false },