diff --git a/test/setup.ts b/test/setup.ts index f9f4d3ff74..bb400a31e8 100644 --- a/test/setup.ts +++ b/test/setup.ts @@ -16,15 +16,21 @@ import type { } from "../src/channels/plugins/types.js"; import type { OpenClawConfig } from "../src/config/config.js"; import type { OutboundSendDeps } from "../src/infra/outbound/deliver.js"; -import { installProcessWarningFilter } from "../src/infra/warning-filter.js"; -import { setActivePluginRegistry } from "../src/plugins/runtime.js"; -import { createTestRegistry } from "../src/test-utils/channel-plugins.js"; import { withIsolatedTestHome } from "./test-env.js"; +// Set HOME/state isolation before importing any runtime OpenClaw modules. +const testEnv = withIsolatedTestHome(); +afterAll(() => testEnv.cleanup()); + +const [{ installProcessWarningFilter }, { setActivePluginRegistry }, { createTestRegistry }] = + await Promise.all([ + import("../src/infra/warning-filter.js"), + import("../src/plugins/runtime.js"), + import("../src/test-utils/channel-plugins.js"), + ]); + installProcessWarningFilter(); -const testEnv = withIsolatedTestHome(); -afterAll(() => testEnv.cleanup()); const pickSendFn = (id: ChannelId, deps?: OutboundSendDeps) => { switch (id) { case "discord":