test: fix CI test isolation - upgrade Bun, fix mock contamination and fresh-import patterns

This commit is contained in:
YeonGyu-Kim
2026-04-05 01:01:19 +09:00
parent aa7e2aa07f
commit da86b57f23
7 changed files with 69 additions and 51 deletions
@@ -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()