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

Use background color to show colored spaces in an inline diff #4287

Merged
merged 7 commits into from
Jun 22, 2020
12 changes: 7 additions & 5 deletions lib/reporters/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ exports.colors = {
light: 90,
'diff gutter': 90,
'diff added': 32,
'diff removed': 31
'diff removed': 31,
'diff added inline': '30;42',
'diff removed inline': '30;41'
};

/**
Expand Down Expand Up @@ -406,9 +408,9 @@ function inlineDiff(actual, expected) {
// legend
msg =
'\n' +
color('diff removed', 'actual') +
color('diff removed inline', 'actual') +
' ' +
color('diff added', 'expected') +
color('diff added inline', 'expected') +
'\n\n' +
msg +
'\n';
Expand Down Expand Up @@ -474,10 +476,10 @@ function errorDiff(actual, expected) {
.diffWordsWithSpace(actual, expected)
.map(function(str) {
if (str.added) {
return colorLines('diff added', str.value);
return colorLines('diff added inline', str.value);
}
if (str.removed) {
return colorLines('diff removed', str.value);
return colorLines('diff removed inline', str.value);
}
return str.value;
})
Expand Down