-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop considering properties not passed to expect.objectContaining
as "Received" in the failure diff
#6170
Comments
If this is a desired change, any pointers for where to start looking in the code? |
This makes it harder to pick up on typos, doesn't it? I supoose we could differentiate between value inequalities and key inequalities, and if all keys are present, just print those |
I'm not sure if it would make it harder - if the keys are mismatched then the diff shows the expectation's mismatched key in green. Making a typo in my above example looks like this:
Do you think it would be harder to spot the typo if component, rank, style, and suite were the same color as accessor? edit: I like your idea of only displaying a more selective diff when the keys match, that works for me |
I was going to file an issue for this myself, and I found that someone else was confused by the same thing. The output is confusing here. If you're testing for only properties I don't have a solution, but I did find it confusing. |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 14 days. |
This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
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
Improve the diff highlighting for expect.objectContaining
Motivation
This makes it faster to identify the cause of a matcher failure.
Example
Here is a contrived example of a failing test (the actual case I ran into had many more properties):
The error message helpfully grays out the "suite" in the diff because expect.objectContaining knows that 'Heart' is correct. However, all of the properties it does not care about, like "accessor", "style", and "component" are highlighted as red along with the actual culprit, "rank". Here's a screenshot of the sample output:
or you can try it out yourself here: https://repl.it/repls/ContentAlarmingExponent
I'd prefer if "accessor", "style", and "component" were treated similar to "suite" and formatted accordingly.
Pitch
Why does this feature belong in the
Jest core platform?
This is a change to the existing logic, not an additional feature
Common feature proposals that do not typically make it to core:
jest-extended)
The text was updated successfully, but these errors were encountered: