Fix Bun mock.module() leak between test files preventing ralph-loop tests from passing
Replace mock.module() with spyOn() in auto-slash-command test to prevent shared module mocking from leaking to other test files. Remove unused mock.module() from think-mode test. This ensures test isolation so ralph-loop tests pass in both isolation and full suite runs. 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
@@ -1,33 +1,16 @@
|
||||
import { describe, expect, it, beforeEach, mock } from "bun:test"
|
||||
import { describe, expect, it, beforeEach, mock, spyOn } from "bun:test"
|
||||
import type {
|
||||
AutoSlashCommandHookInput,
|
||||
AutoSlashCommandHookOutput,
|
||||
} from "./types"
|
||||
|
||||
const logMock = mock(() => {})
|
||||
// Import real shared module to avoid mock leaking to other test files
|
||||
import * as shared from "../../shared"
|
||||
|
||||
mock.module("../../shared", () => ({
|
||||
log: logMock,
|
||||
parseFrontmatter: (content: string) => ({ data: {}, body: content }),
|
||||
resolveCommandsInText: async (text: string) => text,
|
||||
resolveFileReferencesInText: async (text: string) => text,
|
||||
sanitizeModelField: (model: unknown) => model,
|
||||
getClaudeConfigDir: () => "/mock/.claude",
|
||||
}))
|
||||
// Spy on log instead of mocking the entire module
|
||||
const logMock = spyOn(shared, "log").mockImplementation(() => {})
|
||||
|
||||
mock.module("../../shared/file-utils", () => ({
|
||||
isMarkdownFile: () => false,
|
||||
}))
|
||||
|
||||
mock.module("../../features/opencode-skill-loader", () => ({
|
||||
discoverAllSkills: () => [],
|
||||
}))
|
||||
|
||||
mock.module("fs", () => ({
|
||||
existsSync: () => false,
|
||||
readdirSync: () => [],
|
||||
readFileSync: () => "",
|
||||
}))
|
||||
|
||||
const { createAutoSlashCommandHook } = await import("./index")
|
||||
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
import { describe, expect, it, beforeEach, mock } from "bun:test"
|
||||
import { describe, expect, it, beforeEach } from "bun:test"
|
||||
import type { ThinkModeInput } from "./types"
|
||||
|
||||
const logMock = mock(() => {})
|
||||
|
||||
mock.module("../../shared", () => ({
|
||||
log: logMock,
|
||||
}))
|
||||
|
||||
const { createThinkModeHook, clearThinkModeState } = await import("./index")
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user