hyperdx/packages/api/jest.setup.ts
Brandon Pereira e767d79e02
Clean Up Integration Test Console Output (#1566)
- Also fix issue where integration tests were making actual network requests
- this also slightly speeds up tests
- Fixes issues where there were JS errors thrown during tests due to incorrect mocks, causing confusion when adding/fixing other tests

Before (note: too much content to even see all tests)

https://github.com/user-attachments/assets/346bb57d-aa64-4a62-b666-3cf47fcc2a6c

After:

https://github.com/user-attachments/assets/f6379a93-2d1d-4f12-a467-02d874f98de6




Fixes HDX-3165
2026-01-07 17:38:01 +00:00

21 lines
664 B
TypeScript

// @eslint-disable @typescript-eslint/no-var-requires
jest.retryTimes(1, { logErrorsBeforeRetry: true });
global.console = {
...console,
// Turn off console.debug logs in tests (useful since we log db queries aggressively)
debug: jest.fn(),
};
// Mock alert notification functions to prevent HTTP calls during tests
jest.mock('@/utils/slack', () => ({
...jest.requireActual('@/utils/slack'),
postMessageToWebhook: jest.fn().mockResolvedValue(null),
}));
// Mock global fetch for generic webhook calls
global.fetch = jest.fn().mockResolvedValue({
ok: true,
text: jest.fn().mockResolvedValue(''),
json: jest.fn().mockResolvedValue({}),
} as any);