-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetupTests.js
43 lines (35 loc) · 1.11 KB
/
setupTests.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
31
32
33
34
35
36
37
38
39
40
41
42
43
// optional: configure or set up a testing framework before each test
// if you delete this file, remove `setupFilesAfterEnv` from `jest.config.js`
// used for __tests__/testing-library.js
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom/extend-expect';
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });
window.matchMedia =
window.matchMedia ||
function () {
return {
matches: false,
onchange: null,
addListener: function () {},
removeListener: function () {},
};
};
jest.mock('@bugsnag/js');
jest.mock('next/config', () =>
jest.fn().mockReturnValue({
serverRuntimeConfig: {},
publicRuntimeConfig: {},
}),
);
jest.mock('react-i18next', () => ({
// this mock makes sure any components using the translate HoC receive the t function as a prop
withTranslation: () => (Component) => {
Component.defaultProps = { ...Component.defaultProps, t: (key) => key };
return Component;
},
}));
jest.mock('next/dynamic', () => {
return jest.fn(() => 'Dynamic');
});