-
-
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
[Feature]: Support array inputs to toMatchSnapshot()
matcher
#13352
Comments
Happy to take a PR adding support for this. 👍 If it used to work in Jest 27, it should be possible to go back and bisect to see what broke it. |
I think this should be changed to a bug report instead of a feature request. This was working for us in jest v29.0.3, but is broken when attempting to upgrade to v29.1.2. Here's a sample reproduction from our repo:
which errors with
|
@JamieMagee I previously opened #13134. Interestingly, my repro doesn't work with |
A quick workaround is to wrap the array into an object. For example: expect({ theArray }).toMatchSnapshot({ theArray: [...] }); |
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 |
Any update on this? |
I created a PR (#14025) that undoes the changes that broke the functionality. |
I updated my PR (#14025) and now it also supports |
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. |
🚀 Feature Proposal
Currently,
fails with
(#13134, example repo here).
Motivation
This used to work in Jest v27 and would allow test cases like this again. It would help to avoid wrapping arrays in objects solely for the sake of snapshot testing.
Example
Something like
Pitch
This was supported in Jest v27 and the wording
toMatchSnapshot
feels very intuitive as opposed to some customtoMatchArraySnapshot
(or the like) matcher. As a neat side effect, this would also allow to snapshot-test function parameter arrays.The text was updated successfully, but these errors were encountered: