test(perf): reduce repeated cli program setup overhead

This commit is contained in:
Peter Steinberger
2026-03-02 14:02:41 +00:00
parent 234e07fcc0
commit 534f436d4e
2 changed files with 68 additions and 80 deletions

View File

@@ -1,4 +1,4 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import {
configureCommand,
ensureConfigReady,
@@ -26,15 +26,20 @@ vi.mock("./config-cli.js", () => ({
const { buildProgram } = await import("./program.js");
describe("cli program (smoke)", () => {
let program = createProgram();
function createProgram() {
return buildProgram();
}
async function runProgram(argv: string[]) {
const program = createProgram();
await program.parseAsync(argv, { from: "user" });
}
beforeAll(() => {
program = createProgram();
});
beforeEach(() => {
vi.clearAllMocks();
runTui.mockResolvedValue(undefined);
@@ -42,7 +47,6 @@ describe("cli program (smoke)", () => {
});
it("registers memory + status commands", () => {
const program = createProgram();
const names = program.commands.map((command) => command.name());
expect(names).toContain("message");
expect(names).toContain("memory");