Sets up Vitest (jsdom, Testing Library, v8 coverage) per the Next 16 testing guide, using Vite's native tsconfig path resolution instead of vite-tsconfig-paths. A server-only stub and a temp-data helper let server modules run in isolation. @types/node moves to ^24 to match the Node 24 runtime (a vitest 5 peer requirement). First 68 tests cover the discover route (including iss-dbwgww8: no raw errors in responses), the credential store, the camera registry, camera-route helpers and the refresh-rate schema. Line coverage is 31.2%, toward the 95% goal. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
34 lines
1.0 KiB
TypeScript
34 lines
1.0 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"],
|
|
},
|
|
},
|
|
});
|