enzymejs/chai-enzyme

Setup with jsdom and chai-enzyme

NicolasSiver opened this issue · 2 comments

Hello.

I'm trying to add chai-enzyme. When I add import ChaiEnzyme from 'chai-enzyme' several tests are failing with an error:

Invariant Violation: dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a worker thread. Make sure `window` and `document` are available globally before requiring React when unit testing or use ReactDOMServer.renderToString() for server rendering.

I was able to fix it, by making sure that chai-enzyme imported and initiated after jsdom.

I met same issue.

Hard for me to figure this out, since I have already cha-enzyme in my unittesting initialization code. With chai-enzyme imported before jsdom, React component cannot render different type of root element in re-render with the dangerouslyReplaceNodeWithMarkup error message.