diff --git a/src/agents/openclaw-tools.subagents.sessions-spawn.mocks.ts b/src/agents/openclaw-tools.subagents.sessions-spawn.mocks.ts index 814d70b477..7a9ad59197 100644 --- a/src/agents/openclaw-tools.subagents.sessions-spawn.mocks.ts +++ b/src/agents/openclaw-tools.subagents.sessions-spawn.mocks.ts @@ -1,6 +1,8 @@ import { vi } from "vitest"; -export const callGatewayMock = vi.fn(); +// Avoid exporting inferred vitest mock types (TS2742 under pnpm + d.ts emit). +export type CallGatewayMock = ((opts: unknown) => unknown) & ReturnType; +export const callGatewayMock: CallGatewayMock = vi.fn() as unknown as CallGatewayMock; vi.mock("../gateway/call.js", () => ({ callGateway: (opts: unknown) => callGatewayMock(opts), })); diff --git a/src/cli/program.nodes-media.e2e.test.ts b/src/cli/program.nodes-media.e2e.test.ts index bcd51af46b..e31f52d406 100644 --- a/src/cli/program.nodes-media.e2e.test.ts +++ b/src/cli/program.nodes-media.e2e.test.ts @@ -5,6 +5,14 @@ import { callGateway, installBaseProgramMocks, runTui, runtime } from "./program installBaseProgramMocks(); +function getFirstRuntimeLogLine(): string { + const first = runtime.log.mock.calls[0]?.[0]; + if (typeof first !== "string") { + throw new Error(`Expected runtime.log first arg to be string, got ${typeof first}`); + } + return first; +} + const IOS_NODE = { nodeId: "ios-node", displayName: "iOS Node", @@ -59,7 +67,7 @@ describe("cli program (nodes media)", () => { .toSorted((a, b) => a.localeCompare(b)); expect(facings).toEqual(["back", "front"]); - const out = String(runtime.log.mock.calls[0]?.[0] ?? ""); + const out = getFirstRuntimeLogLine(); const mediaPaths = out .split("\n") .filter((l) => l.startsWith("MEDIA:")) @@ -132,7 +140,7 @@ describe("cli program (nodes media)", () => { }), ); - const out = String(runtime.log.mock.calls[0]?.[0] ?? ""); + const out = getFirstRuntimeLogLine(); const mediaPath = out.replace(/^MEDIA:/, "").trim(); expect(mediaPath).toMatch(/openclaw-camera-clip-front-.*\.mp4$/); @@ -188,7 +196,7 @@ describe("cli program (nodes media)", () => { }), ); - const out = String(runtime.log.mock.calls[0]?.[0] ?? ""); + const out = getFirstRuntimeLogLine(); const mediaPath = out.replace(/^MEDIA:/, "").trim(); try { @@ -263,7 +271,7 @@ describe("cli program (nodes media)", () => { }), ); - const out = String(runtime.log.mock.calls[0]?.[0] ?? ""); + const out = getFirstRuntimeLogLine(); const mediaPath = out.replace(/^MEDIA:/, "").trim(); try { @@ -356,7 +364,7 @@ describe("cli program (nodes media)", () => { { from: "user" }, ); - const out = String(runtime.log.mock.calls[0]?.[0] ?? ""); + const out = getFirstRuntimeLogLine(); const mediaPath = out.replace(/^MEDIA:/, "").trim(); expect(mediaPath).toMatch(/openclaw-canvas-snapshot-.*\.png$/); @@ -455,7 +463,7 @@ describe("cli program (nodes media)", () => { { from: "user" }, ); - const out = String(runtime.log.mock.calls[0]?.[0] ?? ""); + const out = getFirstRuntimeLogLine(); const mediaPath = out.replace(/^MEDIA:/, "").trim(); expect(mediaPath).toMatch(/openclaw-camera-snap-front-.*\.jpg$/); @@ -504,7 +512,7 @@ describe("cli program (nodes media)", () => { { from: "user" }, ); - const out = String(runtime.log.mock.calls[0]?.[0] ?? ""); + const out = getFirstRuntimeLogLine(); const mediaPath = out.replace(/^MEDIA:/, "").trim(); expect(mediaPath).toMatch(/openclaw-camera-clip-front-.*\.mp4$/); diff --git a/src/cron/service.test-harness.ts b/src/cron/service.test-harness.ts index d111a8c2ea..99c717e3c8 100644 --- a/src/cron/service.test-harness.ts +++ b/src/cron/service.test-harness.ts @@ -3,7 +3,15 @@ import os from "node:os"; import path from "node:path"; import { afterAll, afterEach, beforeAll, beforeEach, vi } from "vitest"; -export function createNoopLogger() { +// Avoid exporting inferred vitest mock types (TS2742 under pnpm + d.ts emit). +export type NoopLogger = { + debug: ReturnType; + info: ReturnType; + warn: ReturnType; + error: ReturnType; +}; + +export function createNoopLogger(): NoopLogger { return { debug: vi.fn(), info: vi.fn(),