From 8a49a03100d6cef976c73a21a15849c07fe08650 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 27 Apr 2026 13:37:51 +0900 Subject: [PATCH] test(skill): fresh import skill tool factory Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- src/tools/skill/tools.factory.test.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/tools/skill/tools.factory.test.ts b/src/tools/skill/tools.factory.test.ts index b307d9589..b1e992607 100644 --- a/src/tools/skill/tools.factory.test.ts +++ b/src/tools/skill/tools.factory.test.ts @@ -46,6 +46,11 @@ function createMockContext(sessionID: string): ToolContext { } } +async function createSkillTool(...args: Parameters): ReturnType { + const module = await import(`./tools?test=${Date.now()}-${Math.random()}`) + return module.createSkillTool(...args) +} + beforeEach(() => { spyOn(commandDiscovery, "discoverCommandsSync").mockImplementation(discoverCommandsSync) spyOn(skillContent, "getAllSkills").mockImplementation(getAllSkills) @@ -63,8 +68,7 @@ describe("createSkillTool", () => { const baselineDiscoverCommandsSyncCalls = discoverCommandsSync.mock.calls.length // when - const { createSkillTool } = await import("./tools") - const skillTool = createSkillTool({}) + const skillTool = await createSkillTool({}) // then expect(discoverCommandsSync.mock.calls.length).toBe(baselineDiscoverCommandsSyncCalls) @@ -80,8 +84,7 @@ describe("createSkillTool", () => { const baselineGetAllSkillsCalls = getAllSkills.mock.calls.length // when - const { createSkillTool } = await import("./tools") - const skillTool = createSkillTool({}) + const skillTool = await createSkillTool({}) // then expect(getAllSkills.mock.calls.length).toBe(baselineGetAllSkillsCalls) @@ -97,8 +100,7 @@ describe("createSkillTool", () => { const sessionContext = createMockContext("session-clear-once") // when - const { createSkillTool } = await import("./tools") - const skillTool = createSkillTool({}) + const skillTool = await createSkillTool({}) void skillTool.description await flushMicrotasks() await skillTool.execute({ name: "lazy-skill" }, sessionContext) @@ -114,8 +116,7 @@ describe("createSkillTool", () => { const baselineGetAllSkillsCalls = getAllSkills.mock.calls.length const sessionAContext = createMockContext("session-a") const sessionBContext = createMockContext("session-b") - const { createSkillTool } = await import("./tools") - const skillTool = createSkillTool({}) + const skillTool = await createSkillTool({}) // when await skillTool.execute({ name: "lazy-skill" }, sessionAContext)