diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js index 2c10f0c8929752..8d5692777c94e2 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -315,7 +315,7 @@ function keyCheck(val1, val2, strict, memos, iterationType, aKeys) { // Cheap key test let i = 0; for (; i < aKeys.length; i++) { - if (!ObjectPrototypeHasOwnProperty(val2, aKeys[i])) { + if (!ObjectPrototypePropertyIsEnumerable(val2, aKeys[i])) { return false; } } diff --git a/test/parallel/test-assert-deep.js b/test/parallel/test-assert-deep.js index 73af4b3e226929..b14179c85c8a8f 100644 --- a/test/parallel/test-assert-deep.js +++ b/test/parallel/test-assert-deep.js @@ -1194,3 +1194,13 @@ assert.throws( Object.setPrototypeOf(b, null); assertNotDeepOrStrict(a, b, assert.AssertionError); } + +{ + // Verify commutativity + // Regression test for https://github.com/nodejs/node/issues/37710 + const a = { x: 1 }; + const b = { y: 1 }; + Object.defineProperty(b, 'x', { value: 1 }); + + assertNotDeepOrStrict(a, b); +}