dimanche 2 février 2020

Jest is unable to find module from test file

I have setup an app with create react app. When I run yarn test I get the following error: Cannot find module 'react-google-button' from 'App.tsx'. It seems to be caused by jest not finding react-google-button.

When running the app by yarn start it works as expected. Is the error caused by react-google-button library itself, or is it caused by wrong configuration? The error is thrown even when i try to mock the library.

I have created a repo where anyone can replicate the error: https://github.com/kaladivo/jest-error. (run yarn test).

Can someone help me solve this issue? I have no idea how to fix. I know one possible sollution would be not to use react-google-button library, but that still won't solve it happening in the future with maybe some more crucial library...

Aucun commentaire:

Enregistrer un commentaire