






















@@ -63,6 +63,16 @@ async function waitForSpawnCount(count: number) {
6363await Promise.resolve();
6464}
656566+function firstSpawnCall(): unknown[] | undefined {
67+return spawnMock.mock.calls[0];
68+}
69+70+function firstGatewayCall(
71+gatewayCall: ReturnType<typeof vi.fn>,
72+): [string, unknown, unknown] | undefined {
73+return gatewayCall.mock.calls[0] as [string, unknown, unknown] | undefined;
74+}
75+6676describe("qa suite runtime agent process helpers", () => {
6777beforeEach(() => {
6878spawnMock.mockReset();
@@ -94,7 +104,7 @@ describe("qa suite runtime agent process helpers", () => {
94104child.emit("exit", 0);
9510596106await expect(pending).resolves.toBe("ok");
97-const spawnCall = spawnMock.mock.calls.at(0);
107+const spawnCall = firstSpawnCall();
98108expect(spawnCall?.[0]).toBe("/usr/bin/node");
99109expect(spawnCall?.[1]).toEqual([path.join("/repo", "dist", "index.js"), "qa", "suite"]);
100110expect((spawnCall?.[2] as { cwd?: string; env?: unknown } | undefined)?.cwd).toBe(
@@ -132,7 +142,7 @@ describe("qa suite runtime agent process helpers", () => {
132142child.emit("exit", 0);
133143134144await expect(pending).resolves.toBe("ok");
135-const spawnCall = spawnMock.mock.calls.at(0);
145+const spawnCall = firstSpawnCall();
136146expect(spawnCall?.[0]).toBe("/usr/bin/node");
137147expect(spawnCall?.[1]).toEqual([
138148path.join("/repo", "dist", "index.js"),
@@ -253,9 +263,7 @@ describe("qa suite runtime agent process helpers", () => {
253263message: "hello",
254264}),
255265).resolves.toEqual({ runId: "run-1" });
256-const gatewayArgs = gatewayCall.mock.calls.at(0) as unknown as
257-| [string, unknown, unknown]
258-| undefined;
266+const gatewayArgs = firstGatewayCall(gatewayCall);
259267expect(gatewayArgs?.[0]).toBe("agent");
260268const agentPayload = gatewayArgs?.[1] as
261269| {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。