← back to Handbag Auth Nextjs
auction-viewer/tests/setup.js
34 lines
// Global test setup
const fs = require('fs');
const path = require('path');
// Set test environment variables
process.env.NODE_ENV = 'test';
process.env.TEST_MODE = 'true';
// Increase timeout for database operations
jest.setTimeout(30000);
// Global teardown - cleanup test databases
global.afterAll(() => {
// Clean up test databases if they exist
const testDbPath = path.join(__dirname, 'fixtures', 'test-auctions.db');
if (fs.existsSync(testDbPath)) {
try {
fs.unlinkSync(testDbPath);
} catch (error) {
console.warn('Could not clean up test database:', error.message);
}
}
});
// Suppress console.log during tests (optional)
if (process.env.SILENT_TESTS === 'true') {
global.console = {
...console,
log: jest.fn(),
debug: jest.fn(),
info: jest.fn(),
};
}