@@ -313,6 +313,17 @@ function createErrDiff(actual, expected, operator) {
313
313
return `${ msg } ${ skipped ? skippedMsg : '' } \n${ res } ${ other } ${ end } ${ indicator } ` ;
314
314
}
315
315
316
+ function addEllipsis ( string ) {
317
+ const lines = StringPrototypeSplit ( string , '\n' , 11 ) ;
318
+ if ( lines . length > 10 ) {
319
+ lines . length = 10 ;
320
+ return `${ ArrayPrototypeJoin ( lines , '\n' ) } \n...` ;
321
+ } else if ( string . length > 512 ) {
322
+ return `${ StringPrototypeSlice ( string , 512 ) } ...` ;
323
+ }
324
+ return string ;
325
+ }
326
+
316
327
class AssertionError extends Error {
317
328
constructor ( options ) {
318
329
validateObject ( options , 'options' ) ;
@@ -467,16 +478,11 @@ class AssertionError extends Error {
467
478
const tmpActual = this . actual ;
468
479
const tmpExpected = this . expected ;
469
480
470
- for ( const name of [ 'actual' , 'expected' ] ) {
471
- if ( typeof this [ name ] === 'string' ) {
472
- const lines = StringPrototypeSplit ( this [ name ] , '\n' ) ;
473
- if ( lines . length > 10 ) {
474
- lines . length = 10 ;
475
- this [ name ] = `${ ArrayPrototypeJoin ( lines , '\n' ) } \n...` ;
476
- } else if ( this [ name ] . length > 512 ) {
477
- this [ name ] = `${ StringPrototypeSlice ( this [ name ] , 512 ) } ...` ;
478
- }
479
- }
481
+ if ( typeof this . actual === 'string' ) {
482
+ this . actual = addEllipsis ( this . actual ) ;
483
+ }
484
+ if ( typeof this . expected === 'string' ) {
485
+ this . expected = addEllipsis ( this . expected ) ;
480
486
}
481
487
482
488
// This limits the `actual` and `expected` property default inspection to
0 commit comments