import { defineConfig } from "vitest/config"; import { config as loadDotenv } from "dotenv"; import { resolve } from "node:path"; import { existsSync } from "node:fs"; // Load .env file from monorepo root (for local dev) // Try main repo path first (../../.env from apps/appview) // If not found, try worktree path (../../../../.env from .worktrees/branch/apps/appview) const mainRepoPath = resolve(__dirname, "../../.env"); const worktreePath = resolve(__dirname, "../../../../.env"); const envPath = existsSync(mainRepoPath) ? mainRepoPath : worktreePath; // Load .env at config time so variables are available when tests run // dotenv won't override existing environment variables (e.g., from CI) loadDotenv({ path: envPath }); export default defineConfig({ test: { environment: "node", // Run test files sequentially to avoid database conflicts // Tests share a single test database and use the same test DIDs fileParallelism: false, }, });