-
-
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(snapshot): bring back support for array property matchers #14025
fix(snapshot): bring back support for array property matchers #14025
Conversation
Hi @bakasmarius! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Unfortunately the error is hard to understand: "Asymmetric matcher Object does not implement toAsymmetricMatcher()"
A user was reporting an error, which was hard to understand. The fix was not about one or another use case. |
Does this mean my PR won't be approved unless it also makes the error mentioned in #13134 more clear? |
I added some changes (test cases included) that fix #13134 - it doesn't throw any error anymore, because These cases (and combinations of them) now also work:
|
As long as the error is specific, I think that's fine. EDIT: hah, just noticed your latest comment 😅 |
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.
Great job!
Looks like this patch makes .toMatchSnapshot()
matcher work the same as .toMatchObject()
does. I checked out the branch and did some manual testing. Just wanted to compare the behaviour and to try out few edge cases. All went smooth.
One detail – the PR is missing change log entry. It could sound "feat(jest-snapshot): support array inputs to .toMatchSnapshot()
matcher" or so.
Co-authored-by: Tom Mrazauskas <[email protected]>
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!
…#14025) Co-authored-by: Tom Mrazauskas <[email protected]> Co-authored-by: Marius Bakas <[email protected]>
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
Fixes #13352 which is a regression that happened when #13263 fixed #13134.
Technically, this will now throw an error again on the case mentioned in #13134:
expect([{}]).toMatchSnapshot([expect.anything()])
But I don't see a valid use case for this knowing that these cases worked fine before #13263:
expect([{}]).toMatchSnapshot(expect.anything())
expect([{ foo: 'bar' }]).toMatchSnapshot([{ foo: expect.anything() }])
Test plan
Tests added