@@ -15,6 +15,7 @@ const kInfo = Symbol('info');
15
15
const messages = new Map ( ) ;
16
16
const codes = { } ;
17
17
18
+ let blue = '' ;
18
19
let green = '' ;
19
20
let red = '' ;
20
21
let white = '' ;
@@ -259,7 +260,7 @@ function createErrDiff(actual, expected, operator) {
259
260
const expectedLines = inspectValue ( expected ) ;
260
261
const msg = READABLE_OPERATOR [ operator ] +
261
262
`:\n${ green } + expected${ white } ${ red } - actual${ white } ` ;
262
- const skippedMsg = ' ... Lines skipped' ;
263
+ const skippedMsg = ` ${ blue } ...${ white } Lines skipped` ;
263
264
264
265
// Remove all ending lines that match (this optimizes the output for
265
266
// readability by reducing the number of total changed lines).
@@ -280,7 +281,7 @@ function createErrDiff(actual, expected, operator) {
280
281
b = expectedLines [ expectedLines . length - 1 ] ;
281
282
}
282
283
if ( i > 3 ) {
283
- end = `\n...${ end } ` ;
284
+ end = `\n${ blue } ...${ white } ${ end } ` ;
284
285
skipped = true ;
285
286
}
286
287
if ( other !== '' ) {
@@ -297,7 +298,7 @@ function createErrDiff(actual, expected, operator) {
297
298
if ( actualLines . length < i + 1 ) {
298
299
if ( cur > 1 && i > 2 ) {
299
300
if ( cur > 4 ) {
300
- res += '\n ...' ;
301
+ res += `\n ${ blue } ...${ white } ` ;
301
302
skipped = true ;
302
303
} else if ( cur > 3 ) {
303
304
res += `\n ${ expectedLines [ i - 2 ] } ` ;
@@ -313,7 +314,7 @@ function createErrDiff(actual, expected, operator) {
313
314
} else if ( expectedLines . length < i + 1 ) {
314
315
if ( cur > 1 && i > 2 ) {
315
316
if ( cur > 4 ) {
316
- res += '\n ...' ;
317
+ res += `\n ${ blue } ...${ white } ` ;
317
318
skipped = true ;
318
319
} else if ( cur > 3 ) {
319
320
res += `\n ${ actualLines [ i - 2 ] } ` ;
@@ -329,7 +330,7 @@ function createErrDiff(actual, expected, operator) {
329
330
} else if ( actualLines [ i ] !== expectedLines [ i ] ) {
330
331
if ( cur > 1 && i > 2 ) {
331
332
if ( cur > 4 ) {
332
- res += '\n ...' ;
333
+ res += `\n ${ blue } ...${ white } ` ;
333
334
skipped = true ;
334
335
} else if ( cur > 3 ) {
335
336
res += `\n ${ actualLines [ i - 2 ] } ` ;
@@ -354,7 +355,8 @@ function createErrDiff(actual, expected, operator) {
354
355
}
355
356
// Inspected object to big (Show ~20 rows max)
356
357
if ( printedLines > 20 && i < maxLines - 2 ) {
357
- return `${ msg } ${ skippedMsg } \n${ res } \n...${ other } \n...` ;
358
+ return `${ msg } ${ skippedMsg } \n${ res } \n${ blue } ...${ white } ${ other } \n` +
359
+ `${ blue } ...${ white } ` ;
358
360
}
359
361
}
360
362
@@ -371,7 +373,7 @@ function createErrDiff(actual, expected, operator) {
371
373
// Only remove lines in case it makes sense to collapse those.
372
374
// TODO: Accept env to always show the full error.
373
375
if ( actualLines . length > 30 ) {
374
- actualLines [ 26 ] = ' ...' ;
376
+ actualLines [ 26 ] = ` ${ blue } ...${ white } ` ;
375
377
while ( actualLines . length > 27 ) {
376
378
actualLines . pop ( ) ;
377
379
}
@@ -402,10 +404,12 @@ class AssertionError extends Error {
402
404
// Reset on each call to make sure we handle dynamically set environment
403
405
// variables correct.
404
406
if ( process . stdout . getColorDepth ( ) !== 1 ) {
407
+ blue = '\u001b[34m' ;
405
408
green = '\u001b[32m' ;
406
409
white = '\u001b[39m' ;
407
410
red = '\u001b[31m' ;
408
411
} else {
412
+ blue = '' ;
409
413
green = '' ;
410
414
white = '' ;
411
415
red = '' ;
@@ -435,7 +439,7 @@ class AssertionError extends Error {
435
439
// Only remove lines in case it makes sense to collapse those.
436
440
// TODO: Accept env to always show the full error.
437
441
if ( res . length > 30 ) {
438
- res [ 26 ] = ' ...' ;
442
+ res [ 26 ] = ` ${ blue } ...${ white } ` ;
439
443
while ( res . length > 27 ) {
440
444
res . pop ( ) ;
441
445
}
0 commit comments