test: reload runtime plugins module per test

This commit is contained in:
Peter Steinberger
2026-04-05 06:06:12 +01:00
parent 74416c5b33
commit 058fde2d88
2 changed files with 5 additions and 7 deletions

View File

@@ -8,7 +8,7 @@ const isWin = process.platform === "win32";
const defaultShell = isWin
? undefined
: process.env.OPENCLAW_TEST_SHELL || resolveShellFromPath("bash") || process.env.SHELL || "sh";
const longDelayCmd = isWin ? "Start-Sleep -Milliseconds 72" : "sleep 0.072";
const longDelayCmd = isWin ? "Start-Sleep -Milliseconds 200" : "sleep 0.2";
describe("exec foreground failures", () => {
let envSnapshot: ReturnType<typeof captureEnv>;

View File

@@ -1,4 +1,4 @@
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { beforeEach, describe, expect, it, vi } from "vitest";
const hoisted = vi.hoisted(() => ({
resolveRuntimePluginRegistry: vi.fn(),
@@ -11,13 +11,11 @@ vi.mock("../plugins/loader.js", () => ({
describe("ensureRuntimePluginsLoaded", () => {
let ensureRuntimePluginsLoaded: typeof import("./runtime-plugins.js").ensureRuntimePluginsLoaded;
beforeAll(async () => {
({ ensureRuntimePluginsLoaded } = await import("./runtime-plugins.js"));
});
beforeEach(() => {
beforeEach(async () => {
hoisted.resolveRuntimePluginRegistry.mockReset();
hoisted.resolveRuntimePluginRegistry.mockReturnValue(undefined);
vi.resetModules();
({ ensureRuntimePluginsLoaded } = await import("./runtime-plugins.js"));
});
it("does not reactivate plugins when a process already has an active registry", async () => {