-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
32 lines (26 loc) · 866 Bytes
/
jest.setup.js
File metadata and controls
32 lines (26 loc) · 866 Bytes
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
import registerRequireContextHook from 'babel-plugin-require-context-hook/register';
import '@babel/polyfill';
import {configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
registerRequireContextHook();
configure({adapter: new Adapter()});
jest.spyOn(global.console, 'log').mockImplementation(() => jest.fn());
const {error} = console;
console.error = (message, ...args) => {
if (/(Invalid prop|Failed prop type)/gi.test(message)) {
throw new Error(message);
}
error.apply(console, [message, ...args]);
};
window.matchMedia = jest.fn().mockImplementation((query) => {
return {
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // deprecated
removeListener: jest.fn(), // deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn()
};
});