I\'m trying to mount a component for testing with enzyme, and get this error.
npm install --save-dev --save-exact jsdom jsdom-global
Then:
import 'jsdom-global/register'; //at the top of file, even before importing React
More info here.
Alternative: In case you are using jest with enzyme-
In your package.json
, specify the test environment for jest as jsdom
as follows:
"jest": {
"testEnvironment": "jsdom"
}
I faced the same issue and it worked well for me.