import { configDefaults, defineConfig } from "vitest/config"; export default defineConfig({ test: { globals: false, setupFiles: ["./tests/setup.ts"], restoreMocks: true, clearMocks: true, mockReset: true, testTimeout: 10_000, // A runaway serialization inside a worker (the classic case: an assertion // library inspecting a React-rendered DOM node, whose `__reactFiber$*` // graph re-expands per traversal path) allocates until the machine's OOM // killer takes the whole run down -- 29.5GB and ~40s here, reported as a // bare "worker exited" with no failing test named. Capping the worker's // old-space turns that into a `Reached heap limit` abort in ~3s, next to // the file that caused it. The ceiling is chosen well above real demand: // the heaviest suite (`tests/unit`, 126 files) peaks near 1.3GB RSS, of // which old-space is only a fraction. execArgv: ["--max-old-space-size=2048"], exclude: [ ...configDefaults.exclude, ".tmp/**", // A git worktree inside the repository is a different checkout of a // different branch. Running its tests against this checkout's config // reports failures that belong to neither. ".worktrees/**", "tests/fixtures/v8-coverage-counter-semantics/**", ], coverage: { provider: "v8", reportsDirectory: "artifacts/tests/coverage", reporter: ["text", "json-summary", "lcov"], include: ["src/**/*.{ts,tsx}"], exclude: ["**/*.d.ts", "**/*.stories.*"], }, }, });