diff --git a/lib/assert.js b/lib/assert.js index b15549f83d74bb..8955aa8761d7c2 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -193,8 +193,9 @@ function _deepEqual(actual, expected, strict, memos) { } else { memos = memos || {actual: [], expected: []}; - if (memos.actual.includes(actual)) { - if (memos.actual.indexOf(actual) === memos.expected.indexOf(expected)) { + const actualIndex = memos.actual.indexOf(actual); + if (actualIndex !== -1) { + if (actualIndex === memos.expected.indexOf(expected)) { return true; } } diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index ddd2160a5079e4..894eb581b721a2 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -401,8 +401,8 @@ assert.ok(threw); e.a = 1; e.b = e.a; - a.throws(makeBlock(a.deepEqual, d, e)); - a.throws(makeBlock(a.deepStrictEqual, d, e)); + a.throws(makeBlock(a.deepEqual, d, e), /AssertionError/); + a.throws(makeBlock(a.deepStrictEqual, d, e), /AssertionError/); } // GH-7178. Ensure reflexivity of deepEqual with `arguments` objects. var args = (function() { return arguments; })();