Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jest in a React-Native project. How to Blacklist or delete duplicate modules?

I am trying to set up a React-Native project with lerna. When I try to run jest I face the following error.

   The name `setupDevtools` was looked up in the Haste module map. It cannot be resolved, because there exists several different files, or packages, that provide a module for that particular name and platform. The platform is generic (no extension). You must delete or blacklist files until there remains only one of these:

      * `/Users/kevin.amiranoff/project/node_modules/react-native/Libraries/Core/Devtools/setupDevtools.js` (module)
      * `/Users/kevin.amiranoff/project/packages/App/node_modules/react-native/Libraries/Core/Devtools/setupDevtools.js` (module)
      * `/Users/kevin.amiranoff/project/packages/App-exceptions/node_modules/react-native/Libraries/Core/Devtools/setupDevtools.js` (module)
      * `/Users/kevin.amiranoff/project/packages/App-signin/node_modules/react-native/Libraries/Core/Devtools/setupDevtools.js` (module)
      * `/Users/kevin.amiranoff/project/packages/App-ui/node_modules/react-native/Libraries/Core/Devtools/setupDevtools.js` (module)
      * `/Users/kevin.amiranoff/project/packages/App-utils/node_modules/react-native/Libraries/Core/Devtools/setupDevtools.js` (module)

Here is my jest config in my root package.json

"jest": {
    "preset": "react-native",
    "globals": {
      "__DEV__": true
    },
    "testRegex": "packages/(.*)/src/(.*)/__tests__/(.*).js?$",
    "transformIgnorePatterns": [
      "packages/(.*)/node_modules/?!(react|react-native)"
         ],
    "testEnvironment": "node"
  }

Can anyone explain to me what do I have to ignore and how?

like image 473
Kevin Amiranoff Avatar asked Oct 10 '17 10:10

Kevin Amiranoff


1 Answers

You should use the modulePathIgnorePatterns to ignore certain directories. Make sure that only the one you really want to use is not in this ignore list.

Link to documentation: https://facebook.github.io/jest/docs/en/configuration.html#modulepathignorepatterns-array-string

like image 110
Peuchele Avatar answered Oct 03 '22 18:10

Peuchele