-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
jsdom-setup.js
25 lines (20 loc) · 748 Bytes
/
jsdom-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
/* eslint-disable import/no-extraneous-dependencies */
// https://stackoverflow.com/questions/41194264/mocha-react-navigator-is-not-defined
const { JSDOM } = require('jsdom');
const jsdom = new JSDOM('<!doctype html><html><body></body></html>');
const { window } = jsdom;
// function copyProps(src, target) {
// const props = Object.getOwnPropertyNames(src)
// .filter(prop => typeof target[prop] === 'undefined')
// .reduce((result, prop) => ({
// ...result,
// [prop]: Object.getOwnPropertyDescriptor(src, prop),
// }), {});
// Object.defineProperties(target, props);
// }
global.window = window;
global.document = window.document;
global.navigator = {
userAgent: 'node.js',
};
require('raf').polyfill(global);