How to solve Jest storybook test error “cannot find interopRequireDefault.js”

https://www.agirl.codes/storybook-test-error-cannot-find-interopRequireDefaultjs

What caused this error?

I wanted to update my current branch with the master branch. In the process, I encountered a merge conflict with the storybook snapshot test. The incoming test file had been updated with new tests. I accepted both changes without duly reviewing them and that must have caused some data to be repeated or redundant. hhhhh

What I tried to fix the issue?

Usually, when I get errors like this that have a package can’t be found error, I delete and re-install node_modules, package-lock.json. In this case, It did not help

What Solved the Error?

Deleting the Jest cache directory. I added this command to my package.json and ran it.

“test”: “react-scripts test — clearcache”
https://www.agirl.codes/storybook-test-error-cannot-find-interopRequireDefaultjs

Conclusion

Jest stores information in the cache to improve test performance, I suspect the merge with new data must have clashed with the cache data, thereby confusing Jest.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store