Files
siftlode/frontend/vitest.config.ts
T
peter 0b24f2d8fa fix(frontend): the chunk guard's logic lives in the guard, so no file sits in two TypeScript projects
The guard's logic was a src/lib file the config project also listed. The app project, which
references the config project, then refuses that source on a clean build (TS6305) — while every
local run reused the referenced project's cached output and stayed green; only the Docker image
build failed. The logic is back inside chunkGuard.ts, its test beside it at the frontend root
(vitest now also collects `*.test.ts` there), and a gate contract fails when the config project's
include reaches into src/ again. The guard was re-proved on a build with a leaking re-export.
2026-10-22 23:48:16 +02:00

33 lines
1.8 KiB
TypeScript

import { defineConfig } from "vitest/config";
import { reactWithCompiler } from "./reactPlugin";
// Unit + component/hook tests, deliberately separate from vite.config.ts so the production build
// never has to load vitest. The DEFAULT environment is node (the pure src/lib helpers — fast, no
// DOM). A test that needs the DOM (component render or renderHook) opts INTO jsdom per-file with a
// // @vitest-environment jsdom
// docblock on its first line. plugin-react is wired here so those tests get JSX + a Fast-Refresh-
// free React transform. It is NOT a no-op for the plain .ts node tests: the plugin's filter is
// /\.[tj]sx?$/, so the React Compiler rewrites `src/lib`'s hooks in that lane too (usePref,
// useCardPager, plexPlayerHooks all come out with `react/compiler-runtime` memo slots). That is the
// point of sharing one factory with vite.config.ts — the gate compiles the code the way the build
// does — and it is worth knowing before ruling the compiler out of a divergence. jsdom is a
// devDependency referenced only via that docblock env string — knip's vitest plugin still sees it.
export default defineConfig({
plugins: [reactWithCompiler()],
test: {
// .tsx included on purpose: a test file the glob misses does not fail, it is simply never
// collected, and the gate still prints green.
// …and the build plugins' own tests beside them at the frontend root (chunkGuard).
include: ["src/**/*.test.{ts,tsx}", "*.test.ts"],
environment: "node",
// A coverage REPORT on demand (`npm run test -- --coverage`), never enforced and not in the gate:
// "every regression test seen red" is the bar, not a percentage.
coverage: {
provider: "v8",
include: ["src/**/*.{ts,tsx}"],
exclude: ["src/**/*.test.{ts,tsx}", "src/**/*.testkit.ts", "src/**/*.d.ts"],
reporter: ["text-summary"],
},
},
});