From 343c2ea9bf03bc70361280765055814edb8e4f3f Mon Sep 17 00:00:00 2001 From: Giancarmine Salucci Date: Wed, 8 Jul 2026 00:46:12 +0200 Subject: [PATCH] fix: suppress unhandled rejections in retryWithBackoff failure tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add .catch(() => {}) before vi.runAllTimersAsync() on 3 tests that test the rejection path — prevents vitest exit code 1 (CI/CD gate) while still allowing .rejects assertion to work. --- src/tests/retry.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tests/retry.test.ts b/src/tests/retry.test.ts index 742d44f..5a3d461 100644 --- a/src/tests/retry.test.ts +++ b/src/tests/retry.test.ts @@ -37,6 +37,7 @@ describe('retryWithBackoff', () => { const fn = vi.fn().mockRejectedValue(error); const promise = retryWithBackoff(fn, { maxAttempts: 3, baseDelayMs: 10 }); + promise.catch(() => {}); await vi.runAllTimersAsync(); await expect(promise).rejects.toThrow('persistent failure'); expect(fn).toHaveBeenCalledTimes(3); @@ -102,6 +103,7 @@ describe('retryWithBackoff', () => { baseDelayMs: 100, onAttempt }); + promise.catch(() => {}); await vi.runAllTimersAsync(); await expect(promise).rejects.toThrow('always fail'); expect(fn).toHaveBeenCalledTimes(4); @@ -119,6 +121,7 @@ describe('retryWithBackoff', () => { it('defaults to 3 maxAttempts', async () => { const fn = vi.fn().mockRejectedValue(new Error('fail')); const promise = retryWithBackoff(fn, { baseDelayMs: 10 }); + promise.catch(() => {}); await vi.runAllTimersAsync(); await expect(promise).rejects.toThrow('fail'); expect(fn).toHaveBeenCalledTimes(3);