forked from storybookjs/storybook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.init.js
30 lines (21 loc) · 872 Bytes
/
jest.init.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
import 'jest-enzyme/lib/index';
// setup file
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import * as emotion from 'emotion';
import { createSerializer } from 'jest-emotion';
import registerRequireContextHook from 'babel-plugin-require-context-hook/register';
registerRequireContextHook();
expect.addSnapshotSerializer(createSerializer(emotion));
// mock console.info calls for cleaner test execution
global.console.info = jest.fn().mockImplementation(() => {});
configure({ adapter: new Adapter() });
/* Fail tests on PropType warnings
This allows us to throw an error in tests environments when there are prop-type warnings. This should keep the tests
free of warnings going forward.
*/
const throwError = message => {
throw new Error(message);
};
global.console.error = throwError;
global.console.warn = throwError;