fix: resolve test environment loading race condition in CI

- Move getTestConfig() calls from module level to test execution time
- Add CI-specific debug logging to diagnose environment loading issues
- Add verification step in CI workflow to check .env.test availability
- Ensure environment variables are loaded before tests access config

The issue was that config was being accessed at module import time,
which could happen before the global setup runs in some CI environments.
This commit is contained in:
czlonkowski
2025-07-29 07:13:37 +02:00
parent 6c40057cf4
commit a8c3d04c12
4 changed files with 80 additions and 30 deletions

View File

@@ -1,9 +1,18 @@
import { beforeEach, afterEach, vi } from 'vitest';
import { loadTestEnvironment, getTestConfig, getTestTimeout } from './test-env';
// CI Debug: Log environment loading in CI only
if (process.env.CI === 'true') {
console.log('[CI-DEBUG] Global setup starting, NODE_ENV:', process.env.NODE_ENV);
}
// Load test environment configuration
loadTestEnvironment();
if (process.env.CI === 'true') {
console.log('[CI-DEBUG] Global setup complete, N8N_API_URL:', process.env.N8N_API_URL);
}
// Get test configuration
const testConfig = getTestConfig();