Created
August 16, 2017 08:57
-
-
Save anomaly44/a360cd76cb7cfdbc20e7483450daa892 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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