Skip to content

Commit d0bea3f

Browse files
sukvvonmanudeli
andauthored
test(query-core/mutationCache): remove 'vi.waitFor' and add 'advanceTimersByTimeAsync' (#9339)
Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
1 parent 998be8b commit d0bea3f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

packages/query-core/src/__tests__/mutationCache.test.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,8 @@ describe('mutationCache', () => {
310310
1,
311311
)
312312
expect(testCache.getAll()).toHaveLength(1)
313-
await vi.waitFor(() => {
314-
expect(testCache.getAll()).toHaveLength(0)
315-
})
313+
await vi.advanceTimersByTimeAsync(10)
314+
expect(testCache.getAll()).toHaveLength(0)
316315
expect(onSuccess).toHaveBeenCalledTimes(1)
317316
})
318317

@@ -376,9 +375,8 @@ describe('mutationCache', () => {
376375
const unsubscribe = observer.subscribe(() => undefined)
377376
observer.mutate(1)
378377
unsubscribe()
379-
await vi.waitFor(() => {
380-
expect(queryClient.getMutationCache().getAll()).toHaveLength(0)
381-
})
378+
await vi.advanceTimersByTimeAsync(0)
379+
expect(queryClient.getMutationCache().getAll()).toHaveLength(0)
382380
expect(onSuccess).toHaveBeenCalledTimes(1)
383381
})
384382
})

0 commit comments

Comments
 (0)