-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.setup.js
31 lines (27 loc) · 921 Bytes
/
jest.setup.js
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
import 'jest-canvas-mock'; // Needed for compatibilty with react-confetti
import { TextEncoder, TextDecoder } from 'util';
// import jestFetchMock from 'jest-fetch-mock';
// jestFetchMock.enableMocks(); // Needed to test API routes
// Need for testing something in SearchPopularChip.test.tsx
Object.assign(global, { TextDecoder, TextEncoder });
Object.defineProperty(window, 'ResizeObserver', {
writable: true,
value: jest.fn().mockImplementation(() => ({
disconnect: jest.fn(),
observe: jest.fn(),
unobserve: jest.fn(),
})),
});
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation(query => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // Deprecated
removeListener: jest.fn(), // Deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
});