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, jest-matcher-utils: Display change counts in annotation lines #9035

Merged
merged 2 commits into from
Oct 10, 2019

Conversation

pedrottimark
Copy link
Contributor

Summary

In the printDiffOrStringify function, add includeChangeCounts option to calls:

  • diffStringsUnified
  • diffDefault

For consistency with #8982 to interpret differences when other assertions fail

Residue

Did not add includeChangeCounts option:

  • to spy matchers because not separate annotations for multiple diffs per call
  • to diff named export from jest-matcher-utils but caller can add it

I noticed something brittle about a few snapshots of matcher errors which contain diffs: when I tested with --expand option to see all of the lines in the snapshot to count changes, it affected the matcher, which is not correct.

Test plan

Updated 76 snapshots

The differences between empty and non-empty map or object are example where change counts would be even clearer in a data-driven-diff

package test file
1 e2e failures
4 expect extend
66 expect matchers
2 expect toThrowMatchers
1 jest-matcher-utils index
2 jest-matcher-utils printDiffOrStringify

See also pictures in following comment: baseline is at left and improved is at right

@pedrottimark
Copy link
Contributor Author

toBe string: change 1 line

toBe

toEqual object: insert 2 lines

toEqual

toHaveProperty element: change 1 line

toHaveProperty

toMatchObject object: delete 2 lines and change 1 line

toMatchObject

Analysis of the preceding example might decide whether it is progress or regress to change from polyline with stroke to polygon with fill

toStrictEqual instance: change 1 line (that is, the data type)

toStrictEqual

@codecov-io
Copy link

codecov-io commented Oct 9, 2019

Codecov Report

Merging #9035 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #9035   +/-   ##
=======================================
  Coverage   64.05%   64.05%           
=======================================
  Files         277      277           
  Lines       11676    11676           
  Branches     2863     2863           
=======================================
  Hits         7479     7479           
  Misses       3572     3572           
  Partials      625      625
Impacted Files Coverage Δ
packages/jest-matcher-utils/src/index.ts 83.22% <100%> (ø) ⬆️

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 f15ada4...8f9249d. Read the comment docs.

@pedrottimark pedrottimark merged commit 8d47ffa into jestjs:master Oct 10, 2019
@pedrottimark pedrottimark deleted the includeChangeCounts-utils branch October 10, 2019 21:45
@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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants