-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.setup.js
41 lines (38 loc) · 937 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
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
const {
JSDOM
} = require('jsdom');
Enzyme.configure({
adapter: new Adapter()
});
Object.defineProperty(global, 'Node', {
value: {
firstElementChild: 'firstElementChild'
}
})
const jsdom = new JSDOM('<!doctype html><html><body><div id="app"></div></body></html>', {
url: "http://localhost"
});
const {
window
} = jsdom;
function copyProps(src, target) {
Object.defineProperties(target, {
...Object.getOwnPropertyDescriptors(src),
...Object.getOwnPropertyDescriptors(target),
});
}
global.window = window;
global.document = window.document;
global.navigator = {
userAgent: 'node.js',
};
global.requestAnimationFrame = function (callback) {
return setTimeout(callback, 0);
};
global.cancelAnimationFrame = function (id) {
clearTimeout(id);
};
copyProps(window, global);
jest.setTimeout(10000)