fix: load .env.development in test setup files

This commit is contained in:
2026-03-31 18:30:19 -07:00
parent 4e112c92ae
commit 6989decf6f
2 changed files with 32 additions and 0 deletions
+16
View File
@@ -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;