mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 19:31:24 +00:00
test(cli): dedupe runtime capture fixtures across command specs
This commit is contained in:
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user