-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathjestSetup.js
More file actions
27 lines (21 loc) · 738 Bytes
/
jestSetup.js
File metadata and controls
27 lines (21 loc) · 738 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
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
configure({
adapter: new Adapter()
});
// Auto-mock YellowBox component.
jest.mock("YellowBox");
const mockConsoleMethod = (realConsoleMethod) => {
const ignoredMessages = [
"test was not wrapped in act(...)"
];
return (message, ...args) => {
const containsIgnoredMessage = ignoredMessages.some((ignoredMessage) => message.includes(ignoredMessage));
if (!containsIgnoredMessage) {
realConsoleMethod(message, ...args);
}
};
};
// Suppress console errors and warnings to avoid polluting output in tests.
console.warn = jest.fn(mockConsoleMethod(console.warn));
console.error = jest.fn(mockConsoleMethod(console.error));