diff --git a/src/__tests__/e2e/global.setup.ts b/src/__tests__/e2e/global.setup.ts index c7d808c..1419a62 100644 --- a/src/__tests__/e2e/global.setup.ts +++ b/src/__tests__/e2e/global.setup.ts @@ -6,6 +6,22 @@ import { chromium, type FullConfig } from '@playwright/test'; import { prisma } from '@/lib/prisma'; import { cleanupAllTestData } from '@/__tests__/test-utils'; +import path from 'path'; +import fs from 'fs'; + +// Load .env file first, then .env.development (which will override .env) +const envPath = path.resolve(process.cwd(), '.env'); +const envDevPath = path.resolve(process.cwd(), '.env.development'); + +// Load base .env file +if (fs.existsSync(envPath)) { + require('dotenv').config({ path: envPath }); +} + +// Load .env.development file (will override .env settings) +if (fs.existsSync(envDevPath)) { + require('dotenv').config({ path: envDevPath, override: true }); +} const authFile = 'playwright/.auth/user.json'; const adminAuthFile = 'playwright/.auth/admin.json'; diff --git a/vitest.setup.ts b/vitest.setup.ts index a9dd55f..75e7800 100644 --- a/vitest.setup.ts +++ b/vitest.setup.ts @@ -1,4 +1,6 @@ import '@testing-library/jest-dom' +import path from 'path' +import fs from 'fs' /** * Vitest Setup File @@ -8,6 +10,20 @@ import '@testing-library/jest-dom' * to prevent accidental data corruption. */ +// Load .env file first, then .env.development (which will override .env) +const envPath = path.resolve(process.cwd(), '.env'); +const envDevPath = path.resolve(process.cwd(), '.env.development'); + +// Load base .env file +if (fs.existsSync(envPath)) { + require('dotenv').config({ path: envPath }); +} + +// Load .env.development file (will override .env settings) +if (fs.existsSync(envDevPath)) { + require('dotenv').config({ path: envDevPath, override: true }); +} + // Check if DATABASE_URL is set and points to dev database const databaseUrl = process.env.DATABASE_URL;