-
-
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: toMatchObject works with super getters #10381
fix: toMatchObject works with super getters #10381
Conversation
<d>expect(</><r>received</><d>).</>not<d>.</>toMatchObject<d>(</><g>expected</><d>)</> | ||
|
||
Expected: not <g>{"a": undefined, "b": "b", "c": "c"}</> | ||
Received: <r>{}</> |
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.
question: You'll notice that we don't include these non-enumerable keys in the error reporting. I have some ideas on how we can improve this, but fixing this will be quite involved. Is this acceptable for now? Can we handle improving this in a follow-up? 🤔
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.
a follow-up on this would be great, but we definitely don't have to handle it at the same time 👍
@sstern6 could you take a look at this PR we paired on? I still need to add the CHANGELOG 👀 |
9572967
to
1b3ddba
Compare
LGTM! |
1b3ddba
to
3a88c29
Compare
- It also works with `defineProperty` - There's still a bit of work to be done on improving the reporting of this
This way we can catch the actual props of the object without catching those in Object.prototype
3a88c29
to
1dde15b
Compare
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.
Thanks, this looks great!
@jeysal @thymikee @pedrottimark would any of you be able to look over this? |
Not super familiar with this code, but (mostly based on tests) LGTM |
Oh sorry @sstern6, I forgot to add the co-author tag to the commit 😞 |
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
@sstern6 and I worked on this PR to fix #10268, where
toMatchObject
would not work for getters defined in a super class. It does this by using the in operator as opposed to the previoushasOwnProperty
checks.Test plan
The newly added spec fails on
master
And these specs pass on this branch, implying a 🐛 fix 😄