Skip to content

Commit c277c36

Browse files
committed
feat: add retry logic for transient axios errors in uploadCoverageFiles test
1 parent b34560c commit c277c36

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

src/__tests__/uploader.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,31 @@ describe('uploader', () => {
182182
expect(mockCore.warning).toHaveBeenCalledTimes(2);
183183
});
184184

185+
it('should retry on transient axios errors and log warning with axios message', async () => {
186+
const options: UploadOptions = {
187+
...baseOptions,
188+
files: [{ path: testFile, format: 'cobertura' }],
189+
};
190+
191+
// Create an axios error with a 500 status (retryable)
192+
const axiosError = {
193+
response: { status: 500, data: 'Internal Server Error' },
194+
message: 'Request failed with status code 500',
195+
isAxiosError: true,
196+
};
197+
mockAxiosPost
198+
.mockRejectedValueOnce(axiosError)
199+
.mockResolvedValueOnce({ status: 200, data: {} } as AxiosResponse);
200+
mockIsAxiosError.mockReturnValue(true);
201+
202+
await uploadCoverageFiles(options);
203+
204+
expect(mockAxiosPost).toHaveBeenCalledTimes(2);
205+
expect(mockCore.warning).toHaveBeenCalledWith(
206+
'Upload attempt 1/3 failed: Request failed with status code 500'
207+
);
208+
});
209+
185210
it('should fail immediately on 400 error', async () => {
186211
const options: UploadOptions = {
187212
...baseOptions,

0 commit comments

Comments
 (0)