-
Notifications
You must be signed in to change notification settings - Fork 92
/
jest.setup.js
48 lines (44 loc) · 1.05 KB
/
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
45
46
47
48
import '@testing-library/jest-dom';
import { enableMocks } from 'jest-fetch-mock';
// jest.setup.js
enableMocks();
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)
}));