fix(ci): resolve mock.module() cross-file leakage in test suite
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -37,7 +37,10 @@ afterAll(() => {
|
||||
})
|
||||
|
||||
async function importFreshStartupWarningModule(): Promise<typeof import("./log-legacy-plugin-startup-warning")> {
|
||||
return import(`./log-legacy-plugin-startup-warning?test=${Date.now()}-${Math.random()}`)
|
||||
const module = await import(`./log-legacy-plugin-startup-warning?test=${Date.now()}-${Math.random()}`)
|
||||
mock.restore()
|
||||
consoleWarnSpy = spyOn(console, "warn").mockImplementation(() => {})
|
||||
return module
|
||||
}
|
||||
|
||||
describe("logLegacyPluginStartupWarning", () => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { ModelCapabilitiesSnapshot } from "./model-capabilities"
|
||||
import { afterAll, describe, expect, test, mock } from "bun:test"
|
||||
|
||||
// Mock connected-providers-cache to prevent local disk cache from polluting test results.
|
||||
@@ -14,11 +15,8 @@ afterAll(() => {
|
||||
mock.restore()
|
||||
})
|
||||
|
||||
import {
|
||||
getModelCapabilities,
|
||||
getBundledModelCapabilitiesSnapshot,
|
||||
type ModelCapabilitiesSnapshot,
|
||||
} from "./model-capabilities"
|
||||
const { getModelCapabilities, getBundledModelCapabilitiesSnapshot } = await import("./model-capabilities")
|
||||
mock.restore()
|
||||
import { AGENT_MODEL_REQUIREMENTS, CATEGORY_MODEL_REQUIREMENTS } from "./model-requirements"
|
||||
|
||||
describe("getModelCapabilities", () => {
|
||||
|
||||
@@ -9,7 +9,8 @@ mock.module("./connected-providers-cache", () => ({
|
||||
|
||||
afterAll(() => { mock.restore() })
|
||||
|
||||
import { shouldRetryError, selectFallbackProvider } from "./model-error-classifier"
|
||||
const { shouldRetryError, selectFallbackProvider } = await import("./model-error-classifier")
|
||||
mock.restore()
|
||||
|
||||
describe("model-error-classifier", () => {
|
||||
beforeEach(() => {
|
||||
@@ -107,3 +108,5 @@ describe("model-error-classifier", () => {
|
||||
expect(result).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
export {}
|
||||
|
||||
Reference in New Issue
Block a user