import { defineConfig } from "vitest/config"; import tsconfigPaths from "vite-tsconfig-paths"; import { readFileSync, existsSync } from "fs"; import { resolve } from "path"; // Load .env.test into process.env HERE, at config-load time. // Forked workers inherit the parent process env, so Prisma's singleton // will see the test DATABASE_URL when db.ts is first imported. const envTestPath = resolve(__dirname, ".env.test"); if (existsSync(envTestPath)) { for (const line of readFileSync(envTestPath, "utf-8").split("\n")) { const m = line.match(/^([^#=]+)=(.*)/); if (m) process.env[m[1].trim()] = m[2].trim(); } } export default defineConfig({ plugins: [tsconfigPaths()], test: { environment: "node", include: ["src/__tests__/integration/**/*.test.ts"], pool: "forks", }, });