fix: load .env.development in test setup files
This commit is contained in:
@@ -6,6 +6,22 @@
|
|||||||
import { chromium, type FullConfig } from '@playwright/test';
|
import { chromium, type FullConfig } from '@playwright/test';
|
||||||
import { prisma } from '@/lib/prisma';
|
import { prisma } from '@/lib/prisma';
|
||||||
import { cleanupAllTestData } from '@/__tests__/test-utils';
|
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 authFile = 'playwright/.auth/user.json';
|
||||||
const adminAuthFile = 'playwright/.auth/admin.json';
|
const adminAuthFile = 'playwright/.auth/admin.json';
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import '@testing-library/jest-dom'
|
import '@testing-library/jest-dom'
|
||||||
|
import path from 'path'
|
||||||
|
import fs from 'fs'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vitest Setup File
|
* Vitest Setup File
|
||||||
@@ -8,6 +10,20 @@ import '@testing-library/jest-dom'
|
|||||||
* to prevent accidental data corruption.
|
* 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
|
// Check if DATABASE_URL is set and points to dev database
|
||||||
const databaseUrl = process.env.DATABASE_URL;
|
const databaseUrl = process.env.DATABASE_URL;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user