UNPKG

755 BJavaScriptView Raw
1require( '@wordpress/jest-console' );
2
3// It "mocks" enzyme, so that we can delay loading of
4// the utility functions until enzyme is imported in tests.
5// Props to @gdborton for sharing this technique in his article:
6// https://medium.com/airbnb-engineering/unlocking-test-performance-migrating-from-mocha-to-jest-2796c508ec50.
7let mockEnzymeSetup = false;
8
9jest.mock( 'enzyme', () => {
10 const actualEnzyme = require.requireActual( 'enzyme' );
11 if ( ! mockEnzymeSetup ) {
12 mockEnzymeSetup = true;
13
14 // configure enzyme 3 for React, from docs: http://airbnb.io/enzyme/docs/installation/index.html
15 const Adapter = require.requireActual( 'enzyme-adapter-react-16' );
16 actualEnzyme.configure( { adapter: new Adapter() } );
17 }
18 return actualEnzyme;
19} );