// Jest setup file for global test configuration const path = require("path"); // Set test environment process.env.NODE_ENV = "test"; process.env.EMAIL_TEST_MODE = "true"; process.env.EMAIL_USER = "test@example.com"; process.env.EMAIL_PASS = "test-password"; process.env.DELAY_MINUTES = "0"; // No delay in tests process.env.LOG_LEVEL = "error"; // Reduce log noise in tests // Mock external dependencies jest.mock("nodemailer", () => ({ createTransporter: jest.fn(() => ({ sendMail: jest.fn(() => Promise.resolve({ messageId: "test-123" })), })), })); // Mock delay module to make tests faster jest.mock("delay", () => jest.fn(() => Promise.resolve())); // Console spy to reduce output noise in tests global.consoleSpy = jest.spyOn(console, "log").mockImplementation(() => {}); global.consoleErrorSpy = jest .spyOn(console, "error") .mockImplementation(() => {}); global.consoleWarnSpy = jest .spyOn(console, "warn") .mockImplementation(() => {}); // Clean up after each test afterEach(() => { jest.clearAllMocks(); }); // Clean up after all tests afterAll(() => { global.consoleSpy.mockRestore(); global.consoleErrorSpy.mockRestore(); global.consoleWarnSpy.mockRestore(); });