-
Notifications
You must be signed in to change notification settings - Fork 60
/
jest.setup.js
59 lines (49 loc) · 1.28 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
52
53
54
55
56
57
58
59
/* eslint-disable no-undef */
import '@testing-library/jest-dom/extend-expect';
import React from 'react';
jest.mock('dns');
jest.mock('electron');
jest.mock('electron-ga');
jest.mock('request-promise');
// TODO - avoid mocking this
jest.mock('react-apexcharts', () => {
return jest.fn(() => <span>ReactApexChart</span>);
});
require('jest-fetch-mock').enableMocks();
window.scrollTo = () => {};
window.matchMedia = jest.fn().mockImplementation(query => {
return {
matches: true,
media: query,
onchange: null,
addListener: jest.fn(), // deprecated
removeListener: jest.fn(), // deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn()
};
});
jest.mock('popper.js', () => {
const PopperJS = jest.requireActual('popper.js');
return class {
static placements = PopperJS.placements;
constructor() {
return {
destroy: jest.fn(),
scheduleUpdate: jest.fn(),
update: jest.fn()
};
}
};
});
global.window.document.createRange = function createRange() {
return {
setEnd: () => {},
setStart: () => {},
getBoundingClientRect: () => {
return { right: 0 };
},
getClientRects: () => [],
commonAncestorContainer: document.createElement('div')
};
};