Files
siftlode/frontend/vitest.config.ts
T
peter 751e1ae5ed test: a size and complexity ratchet; coverage reported on both sides
The "class size" item from the quality checklist, measured:
- A shipped file over 800 lines may not grow past its line count today
  (13 frontend, 11 backend). No other file may cross 800.
- A function over the complexity limit may not rise, and no new one may
  appear. The limit is eslint `complexity` 20 on the frontend (64 functions
  over it today) and ruff C901 10 on the backend (32).
- Each is a per-file ceiling. Shrinking is free; an entry back under the
  limit must be deleted, so the lists only shrink.

C901 is measured in a test rather than switched on in ruff.toml: ruff has no
per-function baseline, and a noqa would let a function grow without limit.

Coverage (owner decision D4) is printed with no threshold:
`vitest --coverage` (v8) gives 80% of lines, and the pytest lane ends with
the total for app/, 78%. The bar stays "every regression test seen red".
.coverage is ignored by git and kept out of the image's build context.
2026-10-03 17:18:53 +02:00

32 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.
include: ["src/**/*.test.{ts,tsx}"],
environment: "node",
// E32 D4: a coverage REPORT, read and not enforced — the gate's `vitest --coverage` prints the
// summary; no threshold, because "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"],
},
},
});