In my case I needed this specific test to run in node environment instead of jsdom. You can force a particular test to run in a different environment by putting this on top of the .spec file:
node
jsdom
.spec
/** * @jest-environment node */