From 1af9d82f95989dee0df528953d1201fffab6733d Mon Sep 17 00:00:00 2001 From: anandgupta42 Date: Wed, 18 Mar 2026 02:07:14 -0700 Subject: [PATCH] fix: dispatcher tests fail in CI due to shared module state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `Dispatcher.reset()` in `dispatcher.test.ts` clears the shared `nativeHandlers` Map. Since Bun shares modules across test files in the same process, side-effect imports in `schema-finops-dbt.test.ts` only run once at module load — if another test resets the dispatcher afterward, handlers are gone permanently. Replace side-effect imports with explicit `registerAll()` calls in `beforeAll` so handlers are re-registered regardless of test execution order. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../test/altimate/schema-finops-dbt.test.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/opencode/test/altimate/schema-finops-dbt.test.ts b/packages/opencode/test/altimate/schema-finops-dbt.test.ts index 3d34ede0d5..e8fd5e7f35 100644 --- a/packages/opencode/test/altimate/schema-finops-dbt.test.ts +++ b/packages/opencode/test/altimate/schema-finops-dbt.test.ts @@ -6,14 +6,21 @@ beforeAll(() => { process.env.ALTIMATE_TELEMETRY_DISABLED = "true" }) afterAll(() => { delete process.env.ALTIMATE_TELEMETRY_DISABLED }) // --------------------------------------------------------------------------- -// Import modules AFTER env var is set +// Import registerAll functions — call them explicitly in beforeAll to guard +// against Dispatcher.reset() in other test files clearing the shared handler map. // --------------------------------------------------------------------------- -// These side-effect imports register handlers -import "../../src/altimate/native/schema/register" -import "../../src/altimate/native/finops/register" -import "../../src/altimate/native/dbt/register" -import "../../src/altimate/native/local/register" +import { registerAll as registerSchema } from "../../src/altimate/native/schema/register" +import { registerAll as registerFinops } from "../../src/altimate/native/finops/register" +import { registerAll as registerDbt } from "../../src/altimate/native/dbt/register" +import { registerAll as registerLocal } from "../../src/altimate/native/local/register" + +beforeAll(() => { + registerSchema() + registerFinops() + registerDbt() + registerLocal() +}) // Import SQL template exports for template generation tests import { SQL_TEMPLATES as CreditTemplates } from "../../src/altimate/native/finops/credit-analyzer"