mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-17 05:02:23 +08:00
35 lines
892 B
JavaScript
35 lines
892 B
JavaScript
import 'jest-enzyme/lib/index';
|
|
|
|
// setup file
|
|
import { configure } from 'enzyme';
|
|
import Adapter from 'enzyme-adapter-react-16';
|
|
|
|
import registerRequireContextHook from 'babel-plugin-require-context-hook/register';
|
|
|
|
registerRequireContextHook();
|
|
|
|
// mock console.info calls for cleaner test execution
|
|
global.console.info = jest.fn().mockImplementation(() => {});
|
|
|
|
// mock local storage calls
|
|
const localStorageMock = {
|
|
getItem: jest.fn(),
|
|
setItem: jest.fn(),
|
|
clear: jest.fn(),
|
|
};
|
|
global.localStorage = localStorageMock;
|
|
|
|
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;
|