import path from "node:path"; import react from "@vitejs/plugin-react"; import { defineConfig } from "vitest/config"; export default defineConfig({ plugins: [react()], resolve: { // Mirror tsconfig.json `paths` so tests can import via `@/*`. alias: { "@": path.resolve(__dirname, "./app"), }, }, test: { // happy-dom is required for any test that mounts a React tree — // node leaves `document`/`window` undefined. Server-only tests still // pass because happy-dom is a superset of node's globals. environment: "happy-dom", // Inline @raredays/* sources so vitest doesn't choke on ESM-internal // package paths when components import from sibling subpath exports. server: { deps: { inline: [/@raredays\//], }, }, include: ["app/**/*.test.ts", "app/**/*.test.tsx", "lib/**/*.test.ts"], setupFiles: ["./vitest.setup.ts"], // Env stubs for module-load-time provider construction. // // Some `@raredays/*` providers eagerly read env at import time // (e.g. `cms.ts` reading `HYGRAPH_ENDPOINT`). Without stubs here, // any test that transitively imports such a module fails to LOAD. // Real values via `.env.local` override these in real dev runs. // // Add stubs for any integration declared in `site.spec.ts` whose // provider constructs at import time. Defect D11 (T010 turn 0229). env: { MOCKS: "on", HYGRAPH_ENDPOINT: "http://localhost:test", HYGRAPH_TOKEN: "test", }, }, });