forked from FuelLabs/swayswap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.ts
31 lines (28 loc) · 899 Bytes
/
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
import failOnConsole from 'jest-fail-on-console';
const { getComputedStyle } = window;
window.getComputedStyle = (elt) => getComputedStyle(elt);
if (typeof window.matchMedia !== 'function') {
Object.defineProperty(window, 'matchMedia', {
enumerable: true,
configurable: true,
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(),
})),
});
}
failOnConsole({
silenceMessage: (msg, method) => {
if (msg.includes('toHexString')) return true;
if (msg.includes('ReactDOM.render is no longer supported in React 18')) return true;
if (method === 'warn') return true;
return false;
},
});