test: fix CI test isolation - upgrade Bun, fix mock contamination and fresh-import patterns
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
declare const require: (name: string) => any
|
||||
const { describe, test, expect, beforeEach, afterEach, spyOn, mock } = require("bun:test")
|
||||
import type { DelegateTaskArgs } from "../../types"
|
||||
import type { ExecutorContext } from "../../executor-types"
|
||||
import * as logger from "../../../../shared/logger"
|
||||
import * as connectedProvidersCache from "../../../../shared/connected-providers-cache"
|
||||
import type { DelegateTaskArgs } from "../types"
|
||||
import type { ExecutorContext } from "../executor-types"
|
||||
import * as logger from "../../../shared/logger"
|
||||
import * as connectedProvidersCache from "../../../shared/connected-providers-cache"
|
||||
|
||||
type SubagentResolverModule = typeof import("../../subagent-resolver")
|
||||
type SubagentResolverModule = typeof import("../subagent-resolver")
|
||||
|
||||
async function importFreshSubagentResolverModule(): Promise<SubagentResolverModule> {
|
||||
return await import(`../../subagent-resolver?test=${Date.now()}-${Math.random()}`)
|
||||
return await import(`../subagent-resolver?test=${Date.now()}-${Math.random()}`)
|
||||
}
|
||||
|
||||
function createBaseArgs(overrides?: Partial<DelegateTaskArgs>): DelegateTaskArgs {
|
||||
|
||||
@@ -8,7 +8,9 @@ import type { Tool as McpTool } from "@modelcontextprotocol/sdk/types.js"
|
||||
|
||||
const originalReadFileSync = fs.readFileSync.bind(fs)
|
||||
|
||||
async function importFreshSkillToolModule(): Promise<typeof import("./tools")> {
|
||||
let createSkillTool: typeof import("../tools").createSkillTool
|
||||
|
||||
beforeEach(async () => {
|
||||
mock.module("node:fs", () => ({
|
||||
...fs,
|
||||
readFileSync: (path: string, encoding?: string) => {
|
||||
@@ -21,13 +23,10 @@ Test skill body content`
|
||||
return originalReadFileSync(path, encoding as BufferEncoding)
|
||||
},
|
||||
}))
|
||||
|
||||
const module = await import(`./tools?test=${Date.now()}-${Math.random()}`)
|
||||
mock.restore()
|
||||
return module
|
||||
}
|
||||
|
||||
const { createSkillTool } = await importFreshSkillToolModule()
|
||||
|
||||
const module = await import("../tools")
|
||||
createSkillTool = module.createSkillTool
|
||||
})
|
||||
|
||||
afterAll(() => {
|
||||
mock.restore()
|
||||
|
||||
Reference in New Issue
Block a user