34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
/**
|
|
* Test setup file - Loaded before all tests
|
|
* Handles environment variable loading and global test configuration
|
|
*/
|
|
|
|
const path = require('path');
|
|
|
|
// Parse --env argument (default: ./environment.env)
|
|
const args = process.argv.slice(2);
|
|
let envFile = './environment.env';
|
|
for (let i = 0; i < args.length; i++) {
|
|
if (args[i] === '--env' && args[i + 1]) {
|
|
envFile = args[i + 1];
|
|
i++;
|
|
}
|
|
}
|
|
|
|
// Load environment variables from environment.env
|
|
const envPath = path.resolve(process.cwd(), envFile);
|
|
require('dotenv').config({ path: envPath });
|
|
|
|
console.log(`\n🔧 Test environment loaded from: ${envFile}`);
|
|
console.log(` NODE_ENV: ${process.env.NODE_ENV || 'not set'}`);
|
|
console.log(` DB_NAME: ${process.env.DB_NAME || 'not set'}`);
|
|
console.log(` STRIPE_SEC_KEY: ${process.env.STRIPE_SEC_KEY ? '***' + process.env.STRIPE_SEC_KEY.slice(-10) : 'not set'}\n`);
|
|
|
|
// Global test timeout (can be overridden per test)
|
|
if (typeof afterEach !== 'undefined') {
|
|
// Set default timeout for all tests (30 seconds for API calls)
|
|
afterEach(function() {
|
|
this.timeout(30000);
|
|
});
|
|
}
|