test(finalize): use expect.poll vs waitFor

This commit is contained in:
Artem Zakharchenko
2026-07-07 21:29:32 +02:00
parent f97f3bc4ca
commit bbafd21dae
+3 -7
View File
@@ -172,9 +172,7 @@ it('runs immediately when scheduled after the request has been aborted', async (
controller.abort()
await expect(responsePromise).rejects.toThrow()
await vi.waitFor(() => {
expect(cleanup).toHaveBeenCalledOnce()
})
await expect.poll(() => cleanup).toHaveBeenCalledOnce()
})
it('runs cleanups scheduled after the abort listener has fired', async () => {
@@ -203,10 +201,8 @@ it('runs cleanups scheduled after the abort listener has fired', async () => {
controller.abort()
await expect(responsePromise).rejects.toThrow()
await vi.waitFor(() => {
expect(cleanupBeforeAbort).toHaveBeenCalledOnce()
expect(cleanupAfterAbort).toHaveBeenCalledOnce()
})
await expect.poll(() => cleanupBeforeAbort).toHaveBeenCalledOnce()
await expect.poll(() => cleanupAfterAbort).toHaveBeenCalledOnce()
})
it('runs once the generator resolver is exhausted', async () => {