Skip to content Skip to sidebar Skip to footer

Referenceerror: You Are Trying To `import` A File After The Jest Environment Has Been Torn Down: At Loadcjsdefault

I am testing building a bundle with rollup using jest which throws error whenever i use async/await. I have no idea what's wrong. I tried different soultions and it's not working.

Solution 1:

Add "testEnvironment": "jsdom" into jest key in package.json

"jest": {
  "testEnvironment": "jsdom",
  "preset": "react-native",
  ...

Solution 2:

In jest.config.js change testEnvironment to testEnvironment: "jsdom" and it should work fine.

PS: Thanks to this answer in Github issue.

Post a Comment for "Referenceerror: You Are Trying To `import` A File After The Jest Environment Has Been Torn Down: At Loadcjsdefault"