Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

expect: Improve report when matcher fails, part 18 #8356

Merged
merged 2 commits into from
Apr 22, 2019

Conversation

pedrottimark
Copy link
Contributor

Summary

For toMatchObject matcher:

  • Display matcher name in regular black instead of dim color
  • Display promise rejects or resolves in matcher hint
  • Omit redundant or distracting information, as described below

When negative assertion fails:

  • Display not between expected label and value
  • Display received value only if it has different serialization

When positive assertion fails:

  • Display either diff (without Difference label) or stringify values, not both

Residue: there is room for improvement through possible future data-driven diff

Faithful reviewers: thank you for heroic effort to go through matchers.ts together!

  • There may be a small part 19 to improve toThrow(Class) in toThrowMatchers.js
  • And then a well deserved rest before improving reports in spyMatchers.ts

Test plan

updated toMatchObject
25 pass: fail
22 pass: true
10 throws
57 total

See also pictures in following comment.

@pedrottimark
Copy link
Contributor Author

Example pictures baseline at left and improved at right

Negative assertion omit received if it serializes to the same string as expected:

true omit

Negative assertion show received otherwise:

true show

Positive assertion show diff:

false diff

Positive assertion stringify otherwise:

false serialize

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

So good! 👍

@codecov-io
Copy link

Codecov Report

Merging #8356 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8356      +/-   ##
==========================================
+ Coverage   62.23%   62.23%   +<.01%     
==========================================
  Files         266      266              
  Lines       10716    10715       -1     
  Branches     2608     2607       -1     
==========================================
  Hits         6669     6669              
  Misses       3460     3460              
+ Partials      587      586       -1
Impacted Files Coverage Δ
packages/expect/src/matchers.ts 95.83% <100%> (+0.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cd11240...8b3e095. Read the comment docs.

Copy link
Contributor

@scotthovestadt scotthovestadt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me!

@github-actions
Copy link

This pull request 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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants