Skip to content

Commit 7709510

Browse files
lib: add skipPrototypeComparison option to deepStrictEqual for Assert class
1 parent a5d2265 commit 7709510

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/assert.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ const NO_EXCEPTION_SENTINEL = {};
9393
* @property {'full'|'simple'} [diff='simple'] - If set to 'full', shows the full diff in assertion errors.
9494
* @property {boolean} [strict=true] - If set to true, non-strict methods behave like their corresponding
9595
* strict methods.
96+
* @property {boolean} [skipPrototypeComparison=false] - If set to true, skips comparing prototypes
97+
* in deep equality checks.
9698
*/
9799

98100
/**
@@ -105,7 +107,7 @@ function Assert(options) {
105107
throw new ERR_CONSTRUCT_CALL_REQUIRED('Assert');
106108
}
107109

108-
options = ObjectAssign({ __proto__: null, strict: true }, options);
110+
options = ObjectAssign({ __proto__: null, strict: true, skipPrototypeComparison: false }, options);
109111

110112
const allowedDiffs = ['simple', 'full'];
111113
if (options.diff !== undefined) {
@@ -311,7 +313,7 @@ Assert.prototype.deepStrictEqual = function deepStrictEqual(actual, expected, me
311313
throw new ERR_MISSING_ARGS('actual', 'expected');
312314
}
313315
if (isDeepEqual === undefined) lazyLoadComparison();
314-
if (!isDeepStrictEqual(actual, expected)) {
316+
if (!isDeepStrictEqual(actual, expected, { skipPrototypeComparison: this?.[kOptions]?.skipPrototypeComparison })) {
315317
innerFail({
316318
actual,
317319
expected,

0 commit comments

Comments
 (0)