Skip to content

Commit 99f70ad

Browse files
fix(bridge-react): update tests to handle React 19 async rendering
- Replace sleep() with waitFor() from @testing-library/react for proper async handling in React 19 - Fix tests that were stuck showing "loading" due to suspended resources not resolving properly - Ensure tests wait for lazy-loaded components to render completely 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent fb72852 commit 99f70ad

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

packages/bridge/bridge-react/__tests__/bridge.spec.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,12 @@ describe('bridge', () => {
6666
);
6767
expect(getHtml(container)).toMatch('loading');
6868

69-
await sleep(200);
70-
expect(getHtml(container)).toMatch('life cycle render');
69+
await waitFor(
70+
() => {
71+
expect(getHtml(container)).toMatch('life cycle render');
72+
},
73+
{ timeout: 1000 },
74+
);
7175
expect(getHtml(container)).toMatch('hello world');
7276
});
7377

@@ -97,8 +101,12 @@ describe('bridge', () => {
97101
);
98102
expect(getHtml(container)).toMatch('loading');
99103

100-
await sleep(200);
101-
expect(getHtml(container)).toMatch('life cycle render');
104+
await waitFor(
105+
() => {
106+
expect(getHtml(container)).toMatch('life cycle render');
107+
},
108+
{ timeout: 1000 },
109+
);
102110
expect(getHtml(container)).toMatch('hello world');
103111
expect(ref.current).not.toBeNull();
104112
});
@@ -131,7 +139,11 @@ describe('bridge', () => {
131139
const { container } = render(<RemoteComponent />);
132140
expect(getHtml(container)).toMatch('loading');
133141

134-
await sleep(200);
135-
expect(renderMock).toHaveBeenCalledTimes(1);
142+
await waitFor(
143+
() => {
144+
expect(renderMock).toHaveBeenCalledTimes(1);
145+
},
146+
{ timeout: 1000 },
147+
);
136148
});
137149
});

0 commit comments

Comments
 (0)