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,4 +1,4 @@
import { afterEach, beforeEach, describe, expect, it, mock } from "bun:test"
import { afterAll, afterEach, beforeEach, describe, expect, it, mock } from "bun:test"
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"
import { join } from "node:path"
@@ -16,6 +16,10 @@ mock.module("../../shared/logger", () => ({
log: () => {},
}))
afterAll(() => {
mock.restore()
})
function resetTestCache(): void {
if (existsSync(TEST_CACHE_DIR)) {
rmSync(TEST_CACHE_DIR, { recursive: true, force: true })
@@ -1,4 +1,4 @@
import { afterEach, beforeEach, describe, expect, it, mock } from "bun:test"
import { afterAll, afterEach, beforeEach, describe, expect, it, mock } from "bun:test"
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"
import { join } from "node:path"
import type { PluginEntryInfo } from "./plugin-entry"
@@ -22,6 +22,10 @@ mock.module("../../../shared/logger", () => ({
log: () => {},
}))
afterAll(() => {
mock.restore()
})
function resetTestCache(currentVersion = "3.10.0"): void {
if (existsSync(TEST_CACHE_DIR)) {
rmSync(TEST_CACHE_DIR, { recursive: true, force: true })
+5 -1
View File
@@ -1,4 +1,4 @@
import { afterEach, beforeEach, describe, expect, it, mock } from "bun:test"
import { afterAll, afterEach, beforeEach, describe, expect, it, mock } from "bun:test"
const mockShowConfigErrorsIfAny = mock(async () => {})
const mockShowModelCacheWarningIfNeeded = mock(async () => {})
@@ -45,6 +45,10 @@ mock.module("../../shared/logger", () => ({
log: () => {},
}))
afterAll(() => {
mock.restore()
})
type HookFactory = typeof import("./hook").createAutoUpdateCheckerHook
async function importFreshHookFactory(): Promise<HookFactory> {
@@ -1,5 +1,5 @@
import type { PluginInput } from "@opencode-ai/plugin"
import { beforeEach, describe, expect, it, mock } from "bun:test"
import { afterAll, beforeEach, describe, expect, it, mock } from "bun:test"
type PluginEntry = {
entry: string
@@ -51,6 +51,10 @@ mock.module("./update-toasts", () => ({
}))
mock.module("../../../shared/logger", () => ({ log: () => {} }))
afterAll(() => {
mock.restore()
})
const modulePath = "./background-update-check?test"
const { runBackgroundUpdateCheck } = await import(modulePath)
@@ -1,5 +1,5 @@
import type { PluginInput } from "@opencode-ai/plugin"
import { afterEach, beforeEach, describe, expect, it, mock } from "bun:test"
import { afterAll, afterEach, beforeEach, describe, expect, it, mock } from "bun:test"
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs"
import { join } from "node:path"
@@ -101,6 +101,10 @@ mock.module("../../../shared/opencode-config-dir", () => ({
}),
}))
afterAll(() => {
mock.restore()
})
const modulePath = "./background-update-check?test"
const { runBackgroundUpdateCheck } = await import(modulePath)