-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add the required "default" export mocking caveat to Jest migration guide. #1763
Comments
This should be able to be closed as part of this PR? I guess I didn't update any documentation with that fix, do you want an update in either of the documents linked in this issue @sheremet-va ? |
Sure, let's update documentation. |
Also, I think I found a potential bug there: It's not forbidden to export |
Or maybe just |
Fixed #1830 |
Clear and concise description of the problem
It took me a while to realise that I needed to explicitly mock default module exports in vitest. Since this is a rather big change from the way we mock modules in jest, I think it's worth to mention this in the Jest migration guide.
This is well documented in https://vitest.dev/api/#vi-mock, but is easy to miss as it's not a part of the general mocking guide.
Suggested solution
Add a quick note about default export mocking in https://vitest.dev/guide/migration.html#migrating-from-jest. I think this will help people alot.
Alternative
Provide better error messages when people accidentally mock named exports with
vi.mock
. For examplecannot read property 'get' of undefined, did you intend to mock the "default" export? See https://vitest.dev/api/#vi-mock for details.
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: