diff --git a/src/entry.respawn.test.ts b/src/entry.respawn.test.ts index adcd7c3d1d8..fe8d29f5c9a 100644 --- a/src/entry.respawn.test.ts +++ b/src/entry.respawn.test.ts @@ -19,6 +19,14 @@ function expectCliRespawnPlan(plan: ReturnType): Cli return plan; } +function requireFirstMockCall(mock: { mock: { calls: unknown[][] } }, label: string): unknown[] { + const [call] = mock.mock.calls; + if (!call) { + throw new Error(`expected ${label} call`); + } + return call; +} + describe("buildCliRespawnPlan", () => { it("returns null when respawn policy skips the argv", () => { expect( @@ -185,9 +193,12 @@ describe("runCliRespawnPlan", () => { env: { OPENCLAW_NODE_OPTIONS_READY: "1" }, }, ); - expect(attachChildProcessBridge.mock.calls[0]?.[0]).toBe(child); - const bridgeOptions = attachChildProcessBridge.mock.calls[0]?.[1]; - expect(typeof bridgeOptions?.onSignal).toBe("function"); + const [bridgeChild, bridgeOptions] = requireFirstMockCall( + attachChildProcessBridge, + "child process bridge attach", + ); + expect(bridgeChild).toBe(child); + expect(bridgeOptions).toEqual(expect.objectContaining({ onSignal: expect.any(Function) })); child.emit("exit", 0, null); diff --git a/src/image-generation/openai-compatible-image-provider.test.ts b/src/image-generation/openai-compatible-image-provider.test.ts index 1379429f0c2..bf67729b7d8 100644 --- a/src/image-generation/openai-compatible-image-provider.test.ts +++ b/src/image-generation/openai-compatible-image-provider.test.ts @@ -61,7 +61,11 @@ vi.mock("openclaw/plugin-sdk/provider-http", () => ({ })); function requireFirstRequestHeaders(mock: ReturnType): Headers { - const [request] = (mock.mock.calls[0] ?? []) as [{ headers?: Headers }?]; + const [call] = mock.mock.calls; + if (!call) { + throw new Error("expected request call"); + } + const [request] = call as [{ headers?: Headers }]; if (!request) { throw new Error("expected request call"); }