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

jest-diff: Add trailingSpaceFormatter option and replace cyan with commonColor #8927

Merged

Conversation

pedrottimark
Copy link
Contributor

Summary

  1. Make default export and diffStringsUnified display trailing spaces consistently:

    • default export used chalk.inverse in changed lines, but it is ambiguous with formatting for changed substrings
    • default export used chalk.bgYellow in common lines, which becomes the default value of the option, unless y’all recommend something else
    • diffStringsUnified used '·' middle dot, but it is ambiguous with content
  2. Replace cyan color with commonColor for lines that differ only by indentation when both values are objects (am studying how to do it for snapshots tests when received is object and snapshot is string)

Residue

  • diffStringsUnified replaces trimmable empty line at beginning or end of diff with '↵' but default export does not
  • chore to omit double quote marks and have consistent length for color tags in diffs.test.ts.snap

Test plan

package file snapshots
expect matchers.test.ts.snap updated 2
jest-diff diffs.test.ts.snap updated 1 , added 2, deleted 5
jest-matcher-utils printDiffOrStringify.test.ts updated 1
jest-snapshot printDiffOrStringified.test.ts updated 1

See also pictures in the following comment

@codecov-io
Copy link

codecov-io commented Sep 8, 2019

Codecov Report

Merging #8927 into master will decrease coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8927      +/-   ##
==========================================
- Coverage   64.28%   64.24%   -0.05%     
==========================================
  Files         276      276              
  Lines       11716    11695      -21     
  Branches     2868     2863       -5     
==========================================
- Hits         7532     7513      -19     
+ Misses       3552     3550       -2     
  Partials      632      632
Impacted Files Coverage Δ
packages/jest-diff/src/normalizeDiffOptions.ts 100% <ø> (ø) ⬆️
packages/jest-diff/src/printDiffs.ts 97.4% <100%> (-0.04%) ⬇️
packages/jest-diff/src/diffLines.ts 96.77% <100%> (-0.35%) ⬇️
packages/jest-environment-jsdom/src/index.ts 38.63% <0%> (-0.5%) ⬇️
packages/jest-transform/src/ScriptTransformer.ts 68.77% <0%> (-0.15%) ⬇️
packages/jest-environment-node/src/index.ts 48.48% <0%> (-0.09%) ⬇️
packages/jest-fake-timers/src/FakeTimersLolex.ts 69.76% <0%> (ø) ⬆️

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 0935f7c...628e4a2. Read the comment docs.

@pedrottimark
Copy link
Contributor Author

pedrottimark commented Sep 8, 2019

Baseline at left and improved at right

default export from potentially confusing inverse to bgYellow

1 inverse yellowish

lines which differ only by indentation become dim

5 cyan space

diffStringsUnified from dot to bgYellow

2 dot yellowish

and inverse color for space means it is a change

3 inverse dot yellowish

Baseline at left and optional at right

now it is possible for options to specify no colors

const noColor = string => string;

const options = {
  aColor: noColor,
  bColor: noColor,
  changeColor: noColor,
  commonColor: noColor,
  patchColor: noColor,
  trailingSpaceFormatter: noColor,
};

4 common dot

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.

Nice, I like it!

@pedrottimark pedrottimark merged commit 736edd2 into jestjs:master Sep 9, 2019
@pedrottimark pedrottimark deleted the trailingSpaceFormatter-cyan branch September 9, 2019 13:53
@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.

None yet

4 participants