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

Highlight whitespace in expected/received #2674

Merged

Conversation

thymikee
Copy link
Collaborator

Summary
Fixes #2673

screen shot 2017-01-23 at 16 10 02

Test plan
I may want to add a test for this

const printReceived = (object: any) => RECEIVED_COLOR(stringify(object));
const printExpected = (value: any) => EXPECTED_COLOR(stringify(value));
const highlightTrailingWhitespace = (text: string, bgColor: Function): string =>
text.split('\n')
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of splitting and joining after mapping, you can just use a global, multiline regular expression:

text.replace(/\s+$/gm, bgColor('$&'))

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm a dummy, thanks!

@codecov-io
Copy link

codecov-io commented Jan 23, 2017

Current coverage is 68.31% (diff: 83.33%)

Merging #2674 into master will increase coverage by <.01%

@@             master      #2674   diff @@
==========================================
  Files           140        140          
  Lines          5059       5063     +4   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           3456       3459     +3   
- Misses         1603       1604     +1   
  Partials          0          0          

Powered by Codecov. Last update f123b96...663f030

@kentaromiura kentaromiura merged commit 393dd35 into jestjs:master Jan 23, 2017
@thymikee thymikee deleted the highlight-whitespace-throwing-matchers branch February 19, 2017 16:29
skovhus pushed a commit to skovhus/jest that referenced this pull request Apr 29, 2017
* Highlight whitespace in expected/received

* Simplify text replacement with multiline regexp
tushardhole pushed a commit to tushardhole/jest that referenced this pull request Aug 21, 2017
* Highlight whitespace in expected/received

* Simplify text replacement with multiline regexp
@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 13, 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.

Add invisible characters highlighting in diffs
4 participants