Skip to content

Commit 73441e4

Browse files
authored
Refactor fetch implementation and error handling
1 parent 7774c29 commit 73441e4

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/commands/test.rerun.spec.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { tmpdir } from 'node:os';
1010
import { join } from 'node:path';
1111
import { describe, expect, it } from 'vitest';
1212
import { ApiError, RequestTimeoutError } from '../lib/errors.js';
13-
1413
import type { RunResponse, RerunResponse, BatchRerunResponse } from '../lib/runs.types.js';
1514
import type { FetchImpl } from '../lib/http.js';
1615
import { runTestRerun, resolveWaitRequestTimeoutMs } from './test.js';
@@ -4836,7 +4835,7 @@ describe('[finding-5] batch rerun --wait: RequestTimeoutError during fan-out pol
48364835
closure: { byProject: [] },
48374836
};
48384837

4839-
const fetchImpl = makeFetch(url => {
4838+
const fetchImpl = makeFetch((url) => {
48404839
if (url.includes('/tests/batch/rerun')) {
48414840
return { status: 202, body: batchResp };
48424841
}
@@ -4868,15 +4867,15 @@ describe('[finding-5] batch rerun --wait: RequestTimeoutError during fan-out pol
48684867
stdout: (line) => stdoutLines.push(line),
48694868
stderr: () => undefined,
48704869
},
4871-
).catch(e => e);
4870+
).catch((e) => e);
48724871

48734872
expect(err).toMatchObject({ exitCode: 7 });
48744873
const parsed = JSON.parse(stdoutLines.join('\n')) as {
48754874
accepted: Array<{ testId: string; runId: string; status: string }>;
48764875
};
48774876
expect(parsed.accepted).toHaveLength(2);
4878-
expect(parsed.accepted.map(r => r.runId).sort()).toEqual(['run_b1', 'run_b2']);
4879-
expect(parsed.accepted.every(r => r.status === 'timeout')).toBe(true);
4877+
expect(parsed.accepted.map((r) => r.runId).sort()).toEqual(['run_b1', 'run_b2']);
4878+
expect(parsed.accepted.every((r) => r.status === 'timeout')).toBe(true);
48804879
});
48814880
});
48824881

@@ -4939,10 +4938,10 @@ describe('[finding-4] single FE rerun --wait: TimeoutError writes partial JSON t
49394938
...creds,
49404939
sleep: instantSleep,
49414940
fetchImpl: fetchImpl as unknown as FetchImpl,
4942-
stdout: line => stdoutLines.push(line),
4941+
stdout: (line) => stdoutLines.push(line),
49434942
stderr: () => undefined,
49444943
},
4945-
).catch(e => e);
4944+
).catch((e) => e);
49464945

49474946
expect(err).toMatchObject({ exitCode: 7 });
49484947
expect(stdoutLines.length).toBeGreaterThan(0);

0 commit comments

Comments
 (0)