Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

merged 2 commits into from Apr 22, 2019


None yet
5 participants
Copy link

commented Apr 21, 2019


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.


This comment has been minimized.

Copy link
Collaborator Author

commented Apr 21, 2019

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


SimenB approved these changes Apr 21, 2019

Copy link

left a comment


So good! 👍


This comment has been minimized.

Copy link

commented Apr 21, 2019

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

left a comment

Looks great to me!

@SimenB SimenB merged commit 0f77332 into facebook:master Apr 22, 2019

10 of 11 checks passed

ci/circleci: test-node-6 Your tests failed on CircleCI
ci/circleci: lint-and-typecheck Your tests passed on CircleCI!
ci/circleci: test-browser Your tests passed on CircleCI!
ci/circleci: test-jest-circus Your tests passed on CircleCI!
ci/circleci: test-node-10 Your tests passed on CircleCI!
ci/circleci: test-node-11 Your tests passed on CircleCI!
ci/circleci: test-node-8 Your tests passed on CircleCI!
ci/circleci: test-or-deploy-website Your tests passed on CircleCI!
continuous-integration/travis-ci/pr The Travis CI build passed
deploy/netlify Deploy preview ready!
facebook.jest #20190421.14 succeeded

@pedrottimark pedrottimark deleted the pedrottimark:improve-report-18 branch Apr 22, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.