import { defineConfig } from "vitest/config"; import react from "@vitejs/plugin-react"; // 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 a no-op for the plain .ts node tests (they carry no JSX). jsdom is a // devDependency referenced only via that docblock env string — knip's vitest plugin still sees it. export default defineConfig({ plugins: [react()], 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", }, });