mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-30 17:03:40 +00:00
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
// Failure output tests cover CLI error formatting and failure summaries.
|
|
import { describe, expect, it } from "vitest";
|
|
import { formatCliFailureLines } from "./failure-output.js";
|
|
|
|
describe("formatCliFailureLines", () => {
|
|
it("shows a concise reason and recovery commands by default", () => {
|
|
const lines = formatCliFailureLines({
|
|
title: "Could not start the CLI.",
|
|
error: new Error("config file is invalid"),
|
|
argv: ["node", "openclaw", "status"],
|
|
env: {},
|
|
});
|
|
|
|
expect(lines).toEqual([
|
|
"[openclaw] Could not start the CLI.",
|
|
"[openclaw] Reason: config file is invalid",
|
|
"[openclaw] Debug: set OPENCLAW_DEBUG=1 to include the stack trace.",
|
|
"[openclaw] Try: openclaw doctor",
|
|
"[openclaw] Help: openclaw --help",
|
|
]);
|
|
});
|
|
|
|
it("prints stack details when debug output is requested", () => {
|
|
const lines = formatCliFailureLines({
|
|
title: "The CLI command failed.",
|
|
error: new Error("boom"),
|
|
env: { OPENCLAW_DEBUG: "1" },
|
|
});
|
|
|
|
expect(lines.slice(0, 4)).toEqual([
|
|
"[openclaw] The CLI command failed.",
|
|
"[openclaw] Reason: boom",
|
|
"[openclaw] Stack:",
|
|
"[openclaw] Error: boom",
|
|
]);
|
|
expect(lines.join("\n")).toContain("Error: boom");
|
|
});
|
|
});
|