Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Testing React Components with Enzyme

No longer works with jsdom 10

It looks like jsdom 10 has changed the way it's initialised. While jsdom-global seems to be the way to go, I couldn't get it to work in this project.

As a workaround, replace your package.json with this one, which explicitly specifies jsdom 9: https://raw.githubusercontent.com/jesusalc/enzyme_append_app/master/package.json and remove your node_modules folder. Then run npm install and the tests should work.

Would be nice to know what the preferred method is to get things running with jsdom 10, but this should help people trying to run this now :)

Hey John,

I'm using jsdom v11.0.0 and jsdom-global v3.0.2 and everything worked perfectly.

Make sure you import 'jsdom-global/register' at the top of your test spec, and also make sure you don't create the runner file that Jared made (jsdom global eliminates the need for it).

You also need to keep mocha --compilers js:babel-register in your NPM script.

Hope this helps!