forked from wednesday-solutions/react-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.setup.js
44 lines (41 loc) · 999 Bytes
/
jest.setup.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
44
import '@testing-library/jest-dom';
jest.mock('react-router-dom', () => {
const originalModule = jest.requireActual('react-router-dom');
return {
__esModule: true,
...originalModule,
useLocation: jest.fn().mockReturnValue({
pathname: '/',
search: '',
hash: '',
state: null,
key: '5nvxpbdafa'
}),
useHistory: jest.fn().mockReturnValue({
length: 2,
action: 'POP',
push: jest.fn(),
location: {
pathname: '/',
search: '',
hash: ''
}
})
};
});
Object.defineProperty(window, 'matchMedia', {
value: jest.fn(() => {
return {
matches: true,
addListener: jest.fn(),
removeListener: jest.fn()
};
})
});
jest.mock('redux-persist/integration/react', () => ({
PersistGate: (props) => props.children
}));
jest.mock('redux-persist', () => ({
...jest.requireActual('redux-persist'),
persistReducer: jest.fn().mockImplementation((config, reducer) => reducer)
}));