Skip to content

Commit 4764577

Browse files
committed
Make RSC tests await act
1 parent 1d52482 commit 4764577

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

node_package/tests/RSCClientRoot.test.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ enableFetchMocks();
6666
};
6767

6868
// Execute the render
69-
const render = () =>
70-
act(async () => {
69+
const render = async () => {
70+
await act(async () => {
7171
await RSCClientRoot(props, undefined, mockDomNodeId);
7272
});
73+
};
7374

7475
return {
7576
render,
@@ -87,7 +88,7 @@ enableFetchMocks();
8788

8889
await act(async () => {
8990
pushFirstChunk();
90-
render();
91+
await render();
9192
});
9293
expect(window.fetch).toHaveBeenCalledWith('/rsc-render/TestComponent?props=undefined');
9394
expect(window.fetch).toHaveBeenCalledTimes(1);
@@ -108,7 +109,7 @@ enableFetchMocks();
108109
const { render, pushFirstChunk, pushSecondChunk, endStream } = await mockRSCRequest();
109110

110111
await act(async () => {
111-
render();
112+
await render();
112113
pushFirstChunk();
113114
});
114115
expect(consoleSpy).toHaveBeenCalledWith(
@@ -138,7 +139,7 @@ enableFetchMocks();
138139
const { render, pushFirstChunk, pushSecondChunk, endStream } = await mockRSCRequest('/rsc-render/');
139140

140141
await act(async () => {
141-
render();
142+
await render();
142143
pushFirstChunk();
143144
pushSecondChunk();
144145
endStream();

0 commit comments

Comments
 (0)