cameras/vitest.config.mts
Michael Mainguy 4931c3af83 Reach 99.8% test coverage and enforce a 95% floor
- Route tests for camera info, snapshot and credentials (vrek
  iss-nc2tj7c): input validation, store-only-after-verify, reconnects
  after login changes, and fixed error messages with no upstream text.
- Providers and layout tests (iss-nc5w0j8).
- Discovery tests for onvif.ts (iss-3bg4r6e): multicast parsing,
  unicast sweep batching and subnet limits, de-duplication and
  merging. They run on a fake network, replacing onvif Discovery,
  node:dgram and node:os, per new vrek principle pri-e14bahk
  (replaceable transport; tests never touch the real network).
- coverage.thresholds.lines = 95, so `npm run coverage` fails below
  the goal (iss-zjpc22k).

200 tests, 99.77% line coverage. Refreshes the vrek export.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-19 09:17:55 -05:00

36 lines
1.1 KiB
TypeScript

import { fileURLToPath } from "node:url";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vitest/config";
export default defineConfig({
plugins: [react()],
resolve: {
// Resolves the "@/*" path alias from tsconfig.json.
tsconfigPaths: true,
alias: {
// The real package throws unless bundled for React Server Components.
"server-only": fileURLToPath(new URL("./test/server-only.ts", import.meta.url)),
},
},
test: {
// Server code runs in Node; component tests opt in with `// @vitest-environment jsdom`.
environment: "node",
include: ["src/**/*.test.{ts,tsx}"],
restoreMocks: true,
unstubEnvs: true,
coverage: {
provider: "v8",
include: ["src/**/*.{ts,tsx}"],
exclude: [
"src/**/*.test.{ts,tsx}",
"src/**/*.d.ts",
// Async Server Component: unit runners can't render it (Next docs, testing/vitest.md).
"src/app/page.tsx",
],
reporter: ["text", "json-summary"],
// Goal gol-9zxah3p in vrek: `npm run coverage` fails if line coverage drops below 95%.
thresholds: { lines: 95 },
},
},
});