diff --git a/src/agents/channel-tools.test.ts b/src/agents/channel-tools.test.ts index 5686f46aa4a..0fc07f72dad 100644 --- a/src/agents/channel-tools.test.ts +++ b/src/agents/channel-tools.test.ts @@ -42,7 +42,6 @@ describe("channel tools", () => { afterEach(() => { setActivePluginRegistry(createTestRegistry([])); - errorSpy.mockClear(); }); it("skips crashing plugins and logs once", () => { diff --git a/src/agents/live-model-switch.test.ts b/src/agents/live-model-switch.test.ts index 3dbbde9070e..dbedb9a8d6e 100644 --- a/src/agents/live-model-switch.test.ts +++ b/src/agents/live-model-switch.test.ts @@ -1,4 +1,4 @@ -import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { beforeEach, describe, expect, it, vi } from "vitest"; import { importFreshModule } from "../../test/helpers/import-fresh.js"; const state = vi.hoisted(() => ({ @@ -49,11 +49,6 @@ describe("live model switch", () => { state.loadSessionStoreMock.mockReset().mockReturnValue({}); state.resolveStorePathMock.mockReset().mockReturnValue("/tmp/session-store.json"); }); - - afterEach(() => { - vi.clearAllMocks(); - }); - it("resolves persisted session overrides ahead of agent defaults", async () => { state.loadSessionStoreMock.mockReturnValue({ main: { diff --git a/src/agents/subagent-registry.announce-loop-guard.test.ts b/src/agents/subagent-registry.announce-loop-guard.test.ts index 3c2ee076c34..3367c984a84 100644 --- a/src/agents/subagent-registry.announce-loop-guard.test.ts +++ b/src/agents/subagent-registry.announce-loop-guard.test.ts @@ -115,9 +115,7 @@ describe("announce loop guard (#18264)", () => { afterEach(() => { vi.useRealTimers(); - loadSubagentRegistryFromDisk.mockClear(); loadSubagentRegistryFromDisk.mockReturnValue(new Map()); - saveSubagentRegistryToDisk.mockClear(); vi.clearAllMocks(); }); diff --git a/src/cli/devices-cli.test.ts b/src/cli/devices-cli.test.ts index 657be89ed92..ea67a249dbb 100644 --- a/src/cli/devices-cli.test.ts +++ b/src/cli/devices-cli.test.ts @@ -28,7 +28,6 @@ const { listDevicePairing, approveDevicePairing, summarizeDeviceTokens, - withProgress, } = mocks; vi.mock("../gateway/call.js", () => ({ @@ -337,20 +336,12 @@ beforeEach(() => { }); afterEach(() => { - buildGatewayConnectionDetails.mockClear(); buildGatewayConnectionDetails.mockReturnValue({ url: "ws://127.0.0.1:18789", urlSource: "local loopback", message: "", }); - listDevicePairing.mockClear(); listDevicePairing.mockResolvedValue({ pending: [], paired: [] }); - approveDevicePairing.mockClear(); approveDevicePairing.mockResolvedValue(undefined); - summarizeDeviceTokens.mockClear(); summarizeDeviceTokens.mockReturnValue(undefined); - withProgress.mockClear(); - runtime.log.mockClear(); - runtime.error.mockClear(); - runtime.exit.mockClear(); }); diff --git a/src/commands/onboard-non-interactive.provider-auth.test.ts b/src/commands/onboard-non-interactive.provider-auth.test.ts index 85524056118..8328659b6b6 100644 --- a/src/commands/onboard-non-interactive.provider-auth.test.ts +++ b/src/commands/onboard-non-interactive.provider-auth.test.ts @@ -887,7 +887,6 @@ describe("onboard (non-interactive): provider auth", () => { resetFileLockStateForTest(); clearPluginDiscoveryCache(); clearPluginManifestRegistryCache(); - ensureWorkspaceAndSessionsMock.mockClear(); }); it("stores MiniMax API key in the global auth profile", async () => { diff --git a/src/image-generation/provider-registry.test.ts b/src/image-generation/provider-registry.test.ts index a7c41175aa0..ceca9e374a6 100644 --- a/src/image-generation/provider-registry.test.ts +++ b/src/image-generation/provider-registry.test.ts @@ -1,4 +1,4 @@ -import { afterEach, beforeAll, describe, expect, it, vi } from "vitest"; +import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { createEmptyPluginRegistry } from "../plugins/registry.js"; const { resolveRuntimePluginRegistryMock } = vi.hoisted(() => ({ @@ -20,7 +20,7 @@ describe("image-generation provider registry", () => { await import("./provider-registry.js")); }); - afterEach(() => { + beforeEach(() => { resolveRuntimePluginRegistryMock.mockReset(); resolveRuntimePluginRegistryMock.mockReturnValue(undefined); }); diff --git a/src/image-generation/runtime.test.ts b/src/image-generation/runtime.test.ts index 89b42716f8d..f7f37400596 100644 --- a/src/image-generation/runtime.test.ts +++ b/src/image-generation/runtime.test.ts @@ -28,13 +28,13 @@ describe("image-generation runtime helpers", () => { ({ generateImage, listRuntimeImageGenerationProviders } = await import("./runtime.js")); }); - afterEach(() => { + beforeEach(() => { resolveRuntimePluginRegistryMock.mockReset(); resolveRuntimePluginRegistryMock.mockReturnValue(undefined); resetPluginRuntimeStateForTest(); }); - beforeEach(() => { + afterEach(() => { resetPluginRuntimeStateForTest(); }); diff --git a/src/infra/gaxios-fetch-compat.test.ts b/src/infra/gaxios-fetch-compat.test.ts index 692547bafa7..60934c040f0 100644 --- a/src/infra/gaxios-fetch-compat.test.ts +++ b/src/infra/gaxios-fetch-compat.test.ts @@ -23,7 +23,6 @@ beforeEach(() => { describe("gaxios fetch compat", () => { afterEach(() => { - vi.doUnmock("undici"); Reflect.deleteProperty(globalThis as object, TEST_GAXIOS_CONSTRUCTOR_OVERRIDE); __testing.resetGaxiosFetchCompatForTests(); vi.restoreAllMocks(); diff --git a/src/infra/heartbeat-runner.model-override.test.ts b/src/infra/heartbeat-runner.model-override.test.ts index ec5e8cd983c..e7259c6f2b8 100644 --- a/src/infra/heartbeat-runner.model-override.test.ts +++ b/src/infra/heartbeat-runner.model-override.test.ts @@ -1,4 +1,4 @@ -import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { afterEach, describe, expect, it, vi } from "vitest"; import * as replyModule from "../auto-reply/reply.js"; import type { OpenClawConfig } from "../config/config.js"; import { resolveAgentMainSessionKey, resolveMainSessionKey } from "../config/sessions.js"; @@ -38,8 +38,6 @@ async function withHeartbeatFixture( ); } -beforeEach(() => {}); - afterEach(() => { vi.restoreAllMocks(); }); diff --git a/src/infra/windows-task-restart.test.ts b/src/infra/windows-task-restart.test.ts index 8db63418825..a800b3ebeee 100644 --- a/src/infra/windows-task-restart.test.ts +++ b/src/infra/windows-task-restart.test.ts @@ -31,9 +31,6 @@ function decodeCmdPathArg(value: string): string { afterEach(() => { envSnapshot.restore(); - spawnMock.mockReset(); - resolvePreferredOpenClawTmpDirMock.mockReset(); - resolvePreferredOpenClawTmpDirMock.mockReturnValue(os.tmpdir()); for (const scriptPath of createdScriptPaths) { try { fs.unlinkSync(scriptPath); diff --git a/src/plugins/wired-hooks-compaction.test.ts b/src/plugins/wired-hooks-compaction.test.ts index 52c6c6ca3dd..3268d1200a5 100644 --- a/src/plugins/wired-hooks-compaction.test.ts +++ b/src/plugins/wired-hooks-compaction.test.ts @@ -18,13 +18,6 @@ describe("compaction hook wiring", () => { let handleAutoCompactionEnd: typeof import("../agents/pi-embedded-subscribe.handlers.compaction.js").handleAutoCompactionEnd; beforeAll(async () => { - hookMocks.runner.hasHooks.mockClear(); - hookMocks.runner.hasHooks.mockReturnValue(false); - hookMocks.runner.runBeforeCompaction.mockClear(); - hookMocks.runner.runBeforeCompaction.mockResolvedValue(undefined); - hookMocks.runner.runAfterCompaction.mockClear(); - hookMocks.runner.runAfterCompaction.mockResolvedValue(undefined); - hookMocks.emitAgentEvent.mockClear(); vi.doMock("../plugins/hook-runner-global.js", () => ({ getGlobalHookRunner: () => hookMocks.runner, })); diff --git a/src/secrets/runtime.test.ts b/src/secrets/runtime.test.ts index 12173f076f9..feab1cfcc47 100644 --- a/src/secrets/runtime.test.ts +++ b/src/secrets/runtime.test.ts @@ -140,8 +140,6 @@ describe("secrets runtime snapshot", () => { clearSecretsRuntimeSnapshot(); clearRuntimeConfigSnapshot(); clearConfigCache(); - resolveBundledPluginWebSearchProvidersMock.mockReset(); - resolvePluginWebSearchProvidersMock.mockReset(); }); it("resolves env refs for config and auth profiles", async () => { diff --git a/src/tasks/task-flow-owner-access.test.ts b/src/tasks/task-flow-owner-access.test.ts index 6112ed3f575..2f8edbaa5d5 100644 --- a/src/tasks/task-flow-owner-access.test.ts +++ b/src/tasks/task-flow-owner-access.test.ts @@ -1,4 +1,4 @@ -import { afterEach, beforeEach, describe, expect, it } from "vitest"; +import { beforeEach, describe, expect, it } from "vitest"; import { findLatestTaskFlowForOwner, getTaskFlowByIdForOwner, @@ -10,11 +10,6 @@ import { createManagedTaskFlow, resetTaskFlowRegistryForTests } from "./task-flo beforeEach(() => { resetTaskFlowRegistryForTests(); }); - -afterEach(() => { - resetTaskFlowRegistryForTests(); -}); - describe("task flow owner access", () => { it("returns owner-scoped flows for direct and owner-key lookups", () => { const older = createManagedTaskFlow({ diff --git a/src/tts/provider-registry.test.ts b/src/tts/provider-registry.test.ts index 74f4f9f22a3..6bb4323d146 100644 --- a/src/tts/provider-registry.test.ts +++ b/src/tts/provider-registry.test.ts @@ -1,4 +1,4 @@ -import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; +import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import type { OpenClawConfig } from "../config/config.js"; import { createEmptyPluginRegistry } from "../plugins/registry-empty.js"; import type { SpeechProviderPlugin } from "../plugins/types.js"; @@ -44,9 +44,6 @@ describe("speech provider registry", () => { resolveRuntimePluginRegistryMock.mockReset(); resolveRuntimePluginRegistryMock.mockReturnValue(undefined); }); - - afterEach(() => {}); - it("uses active plugin speech providers without reloading plugins", () => { resolveRuntimePluginRegistryMock.mockReturnValue({ ...createEmptyPluginRegistry(),