Skip to content

Commit 4a75d10

Browse files
committed
Fix e2e history test: find result line in NDJSON output
The history command outputs multiple NDJSON lines (events + result + completed status). Parse the line with type "result" instead of assuming it's the first line.
1 parent ff9606d commit 4a75d10

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

test/e2e/channels/channels-e2e.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,13 @@ describe("Channel E2E Tests", () => {
342342

343343
let result;
344344
try {
345-
// The --json output is NDJSON (result line + completed status line).
346-
// Parse the first non-empty line which contains the result data.
347-
// The last line is the completed status signal.
348-
const line = historyResult.stdout.trim().split("\n").find(Boolean);
349-
result = JSON.parse(line);
345+
// The --json output is NDJSON: event lines, then a result line, then a completed status.
346+
// Find the line with type "result" which contains the history data.
347+
const lines = historyResult.stdout.trim().split("\n").filter(Boolean);
348+
const resultLine = lines
349+
.map((l) => JSON.parse(l))
350+
.find((obj) => obj.type === "result");
351+
result = resultLine;
350352
} catch (parseError) {
351353
throw new Error(
352354
`Failed to parse JSON history output. Parse error: ${String(parseError)}. Exit code: ${historyResult.exitCode}, Stderr: ${historyResult.stderr}, Stdout: ${historyResult.stdout}`,

0 commit comments

Comments
 (0)