Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
assert: show proper differences
Right now it is possible to get an AssertionError from input that has
the customInspect function set to always return the same value.

That way the error message is actually misleading because the output
is going to look the same. This fixes it by deactivating the custom
inspect function.
  • Loading branch information
BridgeAR committed Feb 7, 2018
commit 6d0eb21e9945776f2b7353e1137b5ddfcb082d59
4 changes: 2 additions & 2 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ function createErrDiff(actual, expected, operator) {
var skipped = false;
const util = lazyUtil();
const actualLines = util
.inspect(actual, { compact: false }).split('\n');
.inspect(actual, { compact: false, customInspect: false }).split('\n');
const expectedLines = util
.inspect(expected, { compact: false }).split('\n');
.inspect(expected, { compact: false, customInspect: false }).split('\n');
const msg = `Input A expected to ${operator} input B:\n` +
`${green}+ expected${white} ${red}- actual${white}`;
const skippedMsg = ' ... Lines skipped';
Expand Down
6 changes: 5 additions & 1 deletion test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,11 @@ common.expectsError(
message: `${start}\n` +
`${actExp}\n` +
'\n' +
' {}'
`${minus} {}\n` +
`${plus} {\n` +
`${plus} loop: 'forever',\n` +
`${plus} [Symbol(util.inspect.custom)]: [Function]\n` +
`${plus} }`
});

// notDeepEqual tests
Expand Down