Skip to content

Commit 23b32d3

Browse files
authored
Test for ReactTestRenderer (#28674)
This is a repro for a breakage that #28672 would introduce for legacy sync rendering.
1 parent 18812b6 commit 23b32d3

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,35 @@ describe('ReactTestRenderer', () => {
5050
expect(errors[1].message.includes('indexOf is not a function')).toBe(true);
5151
});
5252

53+
test('find element by prop with suspended content', async () => {
54+
const neverResolve = new Promise(() => {});
55+
56+
function TestComp({foo}) {
57+
if (foo === 'one') {
58+
throw neverResolve;
59+
} else {
60+
return null;
61+
}
62+
}
63+
64+
const tree = await act(() =>
65+
ReactTestRenderer.create(
66+
<div>
67+
<React.Suspense fallback={null}>
68+
<TestComp foo="one" />
69+
</React.Suspense>
70+
<TestComp foo="two" />
71+
</div>,
72+
),
73+
);
74+
75+
expect(
76+
tree.root.find(item => {
77+
return item.props.foo === 'two';
78+
}),
79+
).toBeDefined();
80+
});
81+
5382
describe('timed out Suspense hidden subtrees should not be observable via toJSON', () => {
5483
let AsyncText;
5584
let PendingResources;

0 commit comments

Comments
 (0)