From 8a0a28763e12b4bc57576f90abc0e61d92c6a3ca Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 22 Feb 2026 08:22:52 +0000 Subject: [PATCH] test(core): reduce mock reset overhead across unit and e2e specs --- src/agents/openclaw-tools.camera.e2e.test.ts | 2 +- src/agents/sandbox/fs-bridge.test.ts | 2 +- src/agents/sessions-spawn-threadid.e2e.test.ts | 2 +- src/agents/subagent-registry-completion.test.ts | 2 +- src/agents/subagent-registry.announce-loop-guard.test.ts | 2 +- src/agents/tools/agent-step.test.ts | 2 +- src/agents/tools/cron-tool.flat-params.test.ts | 2 +- src/browser/client-fetch.loopback-auth.test.ts | 2 +- .../register.invoke.nodes-run-approval-timeout.test.ts | 2 +- .../bundled/boot-md/handler.gateway-startup.integration.test.ts | 2 +- src/hooks/gmail-watcher-lifecycle.test.ts | 2 +- src/media-understanding/apply.e2e.test.ts | 2 +- src/memory/manager.async-search.test.ts | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/agents/openclaw-tools.camera.e2e.test.ts b/src/agents/openclaw-tools.camera.e2e.test.ts index 7524b4f7a..fb927d338 100644 --- a/src/agents/openclaw-tools.camera.e2e.test.ts +++ b/src/agents/openclaw-tools.camera.e2e.test.ts @@ -39,7 +39,7 @@ function mockNodeList(commands?: string[]) { } beforeEach(() => { - callGateway.mockReset(); + callGateway.mockClear(); }); describe("nodes camera_snap", () => { diff --git a/src/agents/sandbox/fs-bridge.test.ts b/src/agents/sandbox/fs-bridge.test.ts index 7dba40951..56fbdb8ee 100644 --- a/src/agents/sandbox/fs-bridge.test.ts +++ b/src/agents/sandbox/fs-bridge.test.ts @@ -26,7 +26,7 @@ function createSandbox(overrides?: Partial): SandboxContext { describe("sandbox fs bridge shell compatibility", () => { beforeEach(() => { - mockedExecDockerRaw.mockReset(); + mockedExecDockerRaw.mockClear(); mockedExecDockerRaw.mockImplementation(async (args) => { const script = args[5] ?? ""; if (script.includes('stat -c "%F|%s|%Y"')) { diff --git a/src/agents/sessions-spawn-threadid.e2e.test.ts b/src/agents/sessions-spawn-threadid.e2e.test.ts index 9dd46adda..832b106f1 100644 --- a/src/agents/sessions-spawn-threadid.e2e.test.ts +++ b/src/agents/sessions-spawn-threadid.e2e.test.ts @@ -32,7 +32,7 @@ describe("sessions_spawn requesterOrigin threading", () => { beforeEach(() => { const callGatewayMock = getCallGatewayMock(); resetSubagentRegistryForTests(); - callGatewayMock.mockReset(); + callGatewayMock.mockClear(); setSessionsSpawnConfigOverride({ session: { mainKey: "main", diff --git a/src/agents/subagent-registry-completion.test.ts b/src/agents/subagent-registry-completion.test.ts index 4c3faa771..3f003aa20 100644 --- a/src/agents/subagent-registry-completion.test.ts +++ b/src/agents/subagent-registry-completion.test.ts @@ -42,7 +42,7 @@ describe("emitSubagentEndedHookOnce", () => { }; beforeEach(() => { - lifecycleMocks.getGlobalHookRunner.mockReset(); + lifecycleMocks.getGlobalHookRunner.mockClear(); lifecycleMocks.runSubagentEnded.mockClear(); }); diff --git a/src/agents/subagent-registry.announce-loop-guard.test.ts b/src/agents/subagent-registry.announce-loop-guard.test.ts index 9c2545228..5a2bfb2db 100644 --- a/src/agents/subagent-registry.announce-loop-guard.test.ts +++ b/src/agents/subagent-registry.announce-loop-guard.test.ts @@ -70,7 +70,7 @@ describe("announce loop guard (#18264)", () => { afterEach(() => { vi.useRealTimers(); - loadSubagentRegistryFromDisk.mockReset(); + loadSubagentRegistryFromDisk.mockClear(); loadSubagentRegistryFromDisk.mockReturnValue(new Map()); saveSubagentRegistryToDisk.mockClear(); vi.clearAllMocks(); diff --git a/src/agents/tools/agent-step.test.ts b/src/agents/tools/agent-step.test.ts index d83feb5aa..2ba291c32 100644 --- a/src/agents/tools/agent-step.test.ts +++ b/src/agents/tools/agent-step.test.ts @@ -9,7 +9,7 @@ import { readLatestAssistantReply } from "./agent-step.js"; describe("readLatestAssistantReply", () => { beforeEach(() => { - callGatewayMock.mockReset(); + callGatewayMock.mockClear(); }); it("returns the most recent assistant message when compaction markers trail history", async () => { diff --git a/src/agents/tools/cron-tool.flat-params.test.ts b/src/agents/tools/cron-tool.flat-params.test.ts index 627a65e1b..8d2688ffc 100644 --- a/src/agents/tools/cron-tool.flat-params.test.ts +++ b/src/agents/tools/cron-tool.flat-params.test.ts @@ -12,7 +12,7 @@ import { createCronTool } from "./cron-tool.js"; describe("cron tool flat-params", () => { beforeEach(() => { - callGatewayToolMock.mockReset(); + callGatewayToolMock.mockClear(); callGatewayToolMock.mockResolvedValue({ ok: true }); }); diff --git a/src/browser/client-fetch.loopback-auth.test.ts b/src/browser/client-fetch.loopback-auth.test.ts index 209f87d9f..4a0f79dda 100644 --- a/src/browser/client-fetch.loopback-auth.test.ts +++ b/src/browser/client-fetch.loopback-auth.test.ts @@ -46,7 +46,7 @@ function stubJsonFetchOk() { describe("fetchBrowserJson loopback auth", () => { beforeEach(() => { vi.restoreAllMocks(); - mocks.loadConfig.mockReset(); + mocks.loadConfig.mockClear(); mocks.loadConfig.mockReturnValue({ gateway: { auth: { diff --git a/src/cli/nodes-cli/register.invoke.nodes-run-approval-timeout.test.ts b/src/cli/nodes-cli/register.invoke.nodes-run-approval-timeout.test.ts index c8c870a31..f297f72c1 100644 --- a/src/cli/nodes-cli/register.invoke.nodes-run-approval-timeout.test.ts +++ b/src/cli/nodes-cli/register.invoke.nodes-run-approval-timeout.test.ts @@ -40,7 +40,7 @@ describe("nodes run: approval transport timeout (#12098)", () => { }); beforeEach(() => { - callGatewaySpy.mockReset(); + callGatewaySpy.mockClear(); callGatewaySpy.mockResolvedValue({ decision: "allow-once" }); }); diff --git a/src/hooks/bundled/boot-md/handler.gateway-startup.integration.test.ts b/src/hooks/bundled/boot-md/handler.gateway-startup.integration.test.ts index 0bd0f264a..7875bd04a 100644 --- a/src/hooks/bundled/boot-md/handler.gateway-startup.integration.test.ts +++ b/src/hooks/bundled/boot-md/handler.gateway-startup.integration.test.ts @@ -19,7 +19,7 @@ const { clearInternalHooks, createInternalHookEvent, registerInternalHook, trigg describe("boot-md startup hook integration", () => { beforeEach(() => { - runBootOnce.mockReset(); + runBootOnce.mockClear(); clearInternalHooks(); }); diff --git a/src/hooks/gmail-watcher-lifecycle.test.ts b/src/hooks/gmail-watcher-lifecycle.test.ts index 9e049a430..debe8de21 100644 --- a/src/hooks/gmail-watcher-lifecycle.test.ts +++ b/src/hooks/gmail-watcher-lifecycle.test.ts @@ -18,7 +18,7 @@ describe("startGmailWatcherWithLogs", () => { }; beforeEach(() => { - startGmailWatcherMock.mockReset(); + startGmailWatcherMock.mockClear(); log.info.mockClear(); log.warn.mockClear(); log.error.mockClear(); diff --git a/src/media-understanding/apply.e2e.test.ts b/src/media-understanding/apply.e2e.test.ts index 018e84cd3..64502eb62 100644 --- a/src/media-understanding/apply.e2e.test.ts +++ b/src/media-understanding/apply.e2e.test.ts @@ -141,7 +141,7 @@ describe("applyMediaUnderstanding", () => { beforeEach(() => { mockedResolveApiKey.mockClear(); - mockedFetchRemoteMedia.mockReset(); + mockedFetchRemoteMedia.mockClear(); mockedFetchRemoteMedia.mockResolvedValue({ buffer: Buffer.from([0, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]), contentType: "audio/ogg", diff --git a/src/memory/manager.async-search.test.ts b/src/memory/manager.async-search.test.ts index ef26fc394..aad2777e2 100644 --- a/src/memory/manager.async-search.test.ts +++ b/src/memory/manager.async-search.test.ts @@ -42,7 +42,7 @@ describe("memory search async sync", () => { }) as OpenClawConfig; beforeEach(async () => { - embedBatch.mockReset(); + embedBatch.mockClear(); embedBatch.mockImplementation(async (input: string[]) => input.map(() => [0.2, 0.2, 0.2])); workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-mem-async-")); indexPath = path.join(workspaceDir, "index.sqlite");