From 2452a4789d05941c17ef32434f3daba939ebb6c1 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Fri, 2 Jan 2026 00:23:46 +0900 Subject: [PATCH] fix(tests): resolve mock.module leakage breaking ralph-loop tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The node:fs mock in skill/tools.test.ts was replacing the entire module, causing fs functions to be undefined for tests running afterwards. Fixed by preserving original fs functions and only intercepting skill paths. 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode) --- src/tools/skill/tools.test.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/tools/skill/tools.test.ts b/src/tools/skill/tools.test.ts index 25feda0..16a104a 100644 --- a/src/tools/skill/tools.test.ts +++ b/src/tools/skill/tools.test.ts @@ -1,14 +1,23 @@ import { describe, it, expect, beforeEach, mock, spyOn } from "bun:test" +import * as fs from "node:fs" import { createSkillTool } from "./tools" import { SkillMcpManager } from "../../features/skill-mcp-manager" import type { LoadedSkill } from "../../features/opencode-skill-loader/types" import type { Tool as McpTool } from "@modelcontextprotocol/sdk/types.js" +const originalReadFileSync = fs.readFileSync.bind(fs) + mock.module("node:fs", () => ({ - readFileSync: () => `--- + ...fs, + readFileSync: (path: string, encoding?: string) => { + if (typeof path === "string" && path.includes("/skills/")) { + return `--- description: Test skill description --- -Test skill body content`, +Test skill body content` + } + return originalReadFileSync(path, encoding as BufferEncoding) + }, })) function createMockSkillWithMcp(name: string, mcpServers: Record): LoadedSkill {