From 78f0fb660c10b7acda01411837a1ce0967dd6911 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Wed, 15 Apr 2026 12:30:33 +0100 Subject: [PATCH] test(plugins): avoid per-test discovery reloads --- test/helpers/plugins/provider-discovery-contract.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/helpers/plugins/provider-discovery-contract.ts b/test/helpers/plugins/provider-discovery-contract.ts index 8783701fed7..7a40b92e3a9 100644 --- a/test/helpers/plugins/provider-discovery-contract.ts +++ b/test/helpers/plugins/provider-discovery-contract.ts @@ -1,4 +1,4 @@ -import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import type { AuthProfileStore } from "../../../src/agents/auth-profiles/types.js"; import type { OpenClawConfig } from "../../../src/config/config.js"; import type { ModelDefinitionConfig } from "../../../src/config/types.models.js"; @@ -171,15 +171,14 @@ function runCatalog( } async function importBundledProviderPlugin(moduleUrl: string): Promise { - return (await import(`${moduleUrl}?t=${Date.now()}`)) as T; + return (await import(moduleUrl)) as T; } function installDiscoveryHooks( state: DiscoveryState, providerIds: readonly BundledProviderUnderTest[], ) { - beforeEach(async () => { - vi.resetModules(); + beforeAll(async () => { vi.doMock("openclaw/plugin-sdk/agent-runtime", () => { return { ensureAuthProfileStore: ensureAuthProfileStoreMock, @@ -315,7 +314,7 @@ function installDiscoveryHooks( setRuntimeAuthStore(); }); - afterEach(() => { + beforeEach(() => { vi.restoreAllMocks(); resolveCopilotApiTokenMock.mockReset(); buildOllamaProviderMock.mockReset(); @@ -323,6 +322,7 @@ function installDiscoveryHooks( buildSglangProviderMock.mockReset(); ensureAuthProfileStoreMock.mockReset(); listProfilesForProviderMock.mockReset(); + setRuntimeAuthStore(); }); }