velxio/frontend/vitest.config.ts

55 lines
2.0 KiB
TypeScript

import { defineConfig } from 'vitest/config';
/**
* Vitest configuration — split out from `vite.config.ts` (Phase 1d-tests J).
*
* `vite.config.ts` no longer owns the `test:` block; vitest auto-loads
* this file and CI workflows can reference it directly. Defaults below
* tune for the velxio test suite:
*
* - 30 s test timeout: smoke tests iterating 200+ examples need
* headroom; per-test individual asserts are still fast.
* - `forks` pool with `singleFork: false` so each test file runs in
* its own Node worker. The NgSpiceNodeAdapter is a process-wide
* singleton (emscripten module can't reinitialise); without per-file
* isolation, state leaks between tests sharing the same worker.
* - Coverage excludes the WASM bundle (large binary, irrelevant lcov)
* and the test files themselves.
*/
export default defineConfig({
test: {
globals: true,
environment: 'node',
include: ['src/__tests__/**/*.test.ts'],
testTimeout: 30_000,
hookTimeout: 30_000,
// Vitest 4 removed `test.poolOptions` — config moved to top-level
// `forks` / `threads` / etc. See the deprecation banner the runner
// emits: "DEPRECATED test.poolOptions was removed in Vitest 4. All
// previous poolOptions are now top-level options."
//
// Each forked worker also needs its heap cap raised because the
// suite leaks state across the 117 test files (ngspice WASM ~30 MB
// per init, MixedModeScheduler singleton, zustand stores). Even
// sharded (60 files / shard) the leak overflows Node's 4 GB
// default; 8 GB plus sharding fits the runner's 16 GB budget.
forks: {
singleFork: false,
execArgv: ['--max-old-space-size=8192'],
},
coverage: {
provider: 'v8',
include: [
'src/simulation/**/*.ts',
'src/utils/exampleTo*.ts',
],
exclude: [
'**/*.test.ts',
'**/__tests__/**',
'src/simulation/spice/wasm/**',
],
reporter: ['text', 'lcov', 'html'],
},
},
});