fix: load .env.development in test setup files
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user