test(cli): dedupe runtime capture fixtures across command specs

This commit is contained in:
Peter Steinberger
2026-02-18 13:27:07 +00:00
parent 3af9f704c8
commit 8f866d51c4
7 changed files with 59 additions and 90 deletions

View File

@@ -1,5 +1,6 @@
import { Command } from "commander";
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { createCliRuntimeCapture } from "./test-runtime-capture.js";
type NodeInvokeCall = {
method?: string;
@@ -61,15 +62,7 @@ const callGateway = vi.fn(async (opts: NodeInvokeCall) => {
const randomIdempotencyKey = vi.fn(() => "rk_test");
const runtimeLogs: string[] = [];
const runtimeErrors: string[] = [];
const defaultRuntime = {
log: (msg: string) => runtimeLogs.push(msg),
error: (msg: string) => runtimeErrors.push(msg),
exit: (code: number) => {
throw new Error(`__exit__:${code}`);
},
};
const { defaultRuntime, resetRuntimeCapture } = createCliRuntimeCapture();
vi.mock("../gateway/call.js", () => ({
callGateway: (opts: unknown) => callGateway(opts as NodeInvokeCall),
@@ -95,8 +88,7 @@ describe("nodes-cli coverage", () => {
});
beforeEach(() => {
runtimeLogs.length = 0;
runtimeErrors.length = 0;
resetRuntimeCapture();
callGateway.mockClear();
randomIdempotencyKey.mockClear();
});