diff --git a/testing/asserts.ts b/testing/asserts.ts index 352bfd700735..94cca851bce2 100644 --- a/testing/asserts.ts +++ b/testing/asserts.ts @@ -161,6 +161,9 @@ export function equal(c: unknown, d: unknown): boolean { if (!compare(a && a[key as Key], b && b[key as Key])) { return false; } + if (((key in a) && (!(key in b))) || ((key in b) && (!(key in a)))) { + return false; + } } seen.set(a, b); return true; diff --git a/testing/asserts_test.ts b/testing/asserts_test.ts index f0eab61c6867..5ac83fce8c94 100644 --- a/testing/asserts_test.ts +++ b/testing/asserts_test.ts @@ -147,6 +147,12 @@ Deno.test("testingEqual", function (): void { new URL("https://example.test/with-path"), ), ); + assert( + !equal({ a: undefined, b: undefined }, { a: undefined, c: undefined }), + ); + assert( + !equal({ a: undefined, b: undefined }, { a: undefined }), + ); }); Deno.test("testingNotEquals", function (): void {