-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Highlight whitespace in expected/received #2674
Conversation
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') |
There was a problem hiding this comment.
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('$&'))
There was a problem hiding this comment.
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!
Current coverage is 68.31% (diff: 83.33%)@@ 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
|
* Highlight whitespace in expected/received * Simplify text replacement with multiline regexp
* Highlight whitespace in expected/received * Simplify text replacement with multiline regexp
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. |
Summary
Fixes #2673
Test plan
I may want to add a test for this