forked from bigcommerce/checkout-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest-setup.ts
46 lines (39 loc) · 1.1 KB
/
jest-setup.ts
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import '@testing-library/jest-dom';
import '@testing-library/jest-dom/extend-expect';
import { configure as configureRTL } from '@testing-library/react';
import * as Adapter from '@wojtekmaj/enzyme-adapter-react-17';
import { configure } from 'enzyme';
import { noop } from 'lodash';
const adapter = Adapter as any;
configure({ adapter: new adapter.default() });
configureRTL({ testIdAttribute: 'data-test' });
// https://github.com/facebook/jest/issues/10784
process.on('unhandledRejection', (reason) => {
console.log(reason);
});
window.matchMedia = jest.fn(
() =>
({
matches: false,
addListener: noop,
addEventListener: noop,
removeListener: noop,
removeEventListener: noop,
} as MediaQueryList),
);
Object.defineProperty(
window.navigator,
'userAgent',
((value) => ({
get() {
return value;
},
set(v) {
value = v;
},
}))(window.navigator.userAgent),
);
(global as any).__webpack_public_path__ = undefined;
beforeAll(() => {
expect.hasAssertions();
});