@@ -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
if ( typeof options !== 'object' || options === null ) {
@@ -469,16 +480,11 @@ class AssertionError extends Error {
469
480
const tmpActual = this . actual ;
470
481
const tmpExpected = this . expected ;
471
482
472
- for ( const name of [ 'actual' , 'expected' ] ) {
473
- if ( typeof this [ name ] === 'string' ) {
474
- const lines = StringPrototypeSplit ( this [ name ] , '\n' ) ;
475
- if ( lines . length > 10 ) {
476
- lines . length = 10 ;
477
- this [ name ] = `${ ArrayPrototypeJoin ( lines , '\n' ) } \n...` ;
478
- } else if ( this [ name ] . length > 512 ) {
479
- this [ name ] = `${ StringPrototypeSlice ( this [ name ] , 512 ) } ...` ;
480
- }
481
- }
483
+ if ( typeof this . actual === 'string' ) {
484
+ this . actual = addEllipsis ( this . actual ) ;
485
+ }
486
+ if ( typeof this . expected === 'string' ) {
487
+ this . expected = addEllipsis ( this . expected ) ;
482
488
}
483
489
484
490
// This limits the `actual` and `expected` property default inspection to
0 commit comments