question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find module 'setupDevtools' from 'setup.js' when using haste configuration option

See original GitHub issue

🐛 Bug Report

When trying to run platform specific tests on a react-native project tests fail with Cannot find module ‘setupDevtools’ from ‘setup.js’ when configuring jest with the haste option.

package.json

{
  "name": "haste-test",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.6.3",
    "react-native": "0.57.8"
  },
  "devDependencies": {
    "@babel/core": "7.2.0",
    "babel-core": "babel-core@^6.0.0 || ^7.0.0-0",
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.48.5",
    "react-test-renderer": "16.6.3"
  },
  "jest": {
    "preset": "react-native",
    "transformIgnorePatterns": [
      "node_modules/(?!(react-native)/)"
    ],
    "haste": {
      "defaultPlatform": "android",
      "platforms": [
        "android",
        "ios"
      ],
      "providesModuleNodeModules": [
        "react",
        "react-native"
      ]
    }
  }
}

To Reproduce

  1. pull repo: https://github.com/androidian/haste-test
  2. yarn install
  3. yarn test
FAIL  __tests__/tests.js
  ● Test suite failed to run

    Cannot find module 'setupDevtools' from 'setup.js'

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:221:17)
      at Object.<anonymous> (node_modules/react-native/jest/setup.js:3:6)
  1. Remove “haste” from jest configuration
"jest": {
    "preset": "react-native",
    "transformIgnorePatterns": [
      "node_modules/(?!(react-native)/)"
    ]
  }
  1. yarn test
 PASS  __tests__/tests.js
  ✓ renders correctly (2303ms)

Expected behavior

Expect the tests to pass so tests can be run for multiple platforms

Link to repo

https://github.com/androidian/haste-test

#System Info

  System:
    OS: macOS High Sierra 10.13.6
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
  Binaries:
    Node: 9.8.0 - /usr/local/bin/node
    Yarn: 1.12.3 - ~/.yarn/bin/yarn
    npm: 5.6.0 - /usr/local/bin/npm
  npmPackages:
    jest: 23.6.0 => 23.6.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:11

github_iconTop GitHub Comments

7reactions
grit96commented, Feb 1, 2019

I have also experienced this after upgrading to jest 24.0.0 with react-native 0.55.4. Staying on jest 23.6.0 prevents the issue.

4reactions
sibeliuscommented, Jun 24, 2019

how can I solve this in a yarn workspace environment?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest Cannot find module 'setupDevtools' from 'setup.js'
I started anew today and solved my own problem. As it turns out, Babel has documentation which specifically explains how to setup Jest....
Read more >
cannot find module 'jest-config' - You.com | The AI Search ...
I just updated the moduleDirectories field in jest.config.js . Before. moduleDirectories: ['node_modules'].
Read more >
How to move jest tests to a /test folder and get them to run
Cannot find module 'setupDevtools' from 'setup.js' at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:151:17) at Object.
Read more >
Fix Global Installs Not Working | "Cannot find module" error FIX
Getting " Cannot find module " after installing something globally ( with -g)? Well, this video shows you how to fix global package/...
Read more >
Solved: Cannot find module react : npm install - YouTube
start Windows PowerShell and use npm install. ... Your browser can't play this video. ... Solved: Cannot find module react : npm install....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found