Don't highlight passing asymmetric matchers as changes in diffs
See original GitHub issue🚀 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.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Jest 25: Laying foundations for the future · Jest
Jest 25 is laying the groundwork for many major changes in the future. ... Jest will no longer highlight passing asymmetric matchers in...
Read more >The hidden power of Jest matchers | by Boris - Medium
Today I will try to highlight some examples, where asymmetric matches will be surprisingly powerful and allow you to write much simpler code ......
Read more >Improve intraline diff highlighting in the changes view - GitLab
The highlighting of text diff in the changes view is lacking especially when it comes to normal text in for example latex or...
Read more >jest-runner | Yarn - Package Manager
... rejected values are promises from correct realm (#13503); [jest-snapshot] Don't highlight passing asymmetric property matchers in snapshot diff (#13480) ...
Read more >Database Engine events and errors - SQL Server
ls' does not match with a table name or alias name used in the query. ... To correct this error, change the query...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is this a dupe of https://github.com/facebook/jest/issues/6184?
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. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.