question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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),
  })
})

screenshot-1537659092

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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
rickhanloniicommented, Oct 16, 2018
0reactions
github-actions[bot]commented, May 12, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found