Closed
Description
🚀 Feature Proposal
Hi 👋. I think it would be great if Jest would better highlight diffs for objects with asymmetric matchers. Currently, Jest highlights correct/passing asymmetric matchers as changes, which is confusing to the user. I propose that Jest only highlights the matchers that do not pass.
For example:
test('asdf', () => {
expect({ name: 'asdf' }).toStrictEqual({
name: expect.any(String),
week: expect.any(Number),
})
})
This output is unclear to the user. It shows that the name
property is different from the expected value, which makes it less clear that the week
property is missing. Objects with more properties make it harder and harder to tell the actual changes.
I propose that Jest highlights the above example like:
- Expected
+ Received
Object {
"name": "asdf",
- "week": Any<Number>,
}
This would make it much more clear to the user which property is missing.