MCPcopy Create free account
hub / github.com/TestSprite/testsprite-cli / printRunOrChain

Function printRunOrChain

src/commands/test.ts:4358–4377  ·  view source on GitHub ↗

* Print the trigger/run response, merging the create context when the * caller is the `test create --run` chain. Per codex round-1 P1: chained * `--output json` must produce ONE parseable JSON object on stdout, not * two back-to-back envelopes. With `createContext` set, JSON mode emits * `{ ...c

(
  out: Output,
  payload: T,
  createContext: CliCreateTestResponse | CliCreateFromPlanResponse | undefined,
  textRenderer?: (data: unknown) => string,
)

Source from the content-addressed store, hash-verified

4356 * summary first, then the run.
4357 */
4358function printRunOrChain<T>(
4359 out: Output,
4360 payload: T,
4361 createContext: CliCreateTestResponse | CliCreateFromPlanResponse | undefined,
4362 textRenderer?: (data: unknown) => string,
4363): void {
4364 if (!createContext) {
4365 out.print(payload, textRenderer);
4366 return;
4367 }
4368 const merged = { ...createContext, run: payload };
4369 out.print(merged, () => {
4370 // Text mode of the chain: render the create envelope as a header,
4371 // a blank line, then the run envelope below. Stays readable for
4372 // operators while JSON mode owns the parseable contract.
4373 const createText = renderCreateText(createContext as CliCreateTestResponse);
4374 const runText = textRenderer ? textRenderer(payload) : JSON.stringify(payload, null, 2);
4375 return `${createText}\n\n${runText}`;
4376 });
4377}
4378
4379/**
4380 * Enrich a terminal RunResponse with a client-synthesized Portal deep link.

Callers 1

runTestRunFunction · 0.85

Calls 2

renderCreateTextFunction · 0.85
printMethod · 0.80

Tested by

no test coverage detected