-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
After updating @aws-amplify/auth to latest version(1.5.0) test cases is failing because of failed to mock Auth module. #4499
Comments
@anis-shaikh Thanks for bringing this to your attention, and your clear steps to reproduce 👏! I was able to reproduce this here:
It looks like the regression was introduced in #4007 and the bump either in 233dd1c or c0fa439. We'll need to investigate the difference in what's being installed so that Jest is able to mock it successfully...
|
For an easy way to compare the differences between what's published, I've been using: |
For comparison, Related, |
@Amplifiyer I'd appreciate some additional 👀 on this ☝️ |
There are consistent threads regarding Jest & mocking failing due to "meta-programming": As best I can tell, it's due to the dynamic Still researching the solution to this... |
I was having the same issue with After looking at @ericclemmons comparisons it seems I was able to fix this issue by using
instead of
This is how I mocked in my test
|
Did you find a fix for this? Tried the above workaround on a similar problem but to no avail. |
@anywhereiromy I tried by above solution and it works for me but for that I need to replace all the import statement to " import API from '@aws-amplify/api/lib' ". So I found another solution and that is by manually mocking Auth module.
|
@anis-shaikh @anywhereiromy @ifielder We have just merged in the fix. Can you please try with aws-amplify@unstable version and let us know if the issue is resolved for you? |
This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems. |
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
After updating @aws-amplify/auth to latest version(1.5.0) test cases is failing because of failed to mock Auth module.
Steps to reproduce the behavior:
Import Auth API by
import Auth from '@aws-amplify/auth';
mock it by jest
jest.mock('@aws-amplify/auth');
See error
Failed to get mock metadata: /Users/an***/Documents/s***/node_modules/@aws-amplify/auth/index.js
` Test suite failed to run
The text was updated successfully, but these errors were encountered: