perf(test): replace claude runner call polling loop

This commit is contained in:
Peter Steinberger
2026-02-18 17:51:38 +00:00
parent a82ceb81d2
commit c68d1073b5

View File

@@ -1,5 +1,4 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { sleep } from "../utils.js";
import { runClaudeCliAgent } from "./claude-cli-runner.js";
const mocks = vi.hoisted(() => ({
@@ -65,13 +64,12 @@ function successExit(payload: { message: string; session_id: string }) {
}
async function waitForCalls(mockFn: { mock: { calls: unknown[][] } }, count: number) {
for (let i = 0; i < 50; i += 1) {
if (mockFn.mock.calls.length >= count) {
return;
}
await sleep(0);
}
throw new Error(`Expected ${count} calls, got ${mockFn.mock.calls.length}`);
await vi.waitFor(
() => {
expect(mockFn.mock.calls.length).toBeGreaterThanOrEqual(count);
},
{ timeout: 2_000, interval: 5 },
);
}
describe("runClaudeCliAgent", () => {