/** * Jest setup file for Pacifica Wash Trading System * Global test configuration and utilities */ import { config } from 'dotenv'; // Load environment variables for testing config({ path: '.env.test' }); // Set default test environment variables process.env.NODE_ENV = 'test'; process.env.LOG_LEVEL = 'error'; process.env.PACIFICA_API_KEY = 'test-api-key'; process.env.PACIFICA_BASE_URL = 'https://api.test.pacifica.fi'; process.env.WEBSOCKET_URL = 'wss://ws.test.pacifica.fi'; process.env.ENCRYPTION_KEY = 'test-encryption-key-32-characters'; // Global test timeout jest.setTimeout(30000); // Mock console methods in tests to reduce noise global.console = { ...console, log: jest.fn(), debug: jest.fn(), info: jest.fn(), warn: jest.fn(), error: jest.fn(), }; // Global test utilities global.testUtils = { generateId: () => `test-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, sleep: (ms: number) => new Promise(resolve => setTimeout(resolve, ms)), mockDate: (date: Date) => { jest.useFakeTimers(); jest.setSystemTime(date); }, restoreDate: () => { jest.useRealTimers(); } }; // Cleanup after each test afterEach(() => { jest.clearAllMocks(); jest.restoreAllMocks(); }); // Global cleanup afterAll(() => { jest.useRealTimers(); });