All files / tests setup.js

100% Statements 9/9
100% Branches 0/0
100% Functions 3/3
100% Lines 9/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22    1x       1x 212x 195x 1x     1x 1x 1x   1x          
 
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')
    .map(prop => Object.getOwnPropertyDescriptor(src, prop));
  Object.defineProperties(target, props);
}
 
global.window = window;
global.document = window.document;
copyProps(window, global);
 
global.navigator = {
  appName: 'other',
  userAgent: 'node.js',
  platform: 'node.js',
};