-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
fix(@jest/resolve): Include stringifiedOptions in getModuleIDAsync #12766
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, good catch! would you be able to add a test as well?
(and a changelog entry)
There are other slight differences between
getModuleID
andgetModuleIDAsync
that might lead to similar issues.
We should fix those. Is it possible to extract some utils to keep it DRY?
Sure, I'll make an attempt 👍
I can look into it 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic, thanks!
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
I use native ESM with the
--experimental-vm-modules
flag. When upgrading to Jest 28,jest.unstable_mockModule
stopped working:I tracked this down to the mock detection failing due to
getModuleID
andgetModuleIDAsync
not generating identical IDs. In this casegetModuleIDAsync
did not append the stringified options, so the lookup using the ID as a key failed.There are other slight differences between
getModuleID
andgetModuleIDAsync
that might lead to similar issues.Test plan
jest.unstable_mockModule
followed by a dynamic import should resolve the mocked module