Skip to content

fix(jest-matcher-utils): compare value of inherited getter on test failure (#10167) - #14007

Merged
SimenB merged 3 commits into
jestjs:mainfrom
BenceSzalai:fix-getter4private
Mar 20, 2023
Merged

SimenB merged 3 commits into
jestjs:mainfrom
BenceSzalai:fix-getter4private

Conversation

@BenceSzalai

@BenceSzalai BenceSzalai commented Mar 14, 2023

Copy link
Copy Markdown
Contributor

Summary

Inherited getters were not enumerated by deepCyclicCopyObject causing getters not being replaced with value and the test code to call those getters later on the copied object. If the non-replaced getter depended on other non-copied value, e.g. a private class field the calling code could end up in error while trying to show comparison of the expected and received value on test failures.
Fixes #10167

See more detailed analysis under the issue: #10167 (comment)

Test plan

Added a new test case 'copies value of inherited getters' which is failing without the fix but passes after.

@SimenB SimenB left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, this LGTM 👍

could you fix the linting error?

@BenceSzalai

Copy link
Copy Markdown
Contributor Author

Sorry, missed that one. Hope it'll pass this time.

@SimenB
SimenB merged commit 04f11d8 into jestjs:main Mar 20, 2023
@github-actions

Copy link
Copy Markdown

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 20, 2023
@SimenB

SimenB commented Jul 4, 2023

Copy link
Copy Markdown
Member

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

toEqual throws a TypeError when using getter to private field of class

3 participants