testUiOutputKeepsStacks

tcmts.cli.sync.testUiOutputKeepsStacks · #ypavjiek · term

import { uiOutput } from "#codebase/tcmts/cli/sync";
import assert from "node:assert/strict";

export const testUiOutputKeepsStacks = () => {
  const out = uiOutput();
  assert.deepEqual(out("  url      http://127.0.0.1:1/forge/\n  → #abc rendered 12ms\n"), [
    "url      http://127.0.0.1:1/forge/",
  ]);
  // an uncaught error, as Node prints it, split between chunks: its stack comes with it, the rest doesn't
  assert.deepEqual(
    out(
      "file:///x.js:3\n    rec.params\n        ^\n\nTypeError: Cannot read properties of undefined (reading 'params')\n    at handle (file:///x.js:3:9)\n    at proc",
    ),
    [
      "TypeError: Cannot read properties of undefined (reading 'params')",
      "    at handle (file:///x.js:3:9)",
    ],
  );
  assert.deepEqual(out("ess (node:internal/x:1:1)\n\nNode.js v24.15.0\n    at not-a-stack\n"), [
    "    at process (node:internal/x:1:1)",
  ]);
  assert.deepEqual(out("  → #def rendered 8252ms\n"), ["→ #def rendered 8252ms"]);
}

uses