diff --git a/packages/coding-agent/test/tiny-models-cli.test.ts b/packages/coding-agent/test/tiny-models-cli.test.ts index 363d1eeba..f3acdd520 100644 --- a/packages/coding-agent/test/tiny-models-cli.test.ts +++ b/packages/coding-agent/test/tiny-models-cli.test.ts @@ -50,4 +50,29 @@ describe("tiny-models download model resolution", () => { results: [{ model: "lfm2-700m", ok: false, error: "Error: runtime install failed\n at worker" }], }); }); + + it("includes worker error details in text failures", async () => { + const output: string[] = []; + const isTtyDescriptor = Object.getOwnPropertyDescriptor(process.stdout, "isTTY"); + Object.defineProperty(process.stdout, "isTTY", { configurable: true, value: false }); + spyOn(process.stdout, "write").mockImplementation((chunk: string | Uint8Array) => { + output.push(typeof chunk === "string" ? chunk : new TextDecoder().decode(chunk)); + return true; + }); + spyOn(tinyTitleClient, "downloadModel").mockResolvedValue({ + ok: false, + error: "Error: runtime install failed\n at worker", + }); + + try { + await expect( + runTinyModelsCommand({ action: "download", model: "lfm2-700m", flags: {} }), + ).rejects.toThrow("One or more tiny title models failed to download"); + } finally { + if (isTtyDescriptor) Object.defineProperty(process.stdout, "isTTY", isTtyDescriptor); + else delete (process.stdout as typeof process.stdout & { isTTY?: boolean }).isTTY; + } + + expect(output.join("")).toContain("Failed to download LFM2 700M: runtime install failed."); + }); });