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
- pull repo: https://github.com/androidian/haste-test
- yarn install
- 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)
- Remove “haste” from jest configuration
"jest": {
"preset": "react-native",
"transformIgnorePatterns": [
"node_modules/(?!(react-native)/)"
]
}
- 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:
- Created 5 years ago
- Reactions:6
- Comments:11
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have also experienced this after upgrading to
jest 24.0.0
withreact-native 0.55.4
. Staying onjest 23.6.0
prevents the issue.how can I solve this in a yarn workspace environment?