Files
bookorbit/client/vitest.config.ts
neon cb2ea1e898 build: serialize test runs so concurrent agents cannot saturate the machine
Each run sized its worker pool to the whole machine, so simultaneous runs
drove the box into swap until no suite finished and tests began failing on
the 5s default timeout. Serialize runs behind a lock, cap worker counts, and
raise testTimeout. See scripts/dev/with-test-lock.mjs.
2026-08-24 04:49:55 +00:00

43 lines
1.8 KiB
TypeScript

import { fileURLToPath } from 'node:url'
import { availableParallelism } from 'node:os'
import { mergeConfig, defineConfig, configDefaults } from 'vitest/config'
import viteConfig from './vite.config'
// Concurrent agents sharing this worktree each start their own runner, and an uncapped pool
// sizes itself to the whole machine. The lock wrapper raises this for the run that holds the
// lock; anything bypassing the wrapper stays on the conservative floor.
const localMaxWorkers = Number(process.env.BO_TEST_MAX_WORKERS) || Math.max(2, Math.floor(availableParallelism() / 3))
export default mergeConfig(
viteConfig,
defineConfig({
test: {
environment: 'jsdom',
maxWorkers: process.env.CI ? undefined : localMaxWorkers,
testTimeout: 15_000,
setupFiles: ['./src/test-setup.ts'],
// Node 26 defines `localStorage` and `sessionStorage` on globalThis, and jsdom shares that
// object, so its own storage never gets installed. Node's `localStorage` then reads as
// undefined unless the process was started with `--localstorage-file`, and its
// `sessionStorage` is a process-wide store no test file can reset. Standing Node's
// implementation down leaves jsdom's in place, isolated per test file.
execArgv: ['--no-experimental-webstorage'],
exclude: [...configDefaults.exclude, 'e2e/**'],
root: fileURLToPath(new URL('./', import.meta.url)),
coverage: {
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
reportsDirectory: './coverage',
include: ['src/**/*.{ts,vue}'],
exclude: ['src/**/*.test.ts', 'src/**/*.spec.ts', 'src/**/__tests__/**', 'src/main.ts', 'src/**/*.d.ts', 'src/**/*.types.ts'],
thresholds: {
lines: 1,
statements: 1,
functions: 1,
branches: 1,
},
},
},
}),
)