Something went wrong. Try again.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243import type { ViteUserConfig } from "vitest/config";
/** * Three test levels, each measured on its own (a level must reach the threshold by itself): * - unit: one function or class in isolation. No filesystem, network or child process. * - functional: one feature through its public entry point (a function or a CLI) using the real filesystem and real processes. * - integration: two or more real components working together (for example CLI + git + scanner on a real repository). * Source files under these folders count toward coverage even if no test touches them ("include"), so a file nobody tests drags the number down. */export const SOURCE_GLOBS = [ "shared/**/*.ts", "central/**/*.ts", "tools/**/*.ts", "runner/**/*.ts", "bridge/**/*.ts", "extension/**/*.ts", "report/**/*.ts",];
export const THRESHOLD = 70;
export function levelConfig(level: "unit" | "functional" | "integration"): ViteUserConfig { return { test: { include: [`test/${level}/**/*.test.ts`], environment: "node", testTimeout: level === "unit" ? 5_000 : 30_000, // The functional and integration levels start real Chromes and many child processes. Letting vitest use every core at once // (31 workers here) made CI workers abort and Chromes miss their start-up window; a handful at a time is steadier. ...(level === "unit" ? {} : { maxWorkers: 6 }), coverage: { provider: "v8", enabled: true, reportsDirectory: `coverage/${level}`, reporter: ["text-summary", "text", "json-summary"], include: SOURCE_GLOBS, exclude: ["**/*.d.ts", "**/*Cli.ts", "**/types.ts", "extension/src/background.ts", "extension/src/content.ts", "extension/worker/hostEntry.ts"], thresholds: { lines: THRESHOLD, functions: THRESHOLD, branches: THRESHOLD, statements: THRESHOLD }, }, }, };}