From 85932fadc7d3122c8d7904568d3fa04332ade511 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Wed, 4 Feb 2026 14:51:56 +0900 Subject: [PATCH] test(skill-loader): fix test isolation by resetting skill content Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus --- .../skill-content.test.ts | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/features/opencode-skill-loader/skill-content.test.ts b/src/features/opencode-skill-loader/skill-content.test.ts index 1c21e14a6..4ea846712 100644 --- a/src/features/opencode-skill-loader/skill-content.test.ts +++ b/src/features/opencode-skill-loader/skill-content.test.ts @@ -1,6 +1,34 @@ -import { describe, it, expect } from "bun:test" +/// + +import { describe, it, expect, beforeEach, afterEach } from "bun:test" +import { join } from "node:path" +import { tmpdir } from "node:os" import { resolveSkillContent, resolveMultipleSkills, resolveSkillContentAsync, resolveMultipleSkillsAsync } from "./skill-content" +let originalEnv: Record +let testConfigDir: string + +beforeEach(() => { + originalEnv = { + CLAUDE_CONFIG_DIR: process.env.CLAUDE_CONFIG_DIR, + OPENCODE_CONFIG_DIR: process.env.OPENCODE_CONFIG_DIR, + } + const unique = `skill-content-test-${Date.now()}-${Math.random().toString(16).slice(2)}` + testConfigDir = join(tmpdir(), unique) + process.env.CLAUDE_CONFIG_DIR = testConfigDir + process.env.OPENCODE_CONFIG_DIR = testConfigDir +}) + +afterEach(() => { + for (const [key, value] of Object.entries(originalEnv)) { + if (value !== undefined) { + process.env[key] = value + } else { + delete process.env[key] + } + } +}) + describe("resolveSkillContent", () => { it("should return template for existing skill", () => { // given: builtin skills with 'frontend-ui-ux' skill