From d3426ee9f187db92671cec1e1e3f1ace4c04c89b Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 23 Jul 2019 20:38:53 +0200 Subject: [PATCH] assert: avoid potentially misleading reference to object identity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Often, the word “identical” when referring to JS objects will be read as referring to having the same object identity (which is called “reference equality” here), but what the error message is trying to say here is that the objects are different but yield the same `util.inspect()` output. Since `util.inspect()` output represents the structure rather than the identity of objects, (hopefully) clarify the error message to reflect that. PR-URL: https://github.com/nodejs/node/pull/28824 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Rich Trott Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- lib/internal/assert/assertion_error.js | 2 +- test/parallel/test-assert.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/internal/assert/assertion_error.js b/lib/internal/assert/assertion_error.js index cdeba1941c4b02..3734796e2d2a2d 100644 --- a/lib/internal/assert/assertion_error.js +++ b/lib/internal/assert/assertion_error.js @@ -22,7 +22,7 @@ const kReadableOperator = { notStrictEqualObject: 'Expected "actual" not to be reference-equal to "expected":', notDeepEqual: 'Expected "actual" not to be loosely deep-equal to:', - notIdentical: 'Values identical but not reference-equal:', + notIdentical: 'Values have same structure but are not reference-equal:', notDeepEqualUnequal: 'Expected values not to be loosely deep-equal:' }; diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 04f7571a9bee66..61c8f7becead42 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -1100,7 +1100,7 @@ assert.throws(() => { throw null; }, 'foo'); assert.throws( () => assert.strictEqual([], []), { - message: 'Values identical but not reference-equal:\n\n[]\n' + message: 'Values have same structure but are not reference-equal:\n\n[]\n' } );