React: ReferenceError: document is not defined var actContainerElement = document.createElement('div');

Created on 6 Feb 2019  路  3Comments  路  Source: facebook/react

React V 16.8

Im using jsdom and enzyme to unit test my lib. When i updated to V16.8 this morning I started getting the following. I think it has to do with the fact that test utils is a js IIFE, and the jsdom document object has not been created yet.

/Users/n0280500/Documents/Dev/ReactTools/informed/node_modules/react-dom/cjs/react-dom-test-utils.development.js:944
var actContainerElement = document.createElement('div');

ReferenceError: document is not defined

For more context: I have a setup file that gets executed before any of my enzyme tests as described by the docs https://airbnb.io/enzyme/docs/guides/jsdom.html

Duplicate

Most helpful comment

I think this will be fixed by #14768

All 3 comments

I think this will be fixed by #14768

That's right, this is a dupe of https://github.com/facebook/react/issues/14764. Closing this one. Sorry for the trouble!

Should be fixed by the latest 16.8.1 release

Was this page helpful?
0 / 5 - 0 ratings