Answers for "ReferenceError: You are trying to `import` a file after the Jest environment has been torn down."

0

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down.

Cearte a file mock.js on rootDir 

place this inside. file 

jest.useFakeTimers()


now under setup

"setupFiles": [
  "./node_modules/react-native-gesture-handler/jestSetup.js",
  "<rootDir>/mock.js"  //place here
],
  
  ================This is my file====================

"jest": {
    "preset": "react-native",
    "setupFilesAfterEnv": [
      "@testing-library/jest-native/extend-expect"
    ],
    "transformIgnorePatterns": [
     "node_modules/(?!(jest-)?@?react-native|@reactw-native-community|@react-navigation)"
    ],
    "setupFiles": [
      "./node_modules/react-native-gesture-handler/jestSetup.js",
      "<rootDir>/mock.js"
    ],
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx",
      "json",
      "node"
    ]
  },
Posted by: Guest on August-04-2021

Code answers related to "ReferenceError: You are trying to `import` a file after the Jest environment has been torn down."

Code answers related to "Javascript"

Browse Popular Code Answers by Language