-
-
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
[Bug]: createMockFromModule not mocking class correctly #14022
Comments
Just to add I've been seeing a similar issue. Using the package.json
However with:
Our failing tests call a function of an instance that has been mocked with While I'm not 100% familiar with how
Other than that I can't see how the other commits would make a difference here: https://github.com/facebook/jest/commits/main/packages/jest-mock |
That seems different and not related with this issue. See #13925 for details and possible solutions. |
Thanks @mrazauskas. I can confirm that when I made a new codebase to reproduce the issue, the fix suggested by @CreativeTechGuy in #13925 (comment) worked. Unfortunately for our main codebase this did not work, so something else is afoot. We will be looking further at this in time. For now we've pinned |
In your place I would try looking for Unfortunately |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
Since the previous comments seem to be related to another problem, can anyone help me with my problem mocking classes with createMockFromModule please? |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
still active, not stale |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
not stale! |
Duplicate of #14178 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Version
29.5.0
Steps to reproduce
Expected behavior
I expect the test cases to succeed.
Actual behavior
Tests are failing because jest.createMockFromModule only mocks constructor and functions for classes but no other properties (also no getters).
The example for jest.createMockFromModule does not mock an exported class but an instance of a class:
class: new (class Bar {...})()
Additional context
No response
Environment
The text was updated successfully, but these errors were encountered: