From 75766a37b4862a0d1880ee5febf3c398f08fe032 Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Sat, 7 Feb 2026 21:44:02 -0600 Subject: [PATCH] fix(test): Skip loading .env.test in CI environments The .env.test file was being loaded in CI and overriding the CI-provided DATABASE_URL, causing tests to try connecting to localhost:5432 instead of the postgres:5432 service. Fix: Only load .env.test when NOT in CI (check for CI or WOODPECKER env vars). Co-Authored-By: Claude Opus 4.6 --- apps/api/vitest.setup.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/api/vitest.setup.ts b/apps/api/vitest.setup.ts index b05036a..6156f98 100644 --- a/apps/api/vitest.setup.ts +++ b/apps/api/vitest.setup.ts @@ -5,9 +5,11 @@ import * as fs from "fs"; // Load environment variables from .env.test if it exists // This allows local integration tests to run with a local database -// CI environments explicitly provide DATABASE_URL in the test step +// CI environments explicitly provide DATABASE_URL in the test step, so skip loading .env.test there const envTestPath = path.resolve(__dirname, ".env.test"); -if (fs.existsSync(envTestPath)) { +const isCI = process.env.CI === "true" || process.env.WOODPECKER === "true"; + +if (!isCI && fs.existsSync(envTestPath)) { const result = dotenv.config({ path: envTestPath }); if (result.error) { throw new Error(