I am trying to run my project’s tests on my CI/CD machines. They are jest tests that have been running fine for some time on all my environments. I am going through package updates, and somewhere along the way, I began having issues. I see that every test is failing because if this error:
● Test suite failed to run
Cannot find module '/cicduser/myproject/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/interopRequireDefault' from 'src/setupTests.ts'
1 | /*
2 | * Filename: setupTests.ts
> 3 | * Classification: UNCLASSIFIED
| ^
at Resolver.resolveModule (node_modules/jest-runtime/node_modules/jest-resolve/build/index.js:306:11)
at Object.<anonymous> (src/setupTests.ts:3:30)
This is happening on a Debian Ubuntu-16 linux instance, with node 14.16.3 and npm 8.1.0.
This is not happening my local machine. My local machine runs these tests just fine. My local is a mac Catalina 10.15.7, and I’ve tried versions of node 14 and 16, as well as npm 7 and 8, and no issues. I did read Unable to resolve module @babel/runtime/helpers/interopRequireDefault
, as well as a number of other related questions, but no solution is helping. I have tried
npm install @babel/runtime
npm install babel-preset-react-app
- adding
"nohoist": ["**/babel-preset-react-app/@babel/runtime"]
to package.json - uninstalling and reinstalling all packages a few times over with various variations of this
Its a little befuddling that the tests work fine on my laptop, with all variations of what I’ve tried above, and fail on my CI/CD instance, with all variations of what Ive tried above.
What can I do to debug this? Why would this issue persist, despite trying the best answers and suggestions as described above?
3
Answers
I was having the same issue but opposite: it would work on my Azure pipeline but fail locally. I got all tests to run successfully in both environments after running this:
Based on this issue: https://github.com/facebook/create-react-app/issues/6398#issuecomment-462475835
The user ( jeremyckahn ) who posted it said this:
The same was happening to me and downgrading to
[email protected]
fixed it, per the same suggestion above.Try to clear jest cache
or