Created
May 8, 2017 17:37
-
-
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.`
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
// 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 |
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
//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