-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Description
🚀 Feature Proposal
Currently,
expect([{}]).toMatchSnapshot([expect.anything()]);
fails with
expect(received).toMatchSnapshot(properties)
Matcher error: Expected properties must be an object
Expected properties has type: array
Expected properties has value: [Anything]
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
expect([{}, "foo"]).toMatchSnapshot([expect.anything(), "foo"]);
Pitch
This was supported in Jest v27 and the wording toMatchSnapshot
feels very intuitive as opposed to some custom toMatchArraySnapshot
(or the like) matcher. As a neat side effect, this would also allow to snapshot-test function parameter arrays.
rarkins, viceice, bakasmarius, ItamarKieslerFabric, mr-pascal and 3 more