forked from nosana-ci/agent-challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.env.js
More file actions
80 lines (63 loc) · 2.38 KB
/
Copy pathjest.setup.env.js
File metadata and controls
80 lines (63 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* Jest Setup - Environment Variables
*
* This file runs BEFORE test environment is set up
* Use for setting environment variables needed for tests
*/
const fs = require('fs');
const path = require('path');
// ============================================
// LOAD .env.test IF EXISTS
// ============================================
const envTestPath = path.join(__dirname, '.env.test');
if (fs.existsSync(envTestPath)) {
console.log('📄 Loading .env.test for integration tests...');
const envContent = fs.readFileSync(envTestPath, 'utf8');
envContent.split('\n').forEach(line => {
line = line.trim();
if (line && !line.startsWith('#')) {
const [key, ...valueParts] = line.split('=');
const value = valueParts.join('=').trim();
if (key && value) {
process.env[key] = value;
}
}
});
console.log('✅ .env.test loaded successfully');
} else {
console.log('⚠️ .env.test not found, using mock values for unit tests');
// ============================================
// MOCK ENVIRONMENT VARIABLES (for unit tests)
// ============================================
// Supabase Configuration
process.env.NEXT_PUBLIC_SUPABASE_URL = 'https://test.supabase.co';
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY = 'test-anon-key-1234567890';
process.env.SUPABASE_SERVICE_ROLE_KEY = 'test-service-role-key-1234567890';
// Google Generative AI
process.env.GOOGLE_GENERATIVE_AI_API_KEY = 'test-google-ai-key-1234567890';
// Next.js Configuration
process.env.NEXT_PUBLIC_APP_URL = 'http://localhost:3000';
// Integration Tests - disabled by default unless explicitly enabled
if (!process.env.ENABLE_INTEGRATION_TESTS) {
process.env.ENABLE_INTEGRATION_TESTS = 'false';
}
}
// Always set NODE_ENV and TZ
process.env.NODE_ENV = 'test';
// ============================================
// CONSOLE SUPPRESSION (Optional)
// ============================================
// Uncomment to suppress console.log/warn/error in tests
// const originalConsole = global.console;
// global.console = {
// ...originalConsole,
// log: jest.fn(),
// warn: jest.fn(),
// error: jest.fn(),
// };
// ============================================
// TIMEZONE (Optional)
// ============================================
// Set timezone for consistent date/time testing
process.env.TZ = 'UTC';
console.log('✅ Jest environment variables configured');