From 23b32d3f8d273c87f114ad3ec2dcd44d16a5c624 Mon Sep 17 00:00:00 2001 From: Jan Kassens Date: Fri, 29 Mar 2024 14:01:45 -0400 Subject: [PATCH] Test for ReactTestRenderer (#28674) This is a repro for a breakage that #28672 would introduce for legacy sync rendering. --- .../src/__tests__/ReactTestRenderer-test.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js b/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js index e6ed9fa11c291..d3bbd294e37c3 100644 --- a/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js +++ b/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js @@ -50,6 +50,35 @@ describe('ReactTestRenderer', () => { expect(errors[1].message.includes('indexOf is not a function')).toBe(true); }); + test('find element by prop with suspended content', async () => { + const neverResolve = new Promise(() => {}); + + function TestComp({foo}) { + if (foo === 'one') { + throw neverResolve; + } else { + return null; + } + } + + const tree = await act(() => + ReactTestRenderer.create( +
+ + + + +
, + ), + ); + + expect( + tree.root.find(item => { + return item.props.foo === 'two'; + }), + ).toBeDefined(); + }); + describe('timed out Suspense hidden subtrees should not be observable via toJSON', () => { let AsyncText; let PendingResources;