From aa2475b4be988a09adbd82dabe175022c4a7eac0 Mon Sep 17 00:00:00 2001 From: Nathaniel Tucker Date: Wed, 18 Dec 2024 21:06:09 +0000 Subject: [PATCH] internal: Less chance of test race conditions --- .../src/__tests__/integration-optimistic-endpoint.web.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/react/src/__tests__/integration-optimistic-endpoint.web.tsx b/packages/react/src/__tests__/integration-optimistic-endpoint.web.tsx index 0239500acdc4..971fb52b9135 100644 --- a/packages/react/src/__tests__/integration-optimistic-endpoint.web.tsx +++ b/packages/react/src/__tests__/integration-optimistic-endpoint.web.tsx @@ -462,6 +462,9 @@ describe.each([ ], }, ); + await act(async () => { + await new Promise(resolve => setTimeout(resolve, 0)); + }); const fetches: Promise[] = []; const resolves: ((v: any) => void)[] = []; @@ -493,7 +496,7 @@ describe.each([ }), ); await act(async () => { - await new Promise(resolve => setTimeout(resolve, 0)); + await new Promise(resolve => setTimeout(resolve, 1)); }); // second optimistic @@ -607,6 +610,9 @@ describe.each([ ], }, ); + await act(async () => { + await new Promise(resolve => setTimeout(resolve, 1)); + }); const fetches: Promise[] = []; const resolves: ((v: any) => void)[] = [];