testOutputIsShort
Listings cut long signatures to one line; reports say a lot of sameness in a line.
import { cutSignature, listed, printDependents } from "#codebase/tcmts/cli/main"; import assert from "node:assert/strict"; export const testOutputIsShort = () => { assert.equal(cutSignature(": { a: number;\n b: string }"), ": { a: number; b: string }"); assert.equal(cutSignature("x".repeat(200), 10), "xxxxxxxxx…"); assert.equal(listed(["a", "b", "c"], 2), "a, b, and 1 more"); const lines: string[] = []; const log = console.log; const colour = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g"); console.log = (s: string) => void lines.push(s.replace(colour, "")); // (not brief, as a command an agent's tool runs is: that's just how many) const brief = process.env.TCM_BRIEF; delete process.env.TCM_BRIEF; try { printDependents(["lib.a", "lib.b", "lib.c", "lib.d", "lib.e", "lib.f", "app.g"]); } finally { console.log = log; if (brief !== undefined) process.env.TCM_BRIEF = brief; } assert.match(lines[0]!, /~ updated +7 dependents/); assert.equal(lines[1]!.trim(), "lib 6: a, b, c, d, e, and 1 more"); assert.equal(lines[2]!.trim(), "app 1: g"); }