This is an error that I've seen plague several projects when using the Jest Test runner in WebStorm. I have found two working resolutions to this. You can either.
import jsdom from 'jsdom';
const doc = jsdom.jsdom('<!doctype html>test');
global.document = doc;
global.window = doc.defaultView;
Either way the error should now be gone when you run your tests.
Copyright © 2020 | Ben Hutton