import { defineConfig } from "vitest/config"; import react from "@vitejs/plugin-react"; import { resolve } from "path"; export default defineConfig({ plugins: [react()], test: { globals: true, setupFiles: ["./vitest.setup.ts"], exclude: ["node_modules", ".next", "e2e/**"], // Only component tests (.tsx) pay for a jsdom instance; logic tests (.ts) run in plain node, which // was most of the suite's per-file setup time. A .ts test that needs the DOM opts in with a // `// @vitest-environment jsdom` first line. projects: [ { extends: true, test: { name: "dom", environment: "jsdom", include: ["**/*.{test,spec}.tsx"] } }, { extends: true, test: { name: "node", environment: "node", include: ["**/*.{test,spec}.ts"] } }, ], // Form flows that type into many fields run past vitest's 5 s default when all ~360 files run in // parallel (different tests timed out on each full run). A single budget here, not per-file patches. testTimeout: 20000, }, resolve: { alias: { "@": resolve(__dirname, "."), // server-only throws if imported outside an RSC bundle; stub it in tests. "server-only": resolve(__dirname, "test/stub-empty.ts"), }, }, });