Skip to content

Instantly share code, notes, and snippets.

@doque
Created November 20, 2016 16:21
Show Gist options
  • Save doque/c43f305ae7140b51fb7e667c71d98d89 to your computer and use it in GitHub Desktop.
Save doque/c43f305ae7140b51fb7e667c71d98d89 to your computer and use it in GitHub Desktop.
require('babel-register');
require('mock-css-modules');
const jsdom = require('jsdom').jsdom;
// Set up dummy DOM and provide `window` and `document.`
global.document = jsdom('<!doctype html><html><body></body></html>');
global.window = document.defaultView;
const exposedProperties = ['window', 'navigator', 'document'];
Object.keys(document.defaultView).forEach((property) => {
if (typeof global[property] === 'undefined') {
exposedProperties.push(property);
global[property] = document.defaultView[property];
}
});
// Set variables and cookies here
global.navigator = {
userAgent: 'node.js',
plugins: []
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment