fix: suppress unhandled rejections in retryWithBackoff failure tests
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.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user