Skip to content

Commit bdfde5a

Browse files
committed
🐛 Assert #870's failure row against the reason it recorded, not a phrase
UI13 asserted the drawn reason contained "Unexpected reserved word". That is V8 speaking: Deno compiles an eval block itself, while Node and Bun reach it through esbuild and say "Transform failed with 1 error". The fixture is the same real compiler failure in all three, so the row was green on the runtime it was written on and red on the two it was not — `test-node (2/10)` and `test-bun (1/5)`. The row now compares what is drawn with what this run actually retained: the displayed reason has to be the beginning of the recorded message, flattened to one line and cut to its region. The expected answer is derived here rather than by calling the production formatter, so the row still fails if that formatter stops normalizing or stops bounding. Everything else it claimed is untouched: the one-line rule, the region bound, the three-size rendered geometry, that it is the message and not the serialized record around it, and that a cold projection answers with the identical row. Omitting the reason reddens it, and so does replacing it with unrelated text.
1 parent df98bf0 commit bdfde5a

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

‎packages/cli/tests/repl-entries.test.ts‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2969,9 +2969,16 @@ describe("REPL entries: what a failed entry says it failed with", () => {
29692969
// below asserts that against the real placement at three sizes.
29702970
expect(failed?.includes("\n")).toBe(false);
29712971
expect((failed ?? "").length).toBeLessThanOrEqual(surfaceWidth(WIDE));
2972-
// It begins with what the reason begins with, which is the part a reader
2973-
// can act on, and it is not the serialized record.
2974-
expect(failed).toContain("Unexpected reserved word");
2972+
// What is drawn is the *recorded* reason, flattened and cut — compared
2973+
// against the message this run actually produced rather than against a
2974+
// phrase. The phrase is the engine's: Deno compiles an eval block with V8
2975+
// and says "Unexpected reserved word", while Node and Bun reach it through
2976+
// esbuild and say "Transform failed". Asserting either one makes this row a
2977+
// claim about whichever runtime happened to write it.
2978+
const shown = (failed ?? "").slice("failed: ".length).replace(/…$/, "");
2979+
expect(shown.length).toBeGreaterThan(0);
2980+
expect(recorded.replace(/\s+/g, " ").trim().startsWith(shown)).toBe(true);
2981+
// And it is the message, not the serialized record around it.
29752982
expect(failed).not.toContain("stack");
29762983
expect(failed).not.toContain('"name"');
29772984

0 commit comments

Comments
 (0)