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
+5 -1
View File
@@ -1,6 +1,6 @@
/// <reference types="bun-types" />
import { beforeEach, describe, expect, it, mock } from "bun:test"
import { afterAll, beforeEach, describe, expect, it, mock } from "bun:test"
import { PLUGIN_NAME } from "../../../shared"
import type { PluginInfo } from "./system-plugin"
@@ -47,6 +47,10 @@ mock.module("./system-loaded-version", () => ({
getSuggestedInstallTag: mockGetSuggestedInstallTag,
}))
afterAll(() => {
mock.restore()
})
describe("system check", () => {
beforeEach(() => {
mockFindOpenCodeBinary.mockReset()
+5 -1
View File
@@ -1,4 +1,4 @@
import { describe, it, expect, beforeEach, afterEach, mock } from "bun:test"
import { afterAll, describe, it, expect, beforeEach, afterEach, mock } from "bun:test"
const mockLogin = mock(() => Promise.resolve({ accessToken: "test-token", expiresAt: 1710000000 }))
@@ -11,6 +11,10 @@ mock.module("../../features/mcp-oauth/provider", () => ({
},
}))
afterAll(() => {
mock.restore()
})
const { login } = await import("./login")
describe("login command", () => {
+1
View File
@@ -33,6 +33,7 @@ mock.module("../../shared/port-utils", () => ({
afterAll(() => {
mock.module("@opencode-ai/sdk", () => originalSdk)
mock.module("../../shared/port-utils", () => originalPortUtils)
mock.restore()
})
const { createServerConnection } = await import("./server-connection")
+1
View File
@@ -38,6 +38,7 @@ afterAll(() => {
mock.module("@opencode-ai/sdk", () => originalSdk)
mock.module("../../shared/port-utils", () => originalPortUtils)
mock.module("./opencode-binary-resolver", () => originalBinaryResolver)
mock.restore()
})
const { createServerConnection } = await import("./server-connection")