|
1 | 1 | import { spawn } from "node:child_process"; |
2 | | -import { mkdtempSync, readdirSync, readFileSync, rmSync } from "node:fs"; |
| 2 | +import { mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; |
3 | 3 | import { tmpdir } from "node:os"; |
4 | 4 | import { dirname, join } from "node:path"; |
5 | 5 | import { fileURLToPath } from "node:url"; |
@@ -250,6 +250,18 @@ describe("agent-mode contract", () => { |
250 | 250 | expect(run.stdout).toContain("No composition found"); |
251 | 251 | }); |
252 | 252 |
|
| 253 | + it("a render that fails under --json prints only the envelope on stdout", async () => { |
| 254 | + const project = join(home, "render-json"); |
| 255 | + mkdirSync(project, { recursive: true }); |
| 256 | + writeFileSync(join(project, "index.html"), "<!doctype html><html><body></body></html>"); |
| 257 | + const run = await runAsAgent(["render", project, "--variables", "{bad", "--json"]); |
| 258 | + expectQuiet(run); |
| 259 | + expect(run.code, run.stderr).toBe(1); |
| 260 | + expect(run.stdout.trim().split("\n")).toHaveLength(1); |
| 261 | + expectJsonFailure(run, "runtime_error"); |
| 262 | + expect(JSON.parse(run.stdout).error.message).toBe("Invalid JSON in --variables"); |
| 263 | + }); |
| 264 | + |
253 | 265 | it("an unknown command under --json is an envelope with the suggestion", async () => { |
254 | 266 | const run = await runAsAgent(["rendr", "--json"]); |
255 | 267 | expect(run.code).toBe(2); |
|
0 commit comments