diff --git a/src/infra/outbound/deliver.lifecycle.test.ts b/src/infra/outbound/deliver.lifecycle.test.ts index c8ce22b826b..dd32b1648d8 100644 --- a/src/infra/outbound/deliver.lifecycle.test.ts +++ b/src/infra/outbound/deliver.lifecycle.test.ts @@ -1,4 +1,4 @@ -import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import type { OpenClawConfig } from "../../config/config.js"; import { setActivePluginRegistry } from "../../plugins/runtime.js"; import { createOutboundTestPlugin, createTestRegistry } from "../../test-utils/channel-plugins.js"; @@ -77,9 +77,11 @@ function expectSuccessfulWhatsAppInternalHookPayload( } describe("deliverOutboundPayloads lifecycle", () => { - beforeEach(async () => { - vi.resetModules(); + beforeAll(async () => { ({ deliverOutboundPayloads } = await import("./deliver.js")); + }); + + beforeEach(() => { resetDeliverTestState(); resetDeliverTestMocks({ includeSessionMocks: true }); }); diff --git a/src/tts/tts.test.ts b/src/tts/tts.test.ts index ade83c0b30a..6aa74cc29fe 100644 --- a/src/tts/tts.test.ts +++ b/src/tts/tts.test.ts @@ -1,5 +1,5 @@ import { completeSimple, type AssistantMessage } from "@mariozechner/pi-ai"; -import { describe, expect, it, vi, beforeEach } from "vitest"; +import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { ensureCustomApiRegistered } from "../agents/custom-api-registry.js"; import { getApiKeyForModel } from "../agents/model-auth.js"; import { resolveModelAsync } from "../agents/pi-embedded-runner/model.js"; @@ -374,8 +374,7 @@ describe("tts", () => { messages: { tts: {} }, }; - beforeEach(async () => { - vi.resetModules(); + beforeAll(async () => { ({ completeSimple: completeSimpleForTest } = await import("@mariozechner/pi-ai")); ({ getApiKeyForModel: getApiKeyForModelForTest } = await import("../agents/model-auth.js")); ({ resolveModelAsync: resolveModelAsyncForTest } = @@ -385,6 +384,9 @@ describe("tts", () => { const ttsModule = await import("./tts.js"); summarizeTextForTest = ttsModule._test.summarizeText; resolveTtsConfigForTest = ttsModule.resolveTtsConfig; + }); + + beforeEach(() => { vi.mocked(completeSimpleForTest).mockResolvedValue( mockAssistantMessage([{ type: "text", text: "Summary" }]), );