From ce368457236cdf35ac152e078e88907fa990a0f4 Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Wed, 24 Apr 2024 13:39:05 +0200 Subject: [PATCH] fix: check for null before storing in weakmap --- packages/expect/src/jest-utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/expect/src/jest-utils.ts b/packages/expect/src/jest-utils.ts index 7fe4cc706534..3358ca39bed1 100644 --- a/packages/expect/src/jest-utils.ts +++ b/packages/expect/src/jest-utils.ts @@ -452,7 +452,7 @@ export function subsetEquality(object: unknown, subset: unknown, customTesters: return undefined return Object.keys(subset).every((key) => { - if (typeof subset[key] === 'object') { + if (subset[key] != null && typeof subset[key] === 'object') { if (seenReferences.has(subset[key])) return equals(object[key], subset[key], filteredCustomTesters)