fix(ci): simplify test runner to plain bun test by fixing mock.module() leakage

- Add afterAll(() => { mock.restore() }) to 52 test files missing cleanup
- Rewrite create-tool-guard-hooks.test.ts to use spyOn instead of barrel mock
- Fix skill-mcp-manager OAuth tests with missing mockTokens/mockLogin definitions
- Fix start-work hook: show worktree active block on resume with existing worktree_path
- Extract createWorktreeActiveBlock to worktree-block.ts to avoid circular import
- Replace 80-line isolated test runner CI config with single `bun test` command
This commit is contained in:
YeonGyu-Kim
2026-04-03 23:06:35 +09:00
parent 06180e09f8
commit 53eeac3f31
55 changed files with 219 additions and 190 deletions
@@ -1,4 +1,4 @@
const { beforeEach, describe, expect, mock, test } = require("bun:test")
const { beforeEach, describe, expect, mock, test, afterAll } = require("bun:test")
const executeStopHooks = mock(async (context: { parentSessionId?: string }) => ({
block: false,
@@ -19,6 +19,8 @@ mock.module("../stop", () => ({
executeStopHooks,
}))
afterAll(() => { mock.restore() })
const { createSessionEventHandler } = await import("./session-event-handler")
describe("createSessionEventHandler retry behavior", () => {
@@ -1,4 +1,4 @@
import { beforeEach, describe, expect, it, mock } from "bun:test"
import { beforeEach, describe, expect, it, mock, afterAll } from "bun:test"
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null && !Array.isArray(value)
@@ -26,6 +26,8 @@ mock.module("../transcript", () => ({
getTranscriptPath: () => "/tmp/transcript.jsonl",
}))
afterAll(() => { mock.restore() })
const { createToolExecuteAfterHandler } = await import("./tool-execute-after-handler")
describe("createToolExecuteAfterHandler", () => {
+3 -1
View File
@@ -1,4 +1,4 @@
import { describe, it, expect, mock, beforeEach } from "bun:test"
import { describe, it, expect, mock, beforeEach, afterAll } from "bun:test"
import type { ClaudeHooksConfig } from "./types"
import type { StopContext } from "./stop"
@@ -17,6 +17,8 @@ mock.module("../../shared/logger", () => ({
getLogFilePath: () => "/tmp/test.log",
}))
afterAll(() => { mock.restore() })
const { executeStopHooks } = await import("./stop")
function createStopContext(overrides?: Partial<StopContext>): StopContext {