2026-02-21 03:10:39 +00:00
|
|
|
import { defineConfig } from 'vitest/config';
|
2026-04-27 17:06:39 +01:00
|
|
|
import { availableParallelism } from 'node:os';
|
|
|
|
|
|
|
|
|
|
// Default vitest's pool to ~half the CPU threads we have. The previous
|
|
|
|
|
// implicit default left this 64-thread workstation at ~10% utilization
|
|
|
|
|
// during `pnpm test:run`. Half is a soft cap that stays kind to laptops
|
|
|
|
|
// (8-thread → 4 workers) while letting beefy hosts push closer to the
|
|
|
|
|
// box's actual capacity. Override at run time with VITEST_MAX_THREADS.
|
|
|
|
|
const cores = availableParallelism();
|
|
|
|
|
const maxThreads = Number(process.env['VITEST_MAX_THREADS'] ?? Math.max(2, Math.floor(cores / 2)));
|
2026-02-21 03:10:39 +00:00
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
test: {
|
|
|
|
|
globals: true,
|
2026-04-27 17:06:39 +01:00
|
|
|
pool: 'threads',
|
|
|
|
|
poolOptions: {
|
|
|
|
|
threads: { maxThreads, minThreads: 1 },
|
|
|
|
|
},
|
2026-02-21 03:10:39 +00:00
|
|
|
coverage: {
|
|
|
|
|
provider: 'v8',
|
|
|
|
|
reporter: ['text', 'json', 'html'],
|
|
|
|
|
exclude: ['**/node_modules/**', '**/dist/**', '**/*.config.*'],
|
|
|
|
|
},
|
|
|
|
|
include: ['src/*/tests/**/*.test.ts', 'tests/**/*.test.ts'],
|
2026-04-26 21:31:27 +01:00
|
|
|
// src/web tests need jsdom; they're run via the web package's own
|
|
|
|
|
// vitest.config.ts under the projects entry below.
|
|
|
|
|
exclude: ['**/node_modules/**', '**/smoke/**', 'src/db/tests/**', 'src/web/tests/**'],
|
2026-02-21 03:10:39 +00:00
|
|
|
testTimeout: 10000,
|
2026-04-26 21:31:27 +01:00
|
|
|
// Vitest 4 uses `projects` (in-config) instead of vitest.workspace.ts.
|
|
|
|
|
// Each project below is rooted in a workspace package; vitest reads
|
|
|
|
|
// its `vitest.config.ts` (or vite.config.ts) for the test config.
|
|
|
|
|
projects: [
|
|
|
|
|
'src/shared',
|
|
|
|
|
'src/cli',
|
|
|
|
|
'src/mcpd',
|
|
|
|
|
'src/mcplocal',
|
|
|
|
|
'src/web',
|
|
|
|
|
],
|
2026-03-07 00:39:25 +00:00
|
|
|
// DB tests require a test database; run them explicitly via:
|
|
|
|
|
// pnpm --filter db exec vitest run
|
|
|
|
|
// globalSetup: ['src/db/tests/global-setup.ts'],
|
2026-02-21 03:10:39 +00:00
|
|
|
},
|
|
|
|
|
});
|