import { defineConfig } from "vitest/config"; export default defineConfig({ resolve: { tsconfigPaths: true }, test: { environment: "node", globals: false, // Loads .env before any test file's imports run. Several modules under // test (e.g. @/lib/auth/permissions -> @/lib/db/prisma) build the // database connection at import time, so a test that imports one of // them before fixtures.ts (which also loads dotenv) used to die with // "Database connection is not configured" — a pure import-order // accident, not a real failure. setupFiles: ["dotenv/config"], // E2E_TEST_MODE switches off the OTP rate limits (see otp.service.ts) // for Playwright. Integration tests assert those limits exist, so pin it // off here even if the surrounding environment/.env has it on — dotenv // never overrides a variable that's already set. env: { E2E_TEST_MODE: "false" }, include: ["**/*.integration.test.ts"], // "**/node_modules/**" (not "node_modules/**") — see vitest.config.mts's // own comment for why this matters once a nested node_modules // (manager/node_modules) exists in the repo. exclude: ["**/node_modules/**", ".next/**", "templates/**", "manager/**"], // Concurrency tests (double-booking prevention) need real, unshared // DB connections and predictable ordering — run integration test // files one at a time. fileParallelism: false, testTimeout: 20000, }, });