-
-
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: mocking of getters/setters on automatically mocked classes #13460
Conversation
…ed classes (jestjs#13145)"" This reverts commit 52d45be. # Conflicts: # CHANGELOG.md
… 'get'/'set' functions being mocked as accessor objects. Added extra tests for this, and for some other conditions. Corrected expected test error messages due to the refactored code for the fix to this bug.
Co-authored-by: Tom Mrazauskas <tom@mrazauskas.de>
# Conflicts: # CHANGELOG.md
…e currently only test for functions exported as data properties, not as accessors/getters
…unctions exported as accessors/getters
…restoring of accessor properties. Test for function exports via getters.
I added a test for module exports that are imported via getters, based upon @SimenB code.
The test,'can mock a function export', is here. The restoring of the original property fails and is not tested. Can anyone tell me how to make this a valid test? |
@mrazauskas any idea? Did it work before? If not it shouldn't block |
Looks complicated. Maybe |
Are this new changes/tests also covering #13466 ? |
Should add a test for it at least |
I need to make a release for Node 19 today btw, so I might have to revert (again 😅) |
I reverted the original PR in #13472 (but kept a bunch of tests). I'll merge in |
It was the defineProperty() during the restore that resulted in the property being undefined. Not sure why as the defineProperty() during the test worked. |
@SimenB I've reapplied the automatic mocking tests that were removed, and reapplied the original spyOn method structures. Apologies again for the hassle caused. |
The dispatchEvent bug #13466 was caused by the That being said the original code In the test below, in my version of It seems there are edge cases for either implementation so detecting both may be necessary at some point. As use of property descriptors seems to cause more real-world hassle I'll stick with the original code for now. It would be nice to know why these anomalies occur, if anyone has the knowledge.
|
Thanks! And don't worry about the regressions too much - reverting is easy enough 🙂 The real issue is our tests not covering the super valid use cases people have, not your changes breaking them 👍 |
@SimenB thanks, the comment is appreciated. |
This PR is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
This PR was closed because it has been stalled for 30 days with no activity. Please open a new PR if the issue is still relevant, linking to this one. |
This PR was closed because it has been stalled for 30 days with no activity. Please open a new PR if the issue is still relevant, linking to this one. |
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. |
This is a new pull request to complete #13398.