Skip to content

Instantly share code, notes, and snippets.

@anomaly44
Created August 16, 2017 08:57
Show Gist options
  • Save anomaly44/a360cd76cb7cfdbc20e7483450daa892 to your computer and use it in GitHub Desktop.
Save anomaly44/a360cd76cb7cfdbc20e7483450daa892 to your computer and use it in GitHub Desktop.
require('babel-register')();
const jsdom = require('jsdom');
const { JSDOM } = jsdom;
const exposedProperties = ['window', 'navigator', 'document'];
const { document } = (new JSDOM('')).window;
global.document = document;
global.window = document.defaultView;
Object.keys(document.defaultView).forEach((property) => {
if (typeof global[property] === 'undefined') {
exposedProperties.push(property);
global[property] = document.defaultView[property];
}
});
global.navigator = {
userAgent: 'node.js'
};
documentRef = document;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment