generated from wednesday-solutions/react-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.setup.js
51 lines (49 loc) · 1.09 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
49
50
51
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',
location: {
pathname: '/',
search: '',
hash: ''
}
})
};
});
Object.defineProperty(window, 'matchMedia', {
value: jest.fn(() => {
return {
matches: true,
addListener: jest.fn(),
removeListener: jest.fn()
};
})
});
Object.defineProperty(window.HTMLMediaElement.prototype, 'paused', {
writable: true,
value: true
});
window.HTMLMediaElement.prototype.load = () => {
/* do nothing */
};
window.HTMLMediaElement.prototype.play = () => {
/* do nothing */
};
window.HTMLMediaElement.prototype.pause = () => {
/* do nothing */
};
window.HTMLMediaElement.prototype.addTextTrack = () => {
/* do nothing */
};