- All 8 vitest configs now default maxWorkers to \`cpus().length - 1\` instead of the arbitrary \`Math.min(4, …)\` cap. Respects an explicit VITEST_MAX_WORKERS override for constrained environments (CI, laptops on battery). CLI keeps \`fileParallelism: false\` — audit found real shared state (process.chdir in agent-import, dist/ races in build-exe suites) that needs refactoring before we can flip it. - packages/dashboard: move the mobile build-output smoke test (which invokes \`pnpm build:client\` via execSync, ~3s per run) into a dedicated \`test:build\` script so \`pnpm test\` isn't gated by it. A matching root script keeps CI wiring simple. - Root: bump --workspace-concurrency from 2 → 4 so core/engine/cli/ desktop can pipeline against dashboard's tail. - Drop the now-redundant VITEST_MAX_WORKERS=4 prefix from the root scripts; the per-package configs pick up cpu count themselves. Dashboard test suite: 182s → 38s (5x) on a 10-core machine. Full workspace run: ~3m15 → 2m29. All tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
17 lines
659 B
TypeScript
17 lines
659 B
TypeScript
import { defineConfig } from "vitest/config";
|
|
import { cpus } from "node:os";
|
|
|
|
const defaultMaxWorkers = Math.max(1, cpus().length - 1);
|
|
const requestedMaxWorkers = Number.parseInt(process.env.VITEST_MAX_WORKERS ?? String(defaultMaxWorkers), 10);
|
|
const maxWorkers = Math.max(1, Number.isFinite(requestedMaxWorkers) ? requestedMaxWorkers : defaultMaxWorkers);
|
|
process.env.VITEST_MAX_WORKERS = String(maxWorkers);
|
|
|
|
export default defineConfig({
|
|
test: {
|
|
include: ["src/**/*.test.ts"],
|
|
maxWorkers,
|
|
poolOptions: { threads: { minThreads: 1, maxThreads: maxWorkers }, forks: { minForks: 1, maxForks: maxWorkers } },
|
|
fileParallelism: true,
|
|
},
|
|
});
|