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", }, });