mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-29 01:52:04 +00:00
test: harden no-isolate test module resets
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import { afterAll, afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { AuthProfileStore } from "../agents/auth-profiles.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import type { PluginWebSearchProviderEntry } from "../plugins/types.js";
|
||||
import { getPath, setPathCreateStrict } from "./path-utils.js";
|
||||
import { clearSecretsRuntimeSnapshot, prepareSecretsRuntimeSnapshot } from "./runtime.js";
|
||||
import { listSecretTargetRegistryEntries } from "./target-registry.js";
|
||||
|
||||
type SecretRegistryEntry = ReturnType<typeof listSecretTargetRegistryEntries>[number];
|
||||
@@ -19,6 +18,9 @@ const mockedModuleIds = [
|
||||
"../plugins/web-search-providers.runtime.js",
|
||||
] as const;
|
||||
|
||||
let clearSecretsRuntimeSnapshot: typeof import("./runtime.js").clearSecretsRuntimeSnapshot;
|
||||
let prepareSecretsRuntimeSnapshot: typeof import("./runtime.js").prepareSecretsRuntimeSnapshot;
|
||||
|
||||
vi.mock("../plugins/web-search-providers.js", () => ({
|
||||
resolveBundledPluginWebSearchProviders: resolveBundledPluginWebSearchProvidersMock,
|
||||
}));
|
||||
@@ -251,6 +253,11 @@ describe("secrets runtime target coverage", () => {
|
||||
resolvePluginWebSearchProvidersMock.mockReset();
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
({ clearSecretsRuntimeSnapshot, prepareSecretsRuntimeSnapshot } = await import("./runtime.js"));
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
for (const id of mockedModuleIds) {
|
||||
vi.doUnmock(id);
|
||||
|
||||
Reference in New Issue
Block a user