-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot find module 'setupDevtools' from 'setup.js' in react-native/jest/setup.js version 0.56.0 #20460
Comments
This is even reproducable when using react-native init sampleproject
cd sampleproject
react-native eject Creating the file import React from 'react';
import App from './App';
import renderer from 'react-test-renderer';
it('renders without crashing', () => {
const rendered = renderer.create(<App />).toJSON();
expect(rendered).toMatchSnapshot();
}); Running
Even the provided hints/workarounds from #19859 (comment) did not work for me. This makes me not being able to use react-native 0.56 at all! EDIT: the same code works flawless on latest MacOS (High Sierra) and on latest Debian Stretch. This seems to be a platform-specific bug !!! |
@davidpricedev can you confirm, that your project works on MacOS (without the transform-modification), but always fails on Windows ? Did you try any Linux-system? I assume there is a path-bug where backslashes are used wrong while sanitizing, I'm now searching for such things. EDIT: did not found anything .... maybe this is a bug in |
My project works as-is on a macos (without removing the transform section). Adding the roots/rootDir sections doesn't seem to matter for the mac. |
We are seeing the exact same issue after upgrading from 0.55.4 to 0.56.0
|
Looks to me like a duplicate of #19859 |
@kelset might be, but it is very strange that this issue is only on Windows systems, but working on MacOS/Linux. The other issue was happening on MacOS so it seemed to be a different bug. |
Have you tried following my last comment in that issue and test again? Related to it being Windows only we are still fixing/releasing commits related to Windows miss-behaviours so could also be related to that. |
@kelset yes, tried the last comment of that issue, did not work (and the author of this issue seems to have this done too). Can you link these other windows-specific issues/pull-requests here? Would help making this more visually present. |
To address the various suggestions in that last comment of #19859 :
|
I tried all the suggestions above and nothing seems to work.
Update: regardless even with the |
hey folks, thanks for the feedback:
|
@kelset thanks for the linked issue, looking forward to check my project against 0.57RC Having unchanged Any short conclusion what the main culprit was? |
Uhm I'm confused now:
I'm not sure it's related to why for you it's working now, but master basically now resolves correctly the Windows' path's format while bundling. |
@kelset oh sorry, yes, forgot mentioning that version-changing inside the The |
Uhm ok I'm still confused, why did you run And
I guess I phrased my last comment wrongly, but the "why" = "the main culprit" = "master basically now resolves correctly the Windows' path's format while bundling" ( = "before master on windows was having issue with path resolving"). Does this make more sense? 🤔 |
That |
Was your project created via |
@kelset I am running on a mac, there is still an issue with RN 0.56 babel 7 configuration and jest where jest ignores the |
@shyaniv7 this thread is about Windows :) maybe the current master-branch is working out for you too? |
@FibreFoX my bad I subscribed to all the threads with this error message from jest. I will test master but unfortunately we cannot go to production with an RC version and 0.56 fixed a major memory leak issue on android for us, so now we are stuck waiting |
I don't think this is a Windows-specific issue, I'm getting the same error under Linux. I also use jest-expo. |
@dolsem This worked on Linux and MacOS, therefor this indeed is/was windows-specific, as this seems to work with current master-branch, we just have to wait for the |
@dolsem are I explained above, using @shyaniv7 I understand your feeling about
but remember that you can always fork and cherry pick commits that may fix it for you. Overall, we are not releasing a new 0.57 rc because we are stuck trying to fix an issue - you can follow along here. |
I can confirm the master branch of react-native has the issue resolved. I've also narrowed down the exact commit that fixed things - namely 3ac86c3. Lately, I've been using patch-package to patch things that need fixing - especially when the fixes are small and patches are easy to comprehend. You can see that patch in action in the latest commit in my repro repo. |
failing for me on windows, using the latest everything (node 10.12, babel 7, RN 0.57.4, jest 23.6, on windows 10 64 bits), funny thing is that only jest tests fail, the code itself work inside the android emulator 😕 |
Any update to this issue? |
I noticed that I'm getting this error when using a "cacheDirectory" parameter with "transform" into jest config. {
"name": "testApp",
"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-jest": "23.6.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.51.1",
"react-test-renderer": "16.6.3"
},
"jest": {
"preset": "react-native",
"transform": { "^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js" },
"cacheDirectory": "<rootDir>/coverage/main/cache"
}
}
|
For me the issue was watchman -- running the tests with the --no-watchman flag worked. In my case, .watchmanconfig was ignoring node_modules |
I tried with different version of react native but not able to resolve this issue. It is not a Jest issue . It is related to react-native. Please help if anyone have a solution. I am getting same issue in react-native version 0.55.4 also. |
I am too getting the same error. My setup is with TypeScript, but I don't think it affects this. And I haven't been able to find a working solution online. Any help would be much appreciated. |
i am too getting the same error with versions : Error Details:
|
I was able to resolve it with: |
If you see this issue it's due to this line in the react-native jest setup file: jest.mock('setupDevtools'); The error is because for some reason Jest cannot see the To fix you can run @lyoss's command to reset all the caches |
FYI if you are working with a |
FYI here we fixed this issues in a monorepo and no hoisting with that kind of config for // packages/app/jest.config.js
const path = require('path')
module.exports = {
rootDir: path.join(__dirname, '../..'),
preset: "react-native",
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
transformIgnorePatterns: ["node_modules/(?!static-container)/"],
setupFiles: ["./node_modules/react-native-gesture-handler/jestSetup.js"],
testMatch: ["**/packages/app/__tests__/*-test.tsx"]
}; working with:
|
Several bugfixes were needed, and I managed to get the tests running:
|
Environment
node version 8.11.3 (and other windows systems have older yarn and node versions)
Description
Since upgrading to react-native 0.56.0, I can no longer run tests on windows. Every test file fails with the error below
Jest Config
I think everything below the `setupFiles` was stuff I added that made no effective difference.Package.json
What I've already tried
Things that affect the error:
If I remove the
transform
section of the jest config then the setup.js error goes away, but the "Plugin 0" error occurs (on macOs too):If I add the following to my jest config, the error changes to the error below
Reproducible Demo
See: this repo for a reproducible (on windows only) example.
The text was updated successfully, but these errors were encountered: