Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions lib/internal/assert/assertion_error.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,16 @@ function getStackedDiff(actual, expected) {
}

function getSimpleDiff(originalActual, actual, originalExpected, expected) {
let stringsLen = actual.length + expected.length;
const isStrA = typeof originalActual === 'string';
const isStrE = typeof originalExpected === 'string';
// Accounting for the quotes wrapping strings
if (typeof originalActual === 'string') {
stringsLen -= 2;
}
if (typeof originalExpected === 'string') {
stringsLen -= 2;
}
const stringsLen = actual.length + expected.length - (isStrA ? 2 : 0) - (isStrE ? 2 : 0);
if (stringsLen <= kMaxShortStringLength && (originalActual !== 0 || originalExpected !== 0)) {
return { message: `${actual} !== ${expected}`, header: '' };
}

const isStringComparison = typeof originalActual === 'string' && typeof originalExpected === 'string';
// colored myers diff
if (isStringComparison && colors.hasColors) {
if (isStrA && isStrE && colors.hasColors) {
return getColoredMyersDiff(actual, expected);
}

Expand Down
Loading