From 6943b6d4d8b631c0290a31c95c8f0d999902c68e Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Wed, 8 Apr 2026 23:39:43 +0900 Subject: [PATCH] fix(ci): isolate model-resolver and prometheus-config tests from mock.module contamination model-resolver.test.ts and prometheus-agent-config-builder.test.ts use spyOn(shared, 'log') but do not own the logger module. When other test files in the same bun test process call mock.module('../shared/logger'), the import cache is poisoned and the spyOn targets a stale binding. Add a lightweight mock.module call at the top of each file so the auto-detection in run-ci-tests.ts picks them up as isolated targets. This ensures each file gets its own module instance and the spy captures all calls correctly. Fixes the flaky CI failure pattern where resolveModelWithFallback and buildPrometheusAgentConfig tests pass locally (separate bun process) but fail in the shared CI batch. --- src/plugin-handlers/prometheus-agent-config-builder.test.ts | 6 +++++- src/shared/model-resolver.test.ts | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugin-handlers/prometheus-agent-config-builder.test.ts b/src/plugin-handlers/prometheus-agent-config-builder.test.ts index e6440834a..e01403289 100644 --- a/src/plugin-handlers/prometheus-agent-config-builder.test.ts +++ b/src/plugin-handlers/prometheus-agent-config-builder.test.ts @@ -1,4 +1,8 @@ -import { describe, expect, test, spyOn, afterEach, beforeEach } from "bun:test"; +import { describe, expect, test, spyOn, afterEach, beforeEach, mock } from "bun:test"; + +// Isolate from other tests that mock.module the logger (CI cross-contamination fix) +mock.module("../shared/logger", () => ({ log: (..._args: unknown[]) => {} })) + import { buildPrometheusAgentConfig } from "./prometheus-agent-config-builder"; import * as shared from "../shared"; import * as categoryResolver from "./category-config-resolver"; diff --git a/src/shared/model-resolver.test.ts b/src/shared/model-resolver.test.ts index 23a02c132..292aac718 100644 --- a/src/shared/model-resolver.test.ts +++ b/src/shared/model-resolver.test.ts @@ -1,4 +1,8 @@ import { describe, expect, test, spyOn, beforeEach, afterEach, mock } from "bun:test" + +// Isolate from other tests that mock.module the logger (CI cross-contamination fix) +mock.module("./logger", () => ({ log: (..._args: unknown[]) => {} })) + import { resolveModel, resolveModelWithFallback, type ModelResolutionInput, type ExtendedModelResolutionInput, type ModelResolutionResult, type ModelSource } from "./model-resolver" import * as logger from "./logger" import * as connectedProvidersCache from "./connected-providers-cache"