From c91c3e6164ff61bd5f8792b4b5bab04da07f36a5 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sat, 4 Apr 2026 17:08:53 +0900 Subject: [PATCH] fix(test): move auto-slash-command-leak test to isolated subdirectory mock.module('./executor') leaks across all files in the same batch because Bun runs test files in a directory in parallel. The afterAll restore trick doesn't work when other files load the module concurrently at startup. Moving the leak test to its own subdirectory (leak/) ensures CI's batch runner isolates it in a separate bun test invocation, preventing executor mock contamination in executor-resolution.test.ts and index.test.ts. --- .../{ => leak}/auto-slash-command-leak.test.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rename src/hooks/auto-slash-command/{ => leak}/auto-slash-command-leak.test.ts (95%) diff --git a/src/hooks/auto-slash-command/auto-slash-command-leak.test.ts b/src/hooks/auto-slash-command/leak/auto-slash-command-leak.test.ts similarity index 95% rename from src/hooks/auto-slash-command/auto-slash-command-leak.test.ts rename to src/hooks/auto-slash-command/leak/auto-slash-command-leak.test.ts index e82ae313e..15198f174 100644 --- a/src/hooks/auto-slash-command/auto-slash-command-leak.test.ts +++ b/src/hooks/auto-slash-command/leak/auto-slash-command-leak.test.ts @@ -1,12 +1,12 @@ import { afterAll, beforeEach, describe, expect, it, mock, spyOn } from "bun:test" -import { AUTO_SLASH_COMMAND_TAG_OPEN } from "./constants" +import { AUTO_SLASH_COMMAND_TAG_OPEN } from "../constants" import type { AutoSlashCommandHookInput, AutoSlashCommandHookOutput, CommandExecuteBeforeInput, CommandExecuteBeforeOutput, -} from "./types" -import * as shared from "../../shared" +} from "../types" +import * as shared from "../../../shared" const executeSlashCommandMock = mock( async (parsed: { command: string; args: string; raw: string }) => ({ @@ -15,7 +15,7 @@ const executeSlashCommandMock = mock( }) ) -mock.module("./executor", () => ({ +mock.module("../executor", () => ({ executeSlashCommand: executeSlashCommandMock, })) @@ -23,13 +23,13 @@ afterAll(async () => { mock.restore() // Restore the real executor module so subsequent test files in the same batch // (e.g. executor-resolution.test.ts) don't get the mocked version - const realExecutor = await import("./executor") - mock.module("./executor", () => realExecutor) + const realExecutor = await import("../executor") + mock.module("../executor", () => realExecutor) }) const logMock = spyOn(shared, "log").mockImplementation(() => {}) -const { createAutoSlashCommandHook } = await import("./hook") +const { createAutoSlashCommandHook } = await import("../hook") function createChatInput(sessionID: string, messageID: string): AutoSlashCommandHookInput { return {