Files
EpicNext-Cms/vitest.config.ts
openhands 4768b2b406
CI / check (push) Successful in 36s
CI / tests-integration (push) Successful in 1m54s
CI / tests-quality (push) Successful in 49s
CI / tests-imaging-browsers (push) Successful in 1m35s
CI / tests-unit (push) Successful in 4m21s
CI / tests-ui (push) Successful in 4m54s
CI / preflight (push) Skipped
CI / deploy (push) Successful in 20s
fix: limit vitest to one worker to avoid 100% CPU
2026-10-23 14:21:23 +02:00

64 lines
2.0 KiB
TypeScript

import { fileURLToPath } from "node:url";
import { defineConfig } from "vitest/config";
// Project-local config: keeps the `@/` alias, the server-only stub and the
// env fallbacks with the repo instead of relying on whatever vite config a
// parent directory happens to provide.
export default defineConfig({
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
// server-only throws in Node; tests don't need the Next client guard.
"server-only": fileURLToPath(
new URL("./src/test/server-only-stub.ts", import.meta.url),
),
},
},
test: {
setupFiles: ["./vitest.setup.ts"],
environment: "node",
// Preserve module-initialization calls used by route permission contract tests.
clearMocks: false,
// Modules under test transitively import @/env; skip its strict parse so
// unit tests run without a populated .env.
env: {
SKIP_ENV_VALIDATION: "1",
HOTEL_NAME: "TestHotel",
DATABASE_URL: "mysql://root:root@localhost:3306/test",
},
testTimeout: 10000,
maxWorkers: 1,
fileParallelism: false,
exclude: ["integration/**", "e2e/**", "node_modules/**", ".next/**"],
coverage: {
// Off unless asked for (`pnpm test:coverage` passes
// `--coverage.enabled=true`): a focused `vitest run <file>` should
// not fail the global thresholds it cannot possibly meet, and
// measuring v8 coverage on every run costs real time.
enabled: false,
provider: "v8",
reporter: ["text", "lcov", "html"],
// Ratchet floor: measured 37.14 / 30.09 / 31.74 / 38.13 on the full
// suite (statements/branches/functions/lines). Rounded down so only
// a real regression fails the build — raise these to the new
// measured floor whenever coverage improves.
thresholds: {
statements: 37,
branches: 30,
functions: 31,
lines: 38,
},
include: ["src/**/*.{ts,tsx}"],
exclude: [
"src/generated/**",
"src/**/*.test.ts",
"src/**/*.test.tsx",
"src/**/*-client.tsx",
"src/**/*-widget.tsx",
"src/types/**",
"src/test/**",
],
},
},
});