aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2018-02-07 02:23:40 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2018-02-12 15:51:50 +0100
commit0cdc87778e9c871e8bbbb081f4dc52fb17248e58 (patch)
tree8aeb8879a6401d15e045181287a03ff5610a988f /lib
parent656a5d042d30c8c5dbb49a9a9b38ea0df81ec1ca (diff)
downloadandroid-node-v8-0cdc87778e9c871e8bbbb081f4dc52fb17248e58.tar.gz
android-node-v8-0cdc87778e9c871e8bbbb081f4dc52fb17248e58.tar.bz2
android-node-v8-0cdc87778e9c871e8bbbb081f4dc52fb17248e58.zip
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. PR-URL: https://github.com/nodejs/node/pull/18611 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/errors.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/internal/errors.js b/lib/internal/errors.js
index 6d3b055780..fb4f5e8482 100644
--- a/lib/internal/errors.js
+++ b/lib/internal/errors.js
@@ -164,9 +164,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';
@@ -310,8 +310,10 @@ class AssertionError extends Error {
} else if (errorDiff === 1) {
// In case the objects are equal but the operator requires unequal, show
// the first object and say A equals B
- const res = util
- .inspect(actual, { compact: false }).split('\n');
+ const res = util.inspect(
+ actual,
+ { compact: false, customInspect: false }
+ ).split('\n');
if (res.length > 20) {
res[19] = '...';