@@ -191,6 +191,12 @@ function getTruncatedDiffValue(lines) {
191191 return ArrayPrototypeJoin ( lines , '\n' ) ;
192192}
193193
194+ function hasLargeRootMismatch ( inspectedActual , inspectedExpected , diffType ) {
195+ return diffType !== 'full' &&
196+ inspectedActual . length + inspectedExpected . length > kMaxDiffLineCount &&
197+ inspectedActual [ 0 ] !== inspectedExpected [ 0 ] ;
198+ }
199+
194200function createErrDiff ( actual , expected , operator , customMessage , diffType = 'simple' ) {
195201 operator = checkOperator ( actual , expected , operator ) ;
196202
@@ -222,11 +228,11 @@ function createErrDiff(actual, expected, operator, customMessage, diffType = 'si
222228 message = ArrayPrototypeJoin ( inspectedSplitActual , '\n' ) ;
223229 }
224230 header = '' ;
225- } else if (
226- diffType !== 'full' &&
227- inspectedSplitActual . length + inspectedSplitExpected . length > kMaxDiffLineCount
228- ) {
229- message = `\n${ colors . green } + ${ colors . white } ${ getTruncatedDiffValue ( inspectedSplitActual ) } \n` +
231+ } else if ( hasLargeRootMismatch ( inspectedSplitActual , inspectedSplitExpected , diffType ) ) {
232+ const actualPrefix = operator === 'partialDeepStrictEqual' ?
233+ ` ${ colors . gray } ${ colors . hasColors ? ' ' : '+' } ` :
234+ ` ${ colors . green } + ${ colors . white } ` ;
235+ message = `\n${ actualPrefix } ${ getTruncatedDiffValue ( inspectedSplitActual ) } \n` +
230236 `${ colors . red } -${ colors . white } ${ getTruncatedDiffValue ( inspectedSplitExpected ) } ` ;
231237 skipped = true ;
232238 } else {
@@ -236,15 +242,15 @@ function createErrDiff(actual, expected, operator, customMessage, diffType = 'si
236242 const myersDiffMessage = printMyersDiff ( diff , operator ) ;
237243 message = myersDiffMessage . message ;
238244
239- if ( operator === 'partialDeepStrictEqual' ) {
240- header = `${ colors . gray } ${ colors . hasColors ? '' : '+ ' } actual${ colors . white } ${ colors . red } - expected${ colors . white } ` ;
241- }
242-
243245 if ( myersDiffMessage . skipped ) {
244246 skipped = true ;
245247 }
246248 }
247249
250+ if ( operator === 'partialDeepStrictEqual' ) {
251+ header = `${ colors . gray } ${ colors . hasColors ? '' : '+ ' } actual${ colors . white } ${ colors . red } - expected${ colors . white } ` ;
252+ }
253+
248254 const headerMessage = `${ getErrorMessage ( operator , customMessage ) } \n${ header } ` ;
249255 const skippedMessage = skipped ? '\n... Skipped lines' : '' ;
250256
0 commit comments