diff --git a/e2e/create-expert/create-expert.test.ts b/e2e/create-expert/create-expert.test.ts index a7476995..3a6f0e23 100644 --- a/e2e/create-expert/create-expert.test.ts +++ b/e2e/create-expert/create-expert.test.ts @@ -66,6 +66,20 @@ function getAllCalledToolNames(result: RunResult): string[] { ) } +/** Build a diagnostic string from RunResult for assertion failure messages */ +function diagnostics(result: RunResult): string { + const errorEvents = result.events + .filter((e) => e.type === "stopRunByError") + .map((e) => { + const err = (e as { error?: { name: string; message: string } }).error + return err ? `${err.name}: ${err.message}` : "unknown error" + }) + const parts = [`exitCode=${result.exitCode}`] + if (result.stderr) parts.push(`stderr=${result.stderr.slice(0, 500)}`) + if (errorEvents.length > 0) parts.push(`errors=[${errorEvents.join(", ")}]`) + return parts.join("\n") +} + describe("create-expert", () => { it( "should create a new perstack.toml", @@ -77,7 +91,7 @@ describe("create-expert", () => { tempDir, ) - expect(result.exitCode).toBe(0) + expect(result.exitCode, diagnostics(result)).toBe(0) // Verify control flow: coordinator starts, delegates, then completes const controlFlow = result.events @@ -143,7 +157,7 @@ pick = ["attemptCompletion"] const result = await runCreateExpert("Add a testing expert that runs unit tests", tempDir) - expect(result.exitCode).toBe(0) + expect(result.exitCode, diagnostics(result)).toBe(0) // Verify control flow: start → delegate → complete expect(