Skip to content

Commit 8e4a340

Browse files
committed
test: I'm sick of this flaky test
1 parent 388bc25 commit 8e4a340

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/react-query/src/__tests__/useMutationState.test.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,19 @@ describe('useIsMutating', () => {
5959
fireEvent.click(rendered.getByRole('button', { name: /mutate1/i }))
6060
await sleep(10)
6161
fireEvent.click(rendered.getByRole('button', { name: /mutate2/i }))
62-
await waitFor(() => expect(isMutatingArray).toEqual([0, 1, 2, 1, 0]))
62+
63+
// we don't really care if this yields
64+
// [ +0, 1, 2, +0 ]
65+
// or
66+
// [ +0, 1, 2, 1, +0 ]
67+
// our batching strategy might yield different results
68+
69+
await waitFor(() => expect(isMutatingArray[0]).toEqual(0))
70+
await waitFor(() => expect(isMutatingArray[1]).toEqual(1))
71+
await waitFor(() => expect(isMutatingArray[2]).toEqual(2))
72+
await waitFor(() =>
73+
expect(isMutatingArray[isMutatingArray.length - 1]).toEqual(0),
74+
)
6375
})
6476

6577
it('should filter correctly by mutationKey', async () => {

0 commit comments

Comments
 (0)