From 4c51bd5ba2468ba0503503659317c5dcc5b540ef Mon Sep 17 00:00:00 2001 From: Torben Sorensen Date: Sat, 22 Nov 2025 10:37:09 -0800 Subject: [PATCH] units --- server.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server.ts b/server.ts index a117d322..4f7f7045 100644 --- a/server.ts +++ b/server.ts @@ -12,8 +12,13 @@ import userRouter from './src/routes/user'; import adminRouter from './src/routes/admin'; import aiRouter from './src/routes/ai'; -// Load environment variables from a .env file at the root of your project -dotenv.config(); +// Conditionally load environment variables based on the environment. +// When running tests, `NODE_ENV` is automatically set to 'test' by Vitest. +if (process.env.NODE_ENV === 'test') { + dotenv.config({ path: '.env.test' }); +} else { + dotenv.config(); // Load the default .env file for development/production +} const app = express();