Skip to content

Instantly share code, notes, and snippets.

@lmosele
Created May 8, 2017 17:37
Show Gist options
  • Save lmosele/0cc7df05be4379f8a6f42428eab4fcef to your computer and use it in GitHub Desktop.
Save lmosele/0cc7df05be4379f8a6f42428eab4fcef to your computer and use it in GitHub Desktop.
Solution to `It looks like you called `mount()` without a global document being loaded.`
// enzyme requires you to set up jsdom for rendering
var jsdom = require('jsdom').jsdom;
var exposedProperties = ['window', 'navigator', 'document'];
global.document = jsdom('');
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'
};
// any other stuff you may have in your runner file
//example only
--compilers ts-node/register
--check-leaks
--no-exit
--require babel-polyfill
--require ./mocha-runner
--recursive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment