From e6f75e526d7159a69773d3712701ec6ac69f6981 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 14 Feb 2026 19:14:47 +0000 Subject: [PATCH] perf(test): speed up command-registry suite --- src/cli/program/command-registry.test.ts | 26 +++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/cli/program/command-registry.test.ts b/src/cli/program/command-registry.test.ts index cc667fb51..4f1698d4e 100644 --- a/src/cli/program/command-registry.test.ts +++ b/src/cli/program/command-registry.test.ts @@ -1,11 +1,27 @@ import { Command } from "commander"; import { describe, expect, it, vi } from "vitest"; import type { ProgramContext } from "./context.js"; -import { - getCoreCliCommandNames, - registerCoreCliByName, - registerCoreCliCommands, -} from "./command-registry.js"; + +// Perf: `registerCoreCliByName(...)` dynamically imports registrar modules. +// Mock the heavy registrars so this suite stays focused on command-registry wiring. +vi.mock("./register.agent.js", () => ({ + registerAgentCommands: (program: Command) => { + program.command("agent"); + program.command("agents"); + }, +})); + +vi.mock("./register.maintenance.js", () => ({ + registerMaintenanceCommands: (program: Command) => { + program.command("doctor"); + program.command("dashboard"); + program.command("reset"); + program.command("uninstall"); + }, +})); + +const { getCoreCliCommandNames, registerCoreCliByName, registerCoreCliCommands } = + await import("./command-registry.js"); vi.mock("./register.status-health-sessions.js", () => ({ registerStatusHealthSessionsCommands: (program: Command) => {