headlamp 0.1.15 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -69,6 +69,22 @@ npx headlamp --onlyFailures
69
69
  npx headlamp --changed --onlyFailures
70
70
  ```
71
71
 
72
+ - `--showConsole[=true|false]`:
73
+ - When enabled, Headlamp prints a dedicated "Logs" section under each failing test and failing file with the full console output captured by the runner.
74
+ - By default (without this flag), Headlamp shows a condensed "Console errors" snippet with only the most relevant error messages. `--showConsole` includes all console entries (log/info/warn/error).
75
+ - Supported forms: `--showConsole`, `--showConsole=true`, `--showConsole=false`.
76
+ - Works alongside `--onlyFailures`, coverage flags, and selection flags.
77
+
78
+ Examples:
79
+
80
+ ```bash
81
+ # Always include the full console output for each failure
82
+ npx headlamp --showConsole
83
+
84
+ # Combine with only failures visible during the run
85
+ npx headlamp --onlyFailures --showConsole
86
+ ```
87
+
72
88
  ## Changed-file selection
73
89
 
74
90
  - `--changed[=mode]` selects tests by files changed in your working tree or branch.
package/dist/cli.cjs CHANGED
@@ -249,6 +249,7 @@ var init_args = __esm({
249
249
  coverageUi: (value) => ({ type: "coverageUi", value }),
250
250
  coverageAbortOnFailure: (value) => ({ type: "coverageAbortOnFailure", value }),
251
251
  onlyFailures: (value) => ({ type: "onlyFailures", value }),
252
+ showConsole: (value) => ({ type: "showConsole", value }),
252
253
  jestArg: (value) => ({ type: "jestArg", value }),
253
254
  jestArgs: (values) => ({ type: "jestArgs", values }),
254
255
  vitestArg: (value) => ({ type: "vitestArg", value }),
@@ -415,6 +416,18 @@ var init_args = __esm({
415
416
  "--onlyFailures",
416
417
  (_flag, lookahead) => step([ActionBuilders.onlyFailures(isTruthy(String(lookahead)))], true)
417
418
  ),
419
+ // --showConsole flag (boolean)
420
+ rule.eq("--showConsole", () => step([ActionBuilders.showConsole(true)])),
421
+ rule.startsWith(
422
+ "--showConsole=",
423
+ (value) => step([
424
+ ActionBuilders.showConsole(isTruthy((value.split("=")[1] ?? "").trim().toLowerCase()))
425
+ ])
426
+ ),
427
+ rule.withLookahead(
428
+ "--showConsole",
429
+ (_flag, lookahead) => step([ActionBuilders.showConsole(isTruthy(String(lookahead)))], true)
430
+ ),
418
431
  rule.withLookahead(
419
432
  "--testPathPattern",
420
433
  (flag, lookahead) => step([ActionBuilders.jestArgs([flag, lookahead])], true)
@@ -573,6 +586,8 @@ var init_args = __esm({
573
586
  return { vitest: [], jest: [], coverage: false, coverageAbortOnFailure: action.value };
574
587
  case "onlyFailures":
575
588
  return { vitest: [], jest: [], coverage: false, onlyFailures: action.value };
589
+ case "showConsole":
590
+ return { vitest: [], jest: [], coverage: false, showConsole: action.value };
576
591
  case "jestArgs":
577
592
  return { vitest: [], jest: action.values, coverage: false };
578
593
  case "selectionHint":
@@ -648,6 +663,7 @@ var init_args = __esm({
648
663
  ...right.changedDepth !== void 0 || left.changedDepth !== void 0 ? { changedDepth: right.changedDepth ?? left.changedDepth } : {},
649
664
  ...right.coverageAbortOnFailure !== void 0 || left.coverageAbortOnFailure !== void 0 ? { coverageAbortOnFailure: right.coverageAbortOnFailure ?? left.coverageAbortOnFailure } : {},
650
665
  ...right.onlyFailures !== void 0 || left.onlyFailures !== void 0 ? { onlyFailures: right.onlyFailures ?? left.onlyFailures } : {},
666
+ ...right.showConsole !== void 0 || left.showConsole !== void 0 ? { showConsole: right.showConsole ?? left.showConsole } : {},
651
667
  ...right.coverageDetail !== void 0 || left.coverageDetail !== void 0 ? { coverageDetail: right.coverageDetail ?? left.coverageDetail } : {},
652
668
  ...right.coverageShowCode !== void 0 || left.coverageShowCode !== void 0 ? { coverageShowCode: right.coverageShowCode ?? left.coverageShowCode } : {},
653
669
  ...right.coverageMode !== void 0 || left.coverageMode !== void 0 ? { coverageMode: right.coverageMode ?? left.coverageMode } : {},
@@ -672,6 +688,7 @@ var init_args = __esm({
672
688
  let coverageUi = "both";
673
689
  let coverageAbortOnFailure = false;
674
690
  let onlyFailures = false;
691
+ let showConsole = false;
675
692
  let coverageShowCode = Boolean(process.stdout.isTTY);
676
693
  let coverageMode = "auto";
677
694
  const coverageMaxFilesLocalInit = void 0;
@@ -690,6 +707,7 @@ var init_args = __esm({
690
707
  coverageUi = contrib.coverageUi ?? coverageUi;
691
708
  coverageAbortOnFailure = contrib.coverageAbortOnFailure ?? coverageAbortOnFailure;
692
709
  onlyFailures = contrib.onlyFailures ?? onlyFailures;
710
+ showConsole = contrib.showConsole ?? showConsole;
693
711
  coverageShowCode = contrib.coverageShowCode ?? coverageShowCode;
694
712
  const coverageDetailComputed = contrib.coverageDetail ?? (contrib.selection ? "auto" : void 0);
695
713
  coverageMode = contrib.coverageMode ?? (contrib.selection ? "compact" : "auto");
@@ -724,6 +742,7 @@ var init_args = __esm({
724
742
  coverageUi,
725
743
  coverageAbortOnFailure,
726
744
  onlyFailures,
745
+ showConsole,
727
746
  selectionSpecified: Boolean(contrib.selection),
728
747
  selectionPaths: [...contrib.selectionPaths ?? []],
729
748
  includeGlobs,
@@ -5089,24 +5108,43 @@ var buildStackSection = (mergedForStack, ctx, fallbackLoc) => {
5089
5108
  };
5090
5109
  var MAX_CONSOLE_ERRORS_TO_SHOW = 3;
5091
5110
  var isConsoleEntry = (candidate) => typeof candidate === "object" && candidate !== null;
5092
- var buildConsoleSection = (maybeConsole) => {
5111
+ var buildConsoleSection = (maybeConsole, opts) => {
5093
5112
  const out = [];
5094
5113
  if (!Array.isArray(maybeConsole)) {
5095
5114
  return out;
5096
5115
  }
5097
5116
  const entries = maybeConsole.filter(isConsoleEntry);
5098
- const errorsOnly = entries.filter((entry) => String(entry?.type ?? "").toLowerCase() === "error");
5099
- const scored = errorsOnly.map((entry) => {
5100
- const raw = entry?.message;
5101
- const msg = Array.isArray(raw) ? raw.map(String).join(" ") : typeof raw === "string" ? raw : String(raw ?? "");
5102
- return { msg, score: msg.length };
5103
- }).filter((item) => item.msg.trim().length > 0).sort((left, right) => right.score - left.score).slice(0, MAX_CONSOLE_ERRORS_TO_SHOW);
5104
- if (scored.length) {
5105
- out.push(ansi.dim(" Console errors:"));
5106
- for (const item of scored) {
5107
- out.push(` ${ansi.dim("\u2022")} ${item.msg}`);
5117
+ if (opts?.full) {
5118
+ const toMsg = (entry) => {
5119
+ const type = String(entry?.type ?? "").toLowerCase();
5120
+ const raw = entry?.message;
5121
+ const msg = Array.isArray(raw) ? raw.map(String).join(" ") : typeof raw === "string" ? raw : String(raw ?? "");
5122
+ const origin = String(entry?.origin ?? "");
5123
+ const typeFmt = type ? `${ansi.white(type)}: ` : "";
5124
+ const originFmt = origin ? ` ${ansi.dim(`(${origin})`)}` : "";
5125
+ return ` ${ansi.dim("\u2022")} ${typeFmt}${msg}${originFmt}`;
5126
+ };
5127
+ const lines = entries.map(toMsg).filter((ln) => stripAnsiSimple(ln).trim().length > 0);
5128
+ if (lines.length) {
5129
+ out.push(ansi.dim(" Logs:"));
5130
+ out.push(...lines, "");
5131
+ }
5132
+ } else {
5133
+ const errorsOnly = entries.filter(
5134
+ (entry) => String(entry?.type ?? "").toLowerCase() === "error"
5135
+ );
5136
+ const scored = errorsOnly.map((entry) => {
5137
+ const raw = entry?.message;
5138
+ const msg = Array.isArray(raw) ? raw.map(String).join(" ") : typeof raw === "string" ? raw : String(raw ?? "");
5139
+ return { msg, score: msg.length };
5140
+ }).filter((item) => item.msg.trim().length > 0).sort((left, right) => right.score - left.score).slice(0, MAX_CONSOLE_ERRORS_TO_SHOW);
5141
+ if (scored.length) {
5142
+ out.push(ansi.dim(" Console errors:"));
5143
+ for (const item of scored) {
5144
+ out.push(` ${ansi.dim("\u2022")} ${item.msg}`);
5145
+ }
5146
+ out.push("");
5108
5147
  }
5109
- out.push("");
5110
5148
  }
5111
5149
  return out;
5112
5150
  };
@@ -5168,8 +5206,8 @@ var buildThrownSection = (details) => {
5168
5206
  }
5169
5207
  };
5170
5208
  const candidates = [];
5171
- for (const d of details) {
5172
- const obj = d && typeof d === "object" ? d : null;
5209
+ for (const detailEntry of details) {
5210
+ const obj = detailEntry && typeof detailEntry === "object" ? detailEntry : null;
5173
5211
  if (obj && obj.error && typeof obj.error === "object") {
5174
5212
  const err = obj.error;
5175
5213
  if (typeof err.name === "string") {
@@ -5366,7 +5404,7 @@ var renderChunks = (chunks, ctx, fns, opts) => {
5366
5404
 
5367
5405
  // src/lib/formatter/context.ts
5368
5406
  var fs5 = __toESM(require("node:fs"), 1);
5369
- var makeCtx = (opts, showStacks = false) => {
5407
+ var makeCtx = (opts, showStacks = false, showConsole = false) => {
5370
5408
  const cwd = (opts?.cwd ?? process.cwd()).replace(/\\/g, "/");
5371
5409
  const width = Math.max(
5372
5410
  40,
@@ -5382,7 +5420,15 @@ var makeCtx = (opts, showStacks = false) => {
5382
5420
  return [];
5383
5421
  }
5384
5422
  };
5385
- return { cwd, width, showStacks, projectHint, editorCmd: opts?.editorCmd, readSource: readSource2 };
5423
+ return {
5424
+ cwd,
5425
+ width,
5426
+ showStacks,
5427
+ showConsole,
5428
+ projectHint,
5429
+ editorCmd: opts?.editorCmd,
5430
+ readSource: readSource2
5431
+ };
5386
5432
  };
5387
5433
 
5388
5434
  // src/lib/formatter/bridge/tryBridgeFallback.ts
@@ -5704,7 +5750,9 @@ var renderFileLevelFailure = (file, ctx) => {
5704
5750
  suppressDiff: pretty.length > 0,
5705
5751
  stackPreview
5706
5752
  });
5707
- const consoleBlock = buildConsoleSection(stripBridgeEventsFromConsole(file.console ?? null));
5753
+ const consoleBlock = buildConsoleSection(stripBridgeEventsFromConsole(file.console ?? null), {
5754
+ full: Boolean(ctx.showConsole)
5755
+ });
5708
5756
  const stackTail = ctx.showStacks && stackPreview.length === 0 ? (() => {
5709
5757
  const tail = mergedForStack.filter((ln) => isStackLine(stripAnsiSimple(ln))).slice(-4).map((ln) => ` ${colorStackLine(String(ln), ctx.projectHint)}`);
5710
5758
  return tail.length ? [ansi.dim(" Stack:"), ...tail, ""] : empty;
@@ -6019,7 +6067,9 @@ var renderFailedAssertion = (args) => {
6019
6067
  return empty;
6020
6068
  }
6021
6069
  })() : empty;
6022
- const consoleBlock = buildConsoleSection(stripBridgeEventsFromConsole(file.console ?? null));
6070
+ const consoleBlock = buildConsoleSection(stripBridgeEventsFromConsole(file.console ?? null), {
6071
+ full: Boolean(ctx.showConsole)
6072
+ });
6023
6073
  const stackTail = ctx.showStacks && stackPreview.length === 0 ? (() => {
6024
6074
  const merged = collapseStacks([...msgLines, ...details.stacks]);
6025
6075
  const tail = collapseStacks(merged).filter((ln) => isStackLine(stripAnsiSimple(ln))).slice(-4).map((ln) => ` ${colorStackLine(String(ln), ctx.projectHint)}`);
@@ -6116,7 +6166,11 @@ var formatJestOutputVitest = (raw, opts) => pipe(
6116
6166
  { raw, opts },
6117
6167
  (state) => ({
6118
6168
  ...state,
6119
- ctx: makeCtx(state.opts, /\bFAIL\b/.test(stripAnsiSimple(state.raw)))
6169
+ ctx: makeCtx(
6170
+ state.opts,
6171
+ /\bFAIL\b/.test(stripAnsiSimple(state.raw)),
6172
+ Boolean(state.opts?.showConsole)
6173
+ )
6120
6174
  }),
6121
6175
  (state) => ({ ...state, chunks: parseChunks(state.raw) }),
6122
6176
  (state) => ({
@@ -6471,6 +6525,7 @@ var program = async () => {
6471
6525
  coverageUi,
6472
6526
  coverageAbortOnFailure,
6473
6527
  onlyFailures,
6528
+ showConsole,
6474
6529
  selectionSpecified,
6475
6530
  selectionPaths,
6476
6531
  includeGlobs,
@@ -7173,7 +7228,8 @@ var program = async () => {
7173
7228
  reordered,
7174
7229
  makeCtx(
7175
7230
  { cwd: repoRootForDiscovery, ...editorCmd !== void 0 ? { editorCmd } : {} },
7176
- /\bFAIL\b/.test(stripAnsiSimple(output))
7231
+ /\bFAIL\b/.test(stripAnsiSimple(output)),
7232
+ Boolean(showConsole)
7177
7233
  ),
7178
7234
  { onlyFailures }
7179
7235
  );
@@ -7182,7 +7238,8 @@ var program = async () => {
7182
7238
  bridge,
7183
7239
  makeCtx(
7184
7240
  { cwd: repoRootForDiscovery, ...editorCmd !== void 0 ? { editorCmd } : {} },
7185
- /\bFAIL\b/.test(stripAnsiSimple(output))
7241
+ /\bFAIL\b/.test(stripAnsiSimple(output)),
7242
+ Boolean(showConsole)
7186
7243
  ),
7187
7244
  { onlyFailures }
7188
7245
  );
@@ -7284,7 +7341,8 @@ ${stripFooter(rawAlso)}`.trimEnd();
7284
7341
  unified,
7285
7342
  makeCtx(
7286
7343
  { cwd: repoRootForDiscovery, ...editorCmd !== void 0 ? { editorCmd } : {} },
7287
- showStacks
7344
+ showStacks,
7345
+ Boolean(showConsole)
7288
7346
  ),
7289
7347
  { onlyFailures }
7290
7348
  );