-
Notifications
You must be signed in to change notification settings - Fork 10
/
jest.setup.ts
33 lines (27 loc) · 941 Bytes
/
jest.setup.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* eslint-disable */
import '@testing-library/jest-dom';
import '@testing-library/jest-dom/jest-globals';
import { useConfig, useNotificationPreferences } from '@magicbell/react-headless';
import EventSource from 'eventsource';
import fetch, { Headers, Request, Response } from 'node-fetch';
globalThis.fetch = fetch as any;
globalThis.Headers = Headers as any;
globalThis.Request = Request as any;
globalThis.Response = Response as any;
if (!globalThis.EventSource) {
globalThis.EventSource = EventSource;
}
// it's defined in vitest environment
// eslint-disable-next-line no-undef
if (typeof window !== 'undefined') {
window.open = jest.fn();
}
beforeEach(() => {
useConfig.setState({ lastFetchedAt: Date.now() });
useNotificationPreferences.setState({ lastFetchedAt: Date.now() });
});
const _log = console.log;
console.log = (...args: any[]) => {
if (String(args[0]).startsWith('sse error:')) return;
_log(...args);
}