Skip to content

Commit d402277

Browse files
authored
Merge branch 'master' into faster-string-diff
2 parents b3becdc + 9f2ff09 commit d402277

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/format-assert-error.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22
const indentString = require('indent-string');
3+
const stripAnsi = require('strip-ansi');
34
const chalk = require('chalk');
45
const diff = require('diff');
56
const DiffMatchPatch = require('diff-match-patch');
@@ -47,7 +48,7 @@ module.exports = err => {
4748

4849
if (err.actualType === 'string' && err.expectedType === 'string') {
4950
const diffMatchPatch = new DiffMatchPatch();
50-
const patch = diffMatchPatch.diff_main(err.actual, err.expected);
51+
const patch = diffMatchPatch.diff_main(stripAnsi(err.actual), stripAnsi(err.expected));
5152
const msg = patch
5253
.map(part => {
5354
if (part[0] === 1) {
@@ -58,7 +59,7 @@ module.exports = err => {
5859
return chalk.bgRed.black(part[1]);
5960
}
6061

61-
return part[1];
62+
return chalk.red(part[1]);
6263
})
6364
.join('');
6465

test/format-assert-error.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ test('diff strings', t => {
7272

7373
t.is(format(err), [
7474
'Difference:\n',
75-
`ab${chalk.bgRed.black('c')}${chalk.bgGreen.black('d')}\n`
75+
`${chalk.red('ab')}${chalk.bgRed.black('c')}${chalk.bgGreen.black('d')}\n`
7676
].join('\n'));
7777
t.end();
7878
});

0 commit comments

Comments
 (0)