test: display cli output text

This commit is contained in:
Shakker
2026-05-12 21:54:12 +01:00
parent 016852186d
commit 71cdb6ab9a
4 changed files with 7 additions and 7 deletions

View File

@@ -166,15 +166,15 @@ function requireWriteOptions(): { unsetPaths?: string[][]; explicitSetPaths?: st
}
function expectLogIncludes(text: string) {
expect(mockLog.mock.calls.some((call) => String(call[0]).includes(text))).toBe(true);
expect(mockLog.mock.calls.map((call) => String(call[0])).join("\n")).toContain(text);
}
function expectLogExcludes(text: string) {
expect(mockLog.mock.calls.some((call) => String(call[0]).includes(text))).toBe(false);
expect(mockLog.mock.calls.map((call) => String(call[0])).join("\n")).not.toContain(text);
}
function expectErrorIncludes(text: string) {
expect(mockError.mock.calls.some((call) => String(call[0]).includes(text))).toBe(true);
expect(mockError.mock.calls.map((call) => String(call[0])).join("\n")).toContain(text);
}
function requireRecord(value: unknown, label: string): Record<string, unknown> {

View File

@@ -134,11 +134,11 @@ function runtimeErrorMessages(): string[] {
}
function expectRuntimeErrorContaining(text: string): void {
expect(runtimeErrorMessages().some((message) => message.includes(text))).toBe(true);
expect(runtimeErrorMessages().join("\n")).toContain(text);
}
function expectNoRuntimeErrorContaining(text: string): void {
expect(runtimeErrorMessages().some((message) => message.includes(text))).toBe(false);
expect(runtimeErrorMessages().join("\n")).not.toContain(text);
}
function stdoutText(): string {

View File

@@ -32,6 +32,6 @@ describe("formatCliFailureLines", () => {
"[openclaw] Stack:",
"[openclaw] Error: boom",
]);
expect(lines.some((line) => line.includes("Error: boom"))).toBe(true);
expect(lines.join("\n")).toContain("Error: boom");
});
});

View File

@@ -31,7 +31,7 @@ function requireMockCallArg(
}
function expectRuntimeLogIncludes(fragment: string) {
expect(runtimeLogs.some((log) => log.includes(fragment))).toBe(true);
expect(runtimeLogs.join("\n")).toContain(fragment);
}
describe("persistPluginInstall", () => {