From 0553005ae367b20e2fe5c670e65c67c0e4fa5f6b Mon Sep 17 00:00:00 2001 From: ninevra Date: Mon, 26 Oct 2020 22:57:04 -0700 Subject: [PATCH] Test ObjectContaining with cross-realm inputs --- .../expect/src/__tests__/asymmetricMatchers.test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/expect/src/__tests__/asymmetricMatchers.test.ts b/packages/expect/src/__tests__/asymmetricMatchers.test.ts index 843e51b8719c..bb7bae315ce3 100644 --- a/packages/expect/src/__tests__/asymmetricMatchers.test.ts +++ b/packages/expect/src/__tests__/asymmetricMatchers.test.ts @@ -185,6 +185,19 @@ test('ObjectContaining matches', () => { }); }); +test('ObjectContaining recurses into other-realm objects', () => { + const other_realm = new TextEncoder().encodeInto( + 'hello world', + new Uint8Array(100), + ); // returns {read: 11, written: 11} from Node + jestExpect({foo: other_realm}).toEqual({foo: {read: 11, written: 11}}); + jestExpect( + objectContaining({foo: other_realm}).asymmetricMatch({ + foo: {read: 11, written: 11, zed: 11}, + }), + ).toEqual(true); +}); + test('ObjectContaining does not match', () => { [ objectContaining({foo: 'foo'}).asymmetricMatch({bar: 'bar'}),