reporting-labs 0.6.21 → 0.6.23

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
@@ -2,6 +2,7 @@
2
2
 
3
3
  <p align="center">
4
4
  <a href="https://www.npmjs.com/package/reporting-labs"><img src="https://img.shields.io/npm/v/reporting-labs.svg?label=npm" alt="npm"></a>
5
+ <a href="https://npm-stat.com/charts.html?package=reporting-labs&from=2026-09-18"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fnaveenautomationlabs.github.io%2Freporting-labs%2Fbadges%2Fnpm-downloads.json" alt="npm downloads"></a>
5
6
  <a href="https://reportinglabs.dev"><img src="https://img.shields.io/badge/docs-reportinglabs.dev-1A56DB.svg" alt="Docs"></a>
6
7
  <a href="https://reportinglabs.dev/support"><img src="https://img.shields.io/badge/%E2%99%A5%20Support-reportingLabs-E5405E?style=flat" alt="Support reportingLabs"></a>
7
8
  </p>
@@ -228,6 +229,10 @@ Each call shows in the test detail and in the **API** tab with method, URL, stat
228
229
 
229
230
  If you do not use the config file, add `import 'reporting-labs/auto'` at the top of `playwright.config.ts` instead.
230
231
 
232
+ ### What the browser saw
233
+
234
+ The same import also listens to the browser while a test runs. Uncaught JavaScript errors from the app, `console.error` messages and requests that failed or got a 4xx/5xx are recorded with their time. On a failed test they show under **What the browser saw**, timed against the failure ("HTTP 500 · POST /api/cart/coupon · 3.0s before the failure", "JS error · Cannot read properties of undefined"), so a UI failure caused by the backend or by a crash in the app reads as that, not as "element not found".
235
+
231
236
  Only calls that do not go through Playwright (Node `fetch`, axios, a Java service) need a manual record:
232
237
 
233
238
  ```ts
@@ -312,6 +317,7 @@ are right; data tables and the steps left unrun need 8+.
312
317
  ### Failures: everything you need to triage
313
318
 
314
319
  - **Bug report** button on every failed test: a ready-to-paste ticket with priority, owner, story, environment, test data, steps to reproduce (taken from the test's own steps, the failing one marked), expected vs actual, the error, API calls and attachment names. Pick Markdown, Jira or plain text, edit if you like, copy or download.
320
+ - **Video in step with the test**: with `video` on, a test's video sits above its steps. Click ▶ on any step to watch that moment, or **Watch the failure** to see the 5 seconds before it; the step playing lights up as the video runs.
315
321
  - **Run again**: every test shows the command that runs just that test, with a Copy button, e.g. `npx playwright test tests/checkout.spec.ts:12 --project=chromium`. **Copy re-run command** on the Failures tab does the same for all failed tests at once. With playwright-bdd it runs `npx bddgen` first; Cypress and WebdriverIO re-run the spec file (`--spec`).
316
322
  - **By owner**: who to ping, with failed and flaky counts. Click an owner to filter.
317
323
  - **Download CSV / JSON**: all failed and flaky tests with title, spec, project, priority, owner, ticket, attempts, duration, first error line and new/known status. Ready for Jira or a sheet.
@@ -448,7 +454,7 @@ Every option is optional. `npx reporting-labs init` writes them all, with commen
448
454
  | `jsonFile` | `'report.json'` | File name of the JSON blob |
449
455
  | `pdf` | `true` | Also write `report.pdf` (light theme, print-ready), printed by Playwright's Chromium or an installed Chrome / Edge, whatever browser the tests ran on. `false` turns it off; `{ file: 'run.pdf' }` renames it; `{ chromePath }` (or `CHROME_PATH`) names the browser. The Export PDF button in the report works either way |
450
456
  | `embedFonts` | `true` | Bundle the fonts (~140 KB) so it looks the same offline |
451
- | `announce` | `true` | Print the report path after the run |
457
+ | `announce` | `true` | Print the report path after the run. On a developer's machine (never in CI) it also asks for a GitHub star, at most once a week; `REPORTING_LABS_NO_STAR=1` turns only that off |
452
458
  | `open` | `'on-failure'` | Open the report in the browser after the run: `'on-failure'`, `'always'` or `'never'`. Never opens in CI |
453
459
  | `commentMeta` | `true` | Also read meta from the comment above a test or `describe` (`/** @priority P0 @owner naveen */`). `meta()` wins when both are there. `false` reads no comments |
454
460
  | `warnMissingMeta` | `true` | After the run, list the tests that have no meta (no `meta()` and no comment) in the console, so nobody on the team forgets |
package/dist/auto.js CHANGED
@@ -154,6 +154,65 @@ function patchContext(ctx) {
154
154
  };
155
155
  proto[PATCHED] = true;
156
156
  }
157
+ /* ---------- what the browser saw ---------- */
158
+ const WATCHED = '__reportingLabsBrowserEvents';
159
+ const MAX_EVENTS = 50; // per test attempt: a page that logs an error every frame stays readable
160
+ const seen = new Map();
161
+ const oneLine = (s, max = 2000) => String(s ?? '').replace(/\u001b\[[0-9;]*m/g, '').slice(0, max);
162
+ /** One browser event, attached to the running test with its time. Nothing while no test runs. */
163
+ function note(ev) {
164
+ const info = currentTest();
165
+ if (!info)
166
+ return;
167
+ const key = info.testId + ':' + info.retry;
168
+ const n = (seen.get(key) ?? 0) + 1;
169
+ seen.set(key, n);
170
+ if (n > MAX_EVENTS)
171
+ return;
172
+ info.attach('rl:browser', { body: JSON.stringify({ t: Date.now(), ...ev }), contentType: 'application/x-rl-browser' }).catch(() => { });
173
+ }
174
+ /** Listen to a browser context: uncaught page errors, console.error, and requests that failed or got 4xx/5xx. */
175
+ function watchContext(ctx) {
176
+ if (!ctx || typeof ctx.on !== 'function' || ctx[WATCHED])
177
+ return;
178
+ ctx[WATCHED] = true;
179
+ const onPage = (page) => {
180
+ page.on('pageerror', (err) => note({ kind: 'error', text: oneLine(err?.message || err), stack: oneLine(err?.stack, 4000), url: safe(() => page.url()) }));
181
+ page.on('console', (msg) => {
182
+ if (msg.type() !== 'error')
183
+ return;
184
+ // the browser's own note for a request that got 4xx/5xx: the request is already listed
185
+ if (/^Failed to load resource\b/.test(String(msg.text())))
186
+ return;
187
+ const loc = safe(() => msg.location());
188
+ note({ kind: 'console', text: oneLine(msg.text()), url: loc?.url ? `${loc.url}${loc.lineNumber ? ':' + loc.lineNumber : ''}` : undefined });
189
+ });
190
+ };
191
+ try {
192
+ for (const p of ctx.pages())
193
+ onPage(p);
194
+ }
195
+ catch { /* no pages yet */ }
196
+ ctx.on('page', onPage);
197
+ ctx.on('requestfailed', (req) => {
198
+ const why = safe(() => req.failure()?.errorText);
199
+ if (why && /ERR_ABORTED|NS_BINDING_ABORTED|cancelled/i.test(why))
200
+ return; // navigating away, not an app problem
201
+ note({ kind: 'request', method: req.method(), url: req.url(), text: why || 'Request failed' });
202
+ });
203
+ ctx.on('response', (res) => {
204
+ const status = res.status();
205
+ if (status < 400 || /\/favicon\.ico(\?|$)/.test(res.url()))
206
+ return;
207
+ note({ kind: 'request', method: safe(() => res.request().method()), url: res.url(), status, text: safe(() => res.statusText()) || '' });
208
+ });
209
+ }
210
+ function safe(fn) { try {
211
+ return fn();
212
+ }
213
+ catch {
214
+ return undefined;
215
+ } }
157
216
  /** Wrap `obj[name]` (found on the prototype chain) so `after(result)` sees each resolved return value. */
158
217
  function wrapAsync(obj, name, after) {
159
218
  let proto = obj;
@@ -198,11 +257,14 @@ function install() {
198
257
  const onBrowser = (browser) => {
199
258
  if (!browser || typeof browser.newContext !== 'function')
200
259
  return;
201
- wrapAsync(browser, 'newContext', ctx => ctx?.request && patchContext(ctx.request));
260
+ wrapAsync(browser, 'newContext', ctx => { if (ctx?.request)
261
+ patchContext(ctx.request); watchContext(ctx); });
202
262
  try {
203
- for (const ctx of browser.contexts())
263
+ for (const ctx of browser.contexts()) {
204
264
  if (ctx?.request)
205
265
  patchContext(ctx.request);
266
+ watchContext(ctx);
267
+ }
206
268
  }
207
269
  catch { /* not a browser */ }
208
270
  };
@@ -212,7 +274,8 @@ function install() {
212
274
  wrapAsync(bt, 'launch', onBrowser);
213
275
  wrapAsync(bt, 'connect', onBrowser);
214
276
  wrapAsync(bt, 'connectOverCDP', onBrowser);
215
- wrapAsync(bt, 'launchPersistentContext', ctx => ctx?.request && patchContext(ctx.request));
277
+ wrapAsync(bt, 'launchPersistentContext', ctx => { if (ctx?.request)
278
+ patchContext(ctx.request); watchContext(ctx); });
216
279
  }
217
280
  }
218
281
  install();
@@ -62,6 +62,7 @@ export default class ReportingLabsReporter implements Reporter {
62
62
  private outcome;
63
63
  private titlePath;
64
64
  private serializeResult;
65
+ private browserEvent;
65
66
  private serializeStep;
66
67
  private serializeAttachment;
67
68
  }
package/dist/reporter.js CHANGED
@@ -47,11 +47,12 @@ const mask_1 = require("./mask");
47
47
  const explain_1 = require("./explain");
48
48
  const pdf_1 = require("./pdf");
49
49
  const bdd_1 = require("./bdd");
50
+ const star_1 = require("./star");
50
51
  const comments_1 = require("./comments");
51
52
  const DEFAULT_EMBED_LIMIT = 2 * 1024 * 1024;
52
53
  /** Attach steps created by log() and the automatic API capture; the data shows in its own section, so hide the step. */
53
54
  function isInternalAttach(s) {
54
- return s.category === 'test.attach' && /^Attach "(rl:log|(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS) )/.test(s.title);
55
+ return s.category === 'test.attach' && /^Attach "(rl:log|rl:browser|(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS) )/.test(s.title);
55
56
  }
56
57
  /** Playwright 1.63+ moved the target out of the title: title `Click`, subtitle `getByRole('button')`; title `Navigate`,
57
58
  * subtitle `/login`. Put it back next to the title, as the report showed before. A test.step's own subtitle and
@@ -282,6 +283,11 @@ class ReportingLabsReporter {
282
283
  }
283
284
  if (this.options.pdf !== false)
284
285
  await this.writePdf(file);
286
+ if (this.options.announce !== false) {
287
+ const star = (0, star_1.starLine)();
288
+ if (star)
289
+ console.log(star + '\n');
290
+ }
285
291
  this.maybeOpen(file, result);
286
292
  }
287
293
  /** report.pdf next to the HTML; see writeReportPdf for which browser prints it. Never fails the run. */
@@ -616,7 +622,7 @@ class ReportingLabsReporter {
616
622
  return parts;
617
623
  }
618
624
  serializeResult(r, test) {
619
- const logs = [], data = [], api = [];
625
+ const logs = [], data = [], api = [], browser = [];
620
626
  const normal = [];
621
627
  for (const a of r.attachments) {
622
628
  const body = a.body ?? (a.path && fs.existsSync(a.path) ? fs.readFileSync(a.path) : undefined);
@@ -635,6 +641,13 @@ class ReportingLabsReporter {
635
641
  catch { /* ignore */ }
636
642
  continue;
637
643
  }
644
+ if (a.contentType === 'application/x-rl-browser' && body) {
645
+ try {
646
+ browser.push(this.browserEvent(JSON.parse(body.toString())));
647
+ }
648
+ catch { /* ignore */ }
649
+ continue;
650
+ }
638
651
  if (a.contentType === 'application/x-rl-data' && body) {
639
652
  data.push(this.toDataBlock(a.name, body.toString()));
640
653
  continue;
@@ -665,13 +678,19 @@ class ReportingLabsReporter {
665
678
  attachments: normal.map(a => this.serializeAttachment(a, test)).filter(Boolean),
666
679
  stdout: r.stdout.map(c => this.masker.maskStr(stripAnsi(c.toString()))),
667
680
  stderr: r.stderr.map(c => this.masker.maskStr(stripAnsi(c.toString()))),
681
+ ...(browser.length ? { browser: browser.sort((x, y) => x.t - y.t) } : {}),
668
682
  };
669
683
  }
684
+ browserEvent(e) {
685
+ const m = (s) => (s == null ? undefined : this.masker.maskStr(String(s)));
686
+ return { t: Number(e.t) || 0, kind: e.kind, text: m(e.text) ?? '', url: m(e.url), method: e.method, status: e.status, stack: m(e.stack) };
687
+ }
670
688
  serializeStep(s) {
671
689
  return {
672
690
  title: this.masker.maskStr(stepTitle(s)),
673
691
  category: s.category,
674
692
  duration: s.duration,
693
+ start: s.startTime.getTime(),
675
694
  error: s.error?.message ? this.masker.maskStr(stripAnsi(s.error.message)) : undefined,
676
695
  steps: s.steps.filter(c => !isInternalAttach(c)).map(c => this.serializeStep(c)),
677
696
  };
package/dist/star.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare const STAR_URL = "https://github.com/naveenautomationlabs/reporting-labs";
2
+ export declare function starLine(env?: NodeJS.ProcessEnv, mark?: string): string | undefined;
package/dist/star.js ADDED
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.STAR_URL = void 0;
37
+ exports.starLine = starLine;
38
+ /**
39
+ * At most once a week, on a developer's machine, one line after the report asking for a GitHub star: most people
40
+ * who use the reporter never see the repository. Never in CI. Off with announce: false or REPORTING_LABS_NO_STAR=1.
41
+ */
42
+ const fs = __importStar(require("fs"));
43
+ const os = __importStar(require("os"));
44
+ const path = __importStar(require("path"));
45
+ const CI_VARS = ['CI', 'TF_BUILD', 'JENKINS_URL', 'GITLAB_CI', 'BUILDKITE', 'CIRCLECI', 'TEAMCITY_VERSION', 'CODEBUILD_BUILD_ID', 'BITBUCKET_BUILD_NUMBER'];
46
+ const WEEK = 7 * 24 * 3600 * 1000;
47
+ exports.STAR_URL = 'https://github.com/naveenautomationlabs/reporting-labs';
48
+ function starLine(env = process.env, mark = path.join(os.tmpdir(), 'reporting-labs-star')) {
49
+ if (env.REPORTING_LABS_NO_STAR || CI_VARS.some(k => env[k]))
50
+ return undefined;
51
+ try {
52
+ if (Date.now() - fs.statSync(mark).mtimeMs < WEEK)
53
+ return undefined;
54
+ }
55
+ catch { /* never shown on this machine */ }
56
+ // the time it was shown is what keeps it to once a week: if it cannot be kept, stay quiet
57
+ try {
58
+ fs.writeFileSync(mark, '');
59
+ }
60
+ catch {
61
+ return undefined;
62
+ }
63
+ return ` ★ If reportingLabs helps you, a GitHub star helps other testers find it: ${exports.STAR_URL}`;
64
+ }
@@ -201,6 +201,9 @@ a{color:var(--accent)}
201
201
 
202
202
  /* ---------- detail ---------- */
203
203
  .detail{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:22px;min-width:0}
204
+ /* a long URL, path or token with no spaces (an OAuth redirect in a step error) breaks instead of widening the page */
205
+ .detail :is(.e,.crumb,.loc,.errloc,.txt,.logs,.note,.err,.kv dd,.kv2 dd){overflow-wrap:anywhere}
206
+ .detail .kv{grid-template-columns:auto minmax(0,1fr)} .detail .kv2{grid-template-columns:max-content minmax(0,1fr)}
204
207
  .crumb{font-size:12px;color:var(--ink-3)} .crumb span+span::before{content:" / ";color:var(--line)}
205
208
  .detail h3{font-size:20px;font-weight:600;margin:6px 0 10px;letter-spacing:-.01em;overflow-wrap:anywhere;min-width:0}
206
209
  .badges{display:flex;gap:6px;flex-wrap:wrap;align-items:center;margin-bottom:18px}
@@ -511,6 +514,23 @@ html,body{-webkit-font-smoothing:antialiased}
511
514
  /* tests view */
512
515
  .main{margin-top:20px}
513
516
  .list{top:12px;max-height:calc(100vh - 24px)}
517
+ /* one column (phones, narrow windows): the list scrolls away instead of staying pinned over the test detail below it */
518
+ @media (max-width:900px){.list{position:static;max-height:60vh}}
519
+ /* ---------- what the browser saw; video in step with the steps ---------- */
520
+ .bev-list{border:1px solid var(--line);border-radius:var(--radius);overflow:hidden;background:var(--surface)}
521
+ .bev{display:grid;grid-template-columns:104px minmax(0,1fr) auto;gap:4px 12px;padding:8px 12px;border-top:1px solid var(--line);font-size:13px;align-items:start}
522
+ .bev:first-child{border-top:0}
523
+ .bev .k{font-weight:600;font-size:12px;padding-top:1px} .bev.error .k,.bev.request .k{color:var(--fail)} .bev.console .k{color:var(--flaky-ink)}
524
+ .bev .m{min-width:0;overflow-wrap:anywhere;color:var(--ink);line-height:1.45} .bev .m code{font:12px var(--mono)} .bev .u{font:11.5px var(--mono);color:var(--ink-3)}
525
+ .bev .w{font-size:12px;color:var(--ink-3);white-space:nowrap;padding-top:1px} .bev.near{background:var(--fail-bg)} .bev.near .w{color:var(--fail);font-weight:600}
526
+ .bev details summary{font-size:12px;color:var(--ink-3);cursor:pointer;margin-top:2px} .bev pre{font:11.5px/1.45 var(--mono);white-space:pre-wrap;overflow-wrap:anywhere;margin:4px 0 0;color:var(--ink-2)}
527
+ @media (max-width:640px){.bev{grid-template-columns:1fr auto} .bev .m{grid-column:1/-1;grid-row:2}}
528
+ .bev-jump{display:block;margin-top:10px;padding:0;background:none;border:0;font:500 12.5px var(--sans);color:var(--fail);text-align:left;cursor:pointer} .bev-jump:hover{text-decoration:underline}
529
+ .vsync{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:0 0 8px} .vsync .hint{flex:1;min-width:180px;color:var(--ink-3);font-size:12px}
530
+ .vplay{flex:none;width:20px;height:20px;border-radius:50%;border:1px solid var(--line);background:var(--surface);color:var(--accent-2);font-size:8px;line-height:1;cursor:pointer;display:inline-grid;place-items:center;padding:0 0 0 1px}
531
+ .vplay:hover{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
532
+ .step.now{background:color-mix(in srgb,var(--accent) 16%,transparent);box-shadow:inset 3px 0 0 var(--accent)}
533
+ @media print{.vplay,.vsync .btn,.bev-jump{display:none}}
514
534
  .tools{padding:12px;gap:8px;background:var(--surface)}
515
535
  .tools input,.tools select{border-radius:8px;background:var(--bg);border-color:var(--line)}
516
536
  .tools input:focus,.tools select:focus{border-color:var(--accent);outline:0;box-shadow:0 0 0 3px var(--accent-tint)}
@@ -678,6 +698,7 @@ html,body{font-size:var(--fs)}
678
698
  .rl-foot-mark{width:22px;height:22px;display:inline-flex;flex:none}
679
699
  .rl-foot-mark svg{width:22px;height:22px;display:block;border-radius:6px}
680
700
  .rl-foot-txt b{color:var(--ink-2);font-weight:600}
701
+ .rl-star{color:var(--ink-2);text-decoration:none} .rl-star:hover{color:var(--accent-2);text-decoration:underline}
681
702
  @media print{ .rl-foot{display:none} }
682
703
 
683
704
  /* ---------- print / PDF: a clean, client-shareable executive report ----------
@@ -1160,7 +1181,8 @@ function rlFooter(){
1160
1181
  return h('footer',{class:'rl-foot'},
1161
1182
  h('span',{class:'rl-foot-mark',html:svg}),
1162
1183
  h('span',{class:'rl-foot-txt'}, 'Generated by ', h('b',{},'reportingLabs'),
1163
- data.generatedAt? ' · '+new Date(data.generatedAt).toLocaleString() : null));
1184
+ data.generatedAt? ' · '+new Date(data.generatedAt).toLocaleString() : null,
1185
+ ' · ', h('a',{class:'rl-star',href:'https://github.com/naveenautomationlabs/reporting-labs',target:'_blank',rel:'noopener'},'\u2605 Star on GitHub')));
1164
1186
  }
1165
1187
 
1166
1188
  /* ---------- summary ---------- */
@@ -1768,6 +1790,8 @@ function select(id, quiet){
1768
1790
  const t=data.tests.find(x=>x.id===id); if(!t) return;
1769
1791
  state.selected=id; state.retry=t.results.length-1; if(!quiet){ if(state.view!=='tests') showView('tests'); else setHash(); } refresh(true); renderDetail(t);
1770
1792
  const it=document.querySelector('.item[data-id="'+id+'"]'); if(it&&it.scrollIntoView) it.scrollIntoView({block:'nearest'});
1793
+ // one column: the detail is below the list, so bring it into view
1794
+ if(!quiet&&window.innerWidth<=900){ const d=$('#detail'); if(d&&d.scrollIntoView) d.scrollIntoView({block:'start'}); }
1771
1795
  }
1772
1796
  function renderDetail(t, d, retryIdx){
1773
1797
  d=d||$('#detail'); d.innerHTML='';
@@ -1790,10 +1814,30 @@ function renderDetail(t, d, retryIdx){
1790
1814
  const r=t.results[retry]; if(!r){ d.append(h('p',{class:'empty'},'This test did not run.')); return; }
1791
1815
  const body=h('div',{});
1792
1816
  if(t.note&&retry===t.results.length-1) body.append(h('div',{class:'note '+(t.outcome==='passed'?'ok':'warn')}, t.note));
1793
- if(r.errors.length){ body.append(h('h4',{},r.errors.length>1?'Errors':'Error'), ...r.errors.map(errorView)); }
1794
- if(r.steps.length){ const stepTotal=Math.max(1, r.duration||0, r.steps.reduce((a,x)=>a+x.duration,0)); const tree=stepTree(r.steps, stepTotal), nested=r.steps.some(x=>x.steps.length);
1817
+ const failedRun=r.status!=='passed'&&r.status!=='skipped', fail=failedRun? failMoment(r) : null;
1818
+ const bsec=browserView(r, fail);
1819
+ if(r.errors.length){ body.append(h('h4',{},r.errors.length>1?'Errors':'Error'), ...r.errors.map(errorView));
1820
+ const near=fail!=null? (r.browser||[]).filter(e=>e.t<=fail&&fail-e.t<=5000).length : 0;
1821
+ if(near&&bsec) body.append(h('button',{class:'bev-jump',type:'button',onclick:()=>bsec.scrollIntoView({block:'start',behavior:'smooth'})}, 'The browser reported '+near+' problem'+(near>1?'s':'')+' in the 5 seconds before this failure. See what the browser saw ↓')); }
1822
+ if(bsec&&failedRun) body.append(bsec);
1823
+ // Playwright's video starts when the page is created: steps can play it from their own moment
1824
+ const allVids=r.attachments.filter(a=>a.src&&a.contentType.startsWith('video/')), v0=allVids.length? videoStart(r.steps) : null;
1825
+ let sync=null;
1826
+ if(v0!=null){
1827
+ const figs=allVids.map(videoFigure), v=figs[0].v, tree=()=>body.querySelectorAll('.step[data-s]');
1828
+ sync={ from:v0, seek:abs=>{ v.currentTime=Math.max(0,(abs-v0)/1000); v.play().catch(()=>{}); v.scrollIntoView({block:'nearest',behavior:'smooth'}); } };
1829
+ // a step that starts after the recording ended (closing the browser) has nothing to show
1830
+ v.addEventListener('loadedmetadata',()=>{ if(!isFinite(v.duration)) return; const end=v0+v.duration*1000; for(const b of body.querySelectorAll('.vplay[data-s]')) if(+b.dataset.s>=end) b.hidden=true; });
1831
+ v.addEventListener('timeupdate',()=>{ const at=v0+v.currentTime*1000; let cur=null; for(const el of tree()){ if(el.offsetParent&&+el.dataset.s<=at&&at<=+el.dataset.e) cur=el; } for(const el of body.querySelectorAll('.step.now')) if(el!==cur) el.classList.remove('now'); if(cur) cur.classList.add('now'); });
1832
+ body.append(h('h4',{},allVids.length>1?'Videos':'Video'), h('div',{class:'vsync'},
1833
+ h('span',{class:'hint'},'In step with the test: the step playing lights up below. Click ▶ on a step to watch it.'),
1834
+ fail!=null? h('button',{class:'btn primary',type:'button',onclick:()=>sync.seek(fail-5000)},'▶ Watch the failure') : null),
1835
+ h('div',{class:'vids'}, figs.map(f=>f.fig)));
1836
+ }
1837
+ if(r.steps.length){ const stepTotal=Math.max(1, r.duration||0, r.steps.reduce((a,x)=>a+x.duration,0)); const tree=stepTree(r.steps, stepTotal, sync), nested=r.steps.some(x=>x.steps.length);
1795
1838
  body.append(h('h4',{class:'st-h'},data.bdd?'Scenario steps':'Steps', h('span',{class:'hint'},'bar = share of '+ms(stepTotal)),
1796
1839
  nested? h('span',{class:'st-tools'}, h('button',{type:'button',onclick:()=>setSteps(tree,false)},'Expand all'), h('button',{type:'button',onclick:()=>setSteps(tree,true)},'Collapse all')) : null), tree); }
1840
+ if(bsec&&!failedRun) body.append(bsec);
1797
1841
  if(r.logs.length){ const t0=r.startTime; body.append(h('h4',{},'Log'), h('div',{class:'logs'}, r.logs.map(l=>h('div',{class:'ln'+(/\b(error|fail|exception)\b/i.test(l.msg)?' err':/\bwarn/i.test(l.msg)?' warn':'')}, h('span',{class:'ts'},'+'+ms(Math.max(0,l.t-t0))), h('span',{class:'lm'},l.msg))))); }
1798
1842
  for(const b of r.data){ body.append(h('h4',{},b.name), dataBlock(b)); }
1799
1843
  if(r.api.length){ body.append(h('h4',{},r.api.length+' API call'+(r.api.length>1?'s':'')), ...r.api.map(c=>apiPanel(c,r))); body.append(h('div',{class:'mask-note'},'Secrets and auth headers are masked as ****')); }
@@ -1807,9 +1851,7 @@ function renderDetail(t, d, retryIdx){
1807
1851
  for(const a of imgs){ const m=a.name.match(/^(.*)-(expected|actual|diff)(\.\w+)?$/); if(m){ const set=cmp.get(m[1])||{}; set[m[2]]=a; cmp.set(m[1],set); } }
1808
1852
  const plainImgs=imgs.filter(a=>!/-(expected|actual|diff)(\.\w+)?$/.test(a.name));
1809
1853
  for(const [name,set] of cmp) if(set.expected&&set.actual) body.append(h('h4',{},'Visual comparison · '+name), compare(set)); else for(const k of Object.keys(set)) plainImgs.push(set[k]);
1810
- if(vids.length){ body.append(h('h4',{},vids.length>1?'Videos':'Video'), h('div',{class:'vids'}, vids.map(a=>{ const fig=h('figure',{}); const v=h('video',{src:a.src,controls:'',preload:'metadata',playsinline:''});
1811
- v.addEventListener('error',()=>{ const code=v.error&&v.error.code; const why=code===4?'The file is missing, or it is not a format this browser can play.':code===2?'The file could not be read.':'The file could not be decoded.'; v.replaceWith(h('div',{class:'att-err'}, h('b',{},'Video could not be loaded.'), ' '+why+' Expected at ', h('code',{},a.src), '. Common causes: on macOS, Chrome cannot read files next to a report opened from Downloads, Desktop or Documents until you allow it under System Settings → Privacy & Security → Files and Folders (or move the project elsewhere); or the assets folder was replaced by a newer run. Setting embedVideos: true in the reporter options puts videos inside the HTML and avoids both.')); });
1812
- fig.append(v, h('figcaption',{}, a.name, a.size?h('span',{},' · '+kb(a.size)):null, ' · ', h('a',{href:a.src,download:'',target:'_blank',rel:'noopener',title:'Downloads when the report is served over http; opens in a new tab when opened as a file'},'download'))); return fig; }))); }
1854
+ if(vids.length&&v0==null){ body.append(h('h4',{},vids.length>1?'Videos':'Video'), h('div',{class:'vids'}, vids.map(a=>videoFigure(a).fig))); }
1813
1855
  if(plainImgs.length){ body.append(h('h4',{},plainImgs.length>1?'Screenshots':'Screenshot'), h('div',{class:'att'}, plainImgs.map(a=>h('figure',{}, h('img',{src:a.src,alt:a.name,loading:'lazy',onclick:()=>lightbox(a.src)}), h('figcaption',{},a.name))))); }
1814
1856
  if(traces.length){ body.append(h('h4',{},'Trace'), h('div',{class:'trace'}, traces.map(a=>h('div',{class:'trace-card'},
1815
1857
  h('div',{}, h('b',{},a.name), a.size?h('span',{style:'color:var(--ink-3)'},' · '+kb(a.size)):null),
@@ -1823,15 +1865,43 @@ function renderDetail(t, d, retryIdx){
1823
1865
  if(!body.children.length) body.append(h('p',{style:'color:var(--ink-3)'}, r.status==='skipped'?'Skipped — nothing was executed.'+(skipReason(t)?' Reason: '+skipReason(t):''):'Passed with no steps or attachments recorded.'));
1824
1866
  d.append(body);
1825
1867
  }
1826
- function stepTree(steps, total){
1868
+ function videoFigure(a){ const fig=h('figure',{}); const v=h('video',{src:a.src,controls:'',preload:'metadata',playsinline:''});
1869
+ v.addEventListener('error',()=>{ const code=v.error&&v.error.code; const why=code===4?'The file is missing, or it is not a format this browser can play.':code===2?'The file could not be read.':'The file could not be decoded.'; v.replaceWith(h('div',{class:'att-err'}, h('b',{},'Video could not be loaded.'), ' '+why+' Expected at ', h('code',{},a.src), '. Common causes: on macOS, Chrome cannot read files next to a report opened from Downloads, Desktop or Documents until you allow it under System Settings → Privacy & Security → Files and Folders (or move the project elsewhere); or the assets folder was replaced by a newer run. Setting embedVideos: true in the reporter options puts videos inside the HTML and avoids both.')); });
1870
+ fig.append(v, h('figcaption',{}, a.name, a.size?h('span',{},' · '+kb(a.size)):null, ' · ', h('a',{href:a.src,download:'',target:'_blank',rel:'noopener',title:'Downloads when the report is served over http; opens in a new tab when opened as a file'},'download'))); return {fig, v}; }
1871
+ /* Playwright starts recording a page's video when the page is created: the first "Create page" step ends at the
1872
+ video's 0:00 (measured within ~20ms). Without that step (other runners) the video is not lined up with steps. */
1873
+ function videoStart(steps){ for(const s of steps){ if(s.category==='pw:api'&&/^Create page\b/.test(s.title)&&s.start!=null) return s.start+s.duration; const k=videoStart(s.steps); if(k!=null) return k; } return null; }
1874
+ /* When the test failed: the end of the first step that failed, else the end of the attempt. */
1875
+ function failMoment(r){ let at=null; const walk=ss=>{ for(const s of ss){ if(s.error&&s.start!=null) at=at==null? s.start+s.duration : Math.min(at, s.start+s.duration); walk(s.steps); } }; walk(r.steps); return at!=null? at : r.startTime+r.duration; }
1876
+ /* What the browser reported while the test ran (captured by reporting-labs/auto): uncaught JavaScript errors,
1877
+ console.error and failed requests, timed against the failure. */
1878
+ function browserView(r, fail){
1879
+ const ev=r.browser||[]; if(!ev.length) return null;
1880
+ const count=k=>ev.filter(e=>e.kind===k).length;
1881
+ const parts=[[count('error'),'JavaScript error'],[count('console'),'console error'],[count('request'),'failed request']].filter(x=>x[0]).map(([c,l])=>c+' '+l+(c>1?'s':''));
1882
+ const when=e=> fail!=null? (e.t<=fail? ms(fail-e.t)+' before the failure' : ms(e.t-fail)+' after it') : 'at '+ms(Math.max(0,e.t-r.startTime));
1883
+ const label=e=> e.kind==='error'?'JS error':e.kind==='console'?'console.error':e.status?'HTTP '+e.status:'No response';
1884
+ const row=e=>h('div',{class:'bev '+e.kind+(fail!=null&&e.t<=fail&&fail-e.t<=5000?' near':'')},
1885
+ h('span',{class:'k'},label(e)),
1886
+ h('div',{class:'m'}, e.kind==='request'? [h('code',{},(e.method?e.method+' ':'')+e.url), e.text? h('div',{class:'u'},e.text) : null] : [h('div',{},e.text), e.url? h('div',{class:'u'},e.url) : null],
1887
+ e.stack&&e.stack!==e.text? h('details',{}, h('summary',{},'Stack'), h('pre',{},e.stack)) : null),
1888
+ h('span',{class:'w'},when(e)));
1889
+ const shown=ev.slice(-30), sec=h('div',{class:'bev-sec'});
1890
+ sec.append(h('h4',{},'What the browser saw', h('span',{class:'hint'},parts.join(' · ')+(ev.length>shown.length?' · the last '+shown.length+' shown':''))), h('div',{class:'bev-list'}, shown.map(row)));
1891
+ return sec;
1892
+ }
1893
+ function stepTree(steps, total, sync){
1827
1894
  return h('ul',{class:'steps'}, steps.map(s=>{
1828
1895
  const bad=!!s.error, skip=s.status==='skipped', kids=s.steps.length>0, pct=total?Math.min(100,s.duration/total*100):0;
1829
1896
  // a step with sub-steps starts collapsed; the path to a failure starts open unless expandFailedSteps is false
1830
1897
  const li=h('li',{class:kids&&(data.options.expandFailedSteps===false||!hasError(s))?'collapsed':''});
1831
- const row=h('div',{class:'step'+(bad?' bad':'')+(skip?' skip':'')},
1832
- h('span',{class:'tw'}, kids? '▸' : ''), data.bdd?null:h('span',{class:'cat'},s.category), gherkin(s.title), total&&!skip? h('span',{class:'tb',title:Math.round(pct)+'% of the test'}, h('i',{class:pct>=30?'slow':'',style:'width:'+Math.max(pct,s.duration>0?1.5:0)+'%'})) : null, h('span',{class:'d'},skip?'not run':ms(s.duration)));
1898
+ const timed=s.start!=null&&!skip;
1899
+ const row=h('div',{class:'step'+(bad?' bad':'')+(skip?' skip':''),'data-s':timed?s.start:null,'data-e':timed?s.start+s.duration:null},
1900
+ h('span',{class:'tw'}, kids? '▸' : ''), data.bdd?null:h('span',{class:'cat'},s.category), gherkin(s.title), total&&!skip? h('span',{class:'tb',title:Math.round(pct)+'% of the test'}, h('i',{class:pct>=30?'slow':'',style:'width:'+Math.max(pct,s.duration>0?1.5:0)+'%'})) : null, h('span',{class:'d'},skip?'not run':ms(s.duration)),
1901
+ // only for steps the video shows: not the browser launch and page setup that end before recording starts
1902
+ sync&&timed&&s.start+s.duration>sync.from+100? h('button',{class:'vplay',type:'button','data-s':s.start,title:'Play the video from this step','aria-label':'Play the video from this step',onclick:e=>{e.stopPropagation();sync.seek(s.start);}},'▶') : null);
1833
1903
  if(kids){ row.style.cursor='pointer'; row.addEventListener('click',()=>{li.classList.toggle('collapsed'); row.querySelector('.tw').textContent=li.classList.contains('collapsed')?'▸':'▾';}); if(!li.classList.contains('collapsed')) row.querySelector('.tw').textContent='▾'; }
1834
- li.append(row); if(bad) li.append(h('div',{class:'e'},s.error)); if(kids) li.append(stepTree(s.steps, total));
1904
+ li.append(row); if(bad) li.append(h('div',{class:'e'},s.error)); if(kids) li.append(stepTree(s.steps, total, sync));
1835
1905
  return li;
1836
1906
  }));
1837
1907
  }
package/dist/template.js CHANGED
@@ -272,6 +272,9 @@ a{color:var(--accent)}
272
272
 
273
273
  /* ---------- detail ---------- */
274
274
  .detail{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:22px;min-width:0}
275
+ /* a long URL, path or token with no spaces (an OAuth redirect in a step error) breaks instead of widening the page */
276
+ .detail :is(.e,.crumb,.loc,.errloc,.txt,.logs,.note,.err,.kv dd,.kv2 dd){overflow-wrap:anywhere}
277
+ .detail .kv{grid-template-columns:auto minmax(0,1fr)} .detail .kv2{grid-template-columns:max-content minmax(0,1fr)}
275
278
  .crumb{font-size:12px;color:var(--ink-3)} .crumb span+span::before{content:" / ";color:var(--line)}
276
279
  .detail h3{font-size:20px;font-weight:600;margin:6px 0 10px;letter-spacing:-.01em;overflow-wrap:anywhere;min-width:0}
277
280
  .badges{display:flex;gap:6px;flex-wrap:wrap;align-items:center;margin-bottom:18px}
@@ -582,6 +585,23 @@ html,body{-webkit-font-smoothing:antialiased}
582
585
  /* tests view */
583
586
  .main{margin-top:20px}
584
587
  .list{top:12px;max-height:calc(100vh - 24px)}
588
+ /* one column (phones, narrow windows): the list scrolls away instead of staying pinned over the test detail below it */
589
+ @media (max-width:900px){.list{position:static;max-height:60vh}}
590
+ /* ---------- what the browser saw; video in step with the steps ---------- */
591
+ .bev-list{border:1px solid var(--line);border-radius:var(--radius);overflow:hidden;background:var(--surface)}
592
+ .bev{display:grid;grid-template-columns:104px minmax(0,1fr) auto;gap:4px 12px;padding:8px 12px;border-top:1px solid var(--line);font-size:13px;align-items:start}
593
+ .bev:first-child{border-top:0}
594
+ .bev .k{font-weight:600;font-size:12px;padding-top:1px} .bev.error .k,.bev.request .k{color:var(--fail)} .bev.console .k{color:var(--flaky-ink)}
595
+ .bev .m{min-width:0;overflow-wrap:anywhere;color:var(--ink);line-height:1.45} .bev .m code{font:12px var(--mono)} .bev .u{font:11.5px var(--mono);color:var(--ink-3)}
596
+ .bev .w{font-size:12px;color:var(--ink-3);white-space:nowrap;padding-top:1px} .bev.near{background:var(--fail-bg)} .bev.near .w{color:var(--fail);font-weight:600}
597
+ .bev details summary{font-size:12px;color:var(--ink-3);cursor:pointer;margin-top:2px} .bev pre{font:11.5px/1.45 var(--mono);white-space:pre-wrap;overflow-wrap:anywhere;margin:4px 0 0;color:var(--ink-2)}
598
+ @media (max-width:640px){.bev{grid-template-columns:1fr auto} .bev .m{grid-column:1/-1;grid-row:2}}
599
+ .bev-jump{display:block;margin-top:10px;padding:0;background:none;border:0;font:500 12.5px var(--sans);color:var(--fail);text-align:left;cursor:pointer} .bev-jump:hover{text-decoration:underline}
600
+ .vsync{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:0 0 8px} .vsync .hint{flex:1;min-width:180px;color:var(--ink-3);font-size:12px}
601
+ .vplay{flex:none;width:20px;height:20px;border-radius:50%;border:1px solid var(--line);background:var(--surface);color:var(--accent-2);font-size:8px;line-height:1;cursor:pointer;display:inline-grid;place-items:center;padding:0 0 0 1px}
602
+ .vplay:hover{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
603
+ .step.now{background:color-mix(in srgb,var(--accent) 16%,transparent);box-shadow:inset 3px 0 0 var(--accent)}
604
+ @media print{.vplay,.vsync .btn,.bev-jump{display:none}}
585
605
  .tools{padding:12px;gap:8px;background:var(--surface)}
586
606
  .tools input,.tools select{border-radius:8px;background:var(--bg);border-color:var(--line)}
587
607
  .tools input:focus,.tools select:focus{border-color:var(--accent);outline:0;box-shadow:0 0 0 3px var(--accent-tint)}
@@ -749,6 +769,7 @@ html,body{font-size:var(--fs)}
749
769
  .rl-foot-mark{width:22px;height:22px;display:inline-flex;flex:none}
750
770
  .rl-foot-mark svg{width:22px;height:22px;display:block;border-radius:6px}
751
771
  .rl-foot-txt b{color:var(--ink-2);font-weight:600}
772
+ .rl-star{color:var(--ink-2);text-decoration:none} .rl-star:hover{color:var(--accent-2);text-decoration:underline}
752
773
  @media print{ .rl-foot{display:none} }
753
774
 
754
775
  /* ---------- print / PDF: a clean, client-shareable executive report ----------
@@ -1226,7 +1247,8 @@ function rlFooter(){
1226
1247
  return h('footer',{class:'rl-foot'},
1227
1248
  h('span',{class:'rl-foot-mark',html:svg}),
1228
1249
  h('span',{class:'rl-foot-txt'}, 'Generated by ', h('b',{},'reportingLabs'),
1229
- data.generatedAt? ' · '+new Date(data.generatedAt).toLocaleString() : null));
1250
+ data.generatedAt? ' · '+new Date(data.generatedAt).toLocaleString() : null,
1251
+ ' · ', h('a',{class:'rl-star',href:'https://github.com/naveenautomationlabs/reporting-labs',target:'_blank',rel:'noopener'},'\u2605 Star on GitHub')));
1230
1252
  }
1231
1253
 
1232
1254
  /* ---------- summary ---------- */
@@ -1834,6 +1856,8 @@ function select(id, quiet){
1834
1856
  const t=data.tests.find(x=>x.id===id); if(!t) return;
1835
1857
  state.selected=id; state.retry=t.results.length-1; if(!quiet){ if(state.view!=='tests') showView('tests'); else setHash(); } refresh(true); renderDetail(t);
1836
1858
  const it=document.querySelector('.item[data-id="'+id+'"]'); if(it&&it.scrollIntoView) it.scrollIntoView({block:'nearest'});
1859
+ // one column: the detail is below the list, so bring it into view
1860
+ if(!quiet&&window.innerWidth<=900){ const d=$('#detail'); if(d&&d.scrollIntoView) d.scrollIntoView({block:'start'}); }
1837
1861
  }
1838
1862
  function renderDetail(t, d, retryIdx){
1839
1863
  d=d||$('#detail'); d.innerHTML='';
@@ -1856,10 +1880,30 @@ function renderDetail(t, d, retryIdx){
1856
1880
  const r=t.results[retry]; if(!r){ d.append(h('p',{class:'empty'},'This test did not run.')); return; }
1857
1881
  const body=h('div',{});
1858
1882
  if(t.note&&retry===t.results.length-1) body.append(h('div',{class:'note '+(t.outcome==='passed'?'ok':'warn')}, t.note));
1859
- if(r.errors.length){ body.append(h('h4',{},r.errors.length>1?'Errors':'Error'), ...r.errors.map(errorView)); }
1860
- if(r.steps.length){ const stepTotal=Math.max(1, r.duration||0, r.steps.reduce((a,x)=>a+x.duration,0)); const tree=stepTree(r.steps, stepTotal), nested=r.steps.some(x=>x.steps.length);
1883
+ const failedRun=r.status!=='passed'&&r.status!=='skipped', fail=failedRun? failMoment(r) : null;
1884
+ const bsec=browserView(r, fail);
1885
+ if(r.errors.length){ body.append(h('h4',{},r.errors.length>1?'Errors':'Error'), ...r.errors.map(errorView));
1886
+ const near=fail!=null? (r.browser||[]).filter(e=>e.t<=fail&&fail-e.t<=5000).length : 0;
1887
+ if(near&&bsec) body.append(h('button',{class:'bev-jump',type:'button',onclick:()=>bsec.scrollIntoView({block:'start',behavior:'smooth'})}, 'The browser reported '+near+' problem'+(near>1?'s':'')+' in the 5 seconds before this failure. See what the browser saw ↓')); }
1888
+ if(bsec&&failedRun) body.append(bsec);
1889
+ // Playwright's video starts when the page is created: steps can play it from their own moment
1890
+ const allVids=r.attachments.filter(a=>a.src&&a.contentType.startsWith('video/')), v0=allVids.length? videoStart(r.steps) : null;
1891
+ let sync=null;
1892
+ if(v0!=null){
1893
+ const figs=allVids.map(videoFigure), v=figs[0].v, tree=()=>body.querySelectorAll('.step[data-s]');
1894
+ sync={ from:v0, seek:abs=>{ v.currentTime=Math.max(0,(abs-v0)/1000); v.play().catch(()=>{}); v.scrollIntoView({block:'nearest',behavior:'smooth'}); } };
1895
+ // a step that starts after the recording ended (closing the browser) has nothing to show
1896
+ v.addEventListener('loadedmetadata',()=>{ if(!isFinite(v.duration)) return; const end=v0+v.duration*1000; for(const b of body.querySelectorAll('.vplay[data-s]')) if(+b.dataset.s>=end) b.hidden=true; });
1897
+ v.addEventListener('timeupdate',()=>{ const at=v0+v.currentTime*1000; let cur=null; for(const el of tree()){ if(el.offsetParent&&+el.dataset.s<=at&&at<=+el.dataset.e) cur=el; } for(const el of body.querySelectorAll('.step.now')) if(el!==cur) el.classList.remove('now'); if(cur) cur.classList.add('now'); });
1898
+ body.append(h('h4',{},allVids.length>1?'Videos':'Video'), h('div',{class:'vsync'},
1899
+ h('span',{class:'hint'},'In step with the test: the step playing lights up below. Click ▶ on a step to watch it.'),
1900
+ fail!=null? h('button',{class:'btn primary',type:'button',onclick:()=>sync.seek(fail-5000)},'▶ Watch the failure') : null),
1901
+ h('div',{class:'vids'}, figs.map(f=>f.fig)));
1902
+ }
1903
+ if(r.steps.length){ const stepTotal=Math.max(1, r.duration||0, r.steps.reduce((a,x)=>a+x.duration,0)); const tree=stepTree(r.steps, stepTotal, sync), nested=r.steps.some(x=>x.steps.length);
1861
1904
  body.append(h('h4',{class:'st-h'},data.bdd?'Scenario steps':'Steps', h('span',{class:'hint'},'bar = share of '+ms(stepTotal)),
1862
1905
  nested? h('span',{class:'st-tools'}, h('button',{type:'button',onclick:()=>setSteps(tree,false)},'Expand all'), h('button',{type:'button',onclick:()=>setSteps(tree,true)},'Collapse all')) : null), tree); }
1906
+ if(bsec&&!failedRun) body.append(bsec);
1863
1907
  if(r.logs.length){ const t0=r.startTime; body.append(h('h4',{},'Log'), h('div',{class:'logs'}, r.logs.map(l=>h('div',{class:'ln'+(/\b(error|fail|exception)\b/i.test(l.msg)?' err':/\bwarn/i.test(l.msg)?' warn':'')}, h('span',{class:'ts'},'+'+ms(Math.max(0,l.t-t0))), h('span',{class:'lm'},l.msg))))); }
1864
1908
  for(const b of r.data){ body.append(h('h4',{},b.name), dataBlock(b)); }
1865
1909
  if(r.api.length){ body.append(h('h4',{},r.api.length+' API call'+(r.api.length>1?'s':'')), ...r.api.map(c=>apiPanel(c,r))); body.append(h('div',{class:'mask-note'},'Secrets and auth headers are masked as ****')); }
@@ -1873,9 +1917,7 @@ function renderDetail(t, d, retryIdx){
1873
1917
  for(const a of imgs){ const m=a.name.match(/^(.*)-(expected|actual|diff)(\.\w+)?$/); if(m){ const set=cmp.get(m[1])||{}; set[m[2]]=a; cmp.set(m[1],set); } }
1874
1918
  const plainImgs=imgs.filter(a=>!/-(expected|actual|diff)(\.\w+)?$/.test(a.name));
1875
1919
  for(const [name,set] of cmp) if(set.expected&&set.actual) body.append(h('h4',{},'Visual comparison · '+name), compare(set)); else for(const k of Object.keys(set)) plainImgs.push(set[k]);
1876
- if(vids.length){ body.append(h('h4',{},vids.length>1?'Videos':'Video'), h('div',{class:'vids'}, vids.map(a=>{ const fig=h('figure',{}); const v=h('video',{src:a.src,controls:'',preload:'metadata',playsinline:''});
1877
- v.addEventListener('error',()=>{ const code=v.error&&v.error.code; const why=code===4?'The file is missing, or it is not a format this browser can play.':code===2?'The file could not be read.':'The file could not be decoded.'; v.replaceWith(h('div',{class:'att-err'}, h('b',{},'Video could not be loaded.'), ' '+why+' Expected at ', h('code',{},a.src), '. Common causes: on macOS, Chrome cannot read files next to a report opened from Downloads, Desktop or Documents until you allow it under System Settings → Privacy & Security → Files and Folders (or move the project elsewhere); or the assets folder was replaced by a newer run. Setting embedVideos: true in the reporter options puts videos inside the HTML and avoids both.')); });
1878
- fig.append(v, h('figcaption',{}, a.name, a.size?h('span',{},' · '+kb(a.size)):null, ' · ', h('a',{href:a.src,download:'',target:'_blank',rel:'noopener',title:'Downloads when the report is served over http; opens in a new tab when opened as a file'},'download'))); return fig; }))); }
1920
+ if(vids.length&&v0==null){ body.append(h('h4',{},vids.length>1?'Videos':'Video'), h('div',{class:'vids'}, vids.map(a=>videoFigure(a).fig))); }
1879
1921
  if(plainImgs.length){ body.append(h('h4',{},plainImgs.length>1?'Screenshots':'Screenshot'), h('div',{class:'att'}, plainImgs.map(a=>h('figure',{}, h('img',{src:a.src,alt:a.name,loading:'lazy',onclick:()=>lightbox(a.src)}), h('figcaption',{},a.name))))); }
1880
1922
  if(traces.length){ body.append(h('h4',{},'Trace'), h('div',{class:'trace'}, traces.map(a=>h('div',{class:'trace-card'},
1881
1923
  h('div',{}, h('b',{},a.name), a.size?h('span',{style:'color:var(--ink-3)'},' · '+kb(a.size)):null),
@@ -1889,15 +1931,43 @@ function renderDetail(t, d, retryIdx){
1889
1931
  if(!body.children.length) body.append(h('p',{style:'color:var(--ink-3)'}, r.status==='skipped'?'Skipped — nothing was executed.'+(skipReason(t)?' Reason: '+skipReason(t):''):'Passed with no steps or attachments recorded.'));
1890
1932
  d.append(body);
1891
1933
  }
1892
- function stepTree(steps, total){
1934
+ function videoFigure(a){ const fig=h('figure',{}); const v=h('video',{src:a.src,controls:'',preload:'metadata',playsinline:''});
1935
+ v.addEventListener('error',()=>{ const code=v.error&&v.error.code; const why=code===4?'The file is missing, or it is not a format this browser can play.':code===2?'The file could not be read.':'The file could not be decoded.'; v.replaceWith(h('div',{class:'att-err'}, h('b',{},'Video could not be loaded.'), ' '+why+' Expected at ', h('code',{},a.src), '. Common causes: on macOS, Chrome cannot read files next to a report opened from Downloads, Desktop or Documents until you allow it under System Settings → Privacy & Security → Files and Folders (or move the project elsewhere); or the assets folder was replaced by a newer run. Setting embedVideos: true in the reporter options puts videos inside the HTML and avoids both.')); });
1936
+ fig.append(v, h('figcaption',{}, a.name, a.size?h('span',{},' · '+kb(a.size)):null, ' · ', h('a',{href:a.src,download:'',target:'_blank',rel:'noopener',title:'Downloads when the report is served over http; opens in a new tab when opened as a file'},'download'))); return {fig, v}; }
1937
+ /* Playwright starts recording a page's video when the page is created: the first "Create page" step ends at the
1938
+ video's 0:00 (measured within ~20ms). Without that step (other runners) the video is not lined up with steps. */
1939
+ function videoStart(steps){ for(const s of steps){ if(s.category==='pw:api'&&/^Create page\b/.test(s.title)&&s.start!=null) return s.start+s.duration; const k=videoStart(s.steps); if(k!=null) return k; } return null; }
1940
+ /* When the test failed: the end of the first step that failed, else the end of the attempt. */
1941
+ function failMoment(r){ let at=null; const walk=ss=>{ for(const s of ss){ if(s.error&&s.start!=null) at=at==null? s.start+s.duration : Math.min(at, s.start+s.duration); walk(s.steps); } }; walk(r.steps); return at!=null? at : r.startTime+r.duration; }
1942
+ /* What the browser reported while the test ran (captured by reporting-labs/auto): uncaught JavaScript errors,
1943
+ console.error and failed requests, timed against the failure. */
1944
+ function browserView(r, fail){
1945
+ const ev=r.browser||[]; if(!ev.length) return null;
1946
+ const count=k=>ev.filter(e=>e.kind===k).length;
1947
+ const parts=[[count('error'),'JavaScript error'],[count('console'),'console error'],[count('request'),'failed request']].filter(x=>x[0]).map(([c,l])=>c+' '+l+(c>1?'s':''));
1948
+ const when=e=> fail!=null? (e.t<=fail? ms(fail-e.t)+' before the failure' : ms(e.t-fail)+' after it') : 'at '+ms(Math.max(0,e.t-r.startTime));
1949
+ const label=e=> e.kind==='error'?'JS error':e.kind==='console'?'console.error':e.status?'HTTP '+e.status:'No response';
1950
+ const row=e=>h('div',{class:'bev '+e.kind+(fail!=null&&e.t<=fail&&fail-e.t<=5000?' near':'')},
1951
+ h('span',{class:'k'},label(e)),
1952
+ h('div',{class:'m'}, e.kind==='request'? [h('code',{},(e.method?e.method+' ':'')+e.url), e.text? h('div',{class:'u'},e.text) : null] : [h('div',{},e.text), e.url? h('div',{class:'u'},e.url) : null],
1953
+ e.stack&&e.stack!==e.text? h('details',{}, h('summary',{},'Stack'), h('pre',{},e.stack)) : null),
1954
+ h('span',{class:'w'},when(e)));
1955
+ const shown=ev.slice(-30), sec=h('div',{class:'bev-sec'});
1956
+ sec.append(h('h4',{},'What the browser saw', h('span',{class:'hint'},parts.join(' · ')+(ev.length>shown.length?' · the last '+shown.length+' shown':''))), h('div',{class:'bev-list'}, shown.map(row)));
1957
+ return sec;
1958
+ }
1959
+ function stepTree(steps, total, sync){
1893
1960
  return h('ul',{class:'steps'}, steps.map(s=>{
1894
1961
  const bad=!!s.error, skip=s.status==='skipped', kids=s.steps.length>0, pct=total?Math.min(100,s.duration/total*100):0;
1895
1962
  // a step with sub-steps starts collapsed; the path to a failure starts open unless expandFailedSteps is false
1896
1963
  const li=h('li',{class:kids&&(data.options.expandFailedSteps===false||!hasError(s))?'collapsed':''});
1897
- const row=h('div',{class:'step'+(bad?' bad':'')+(skip?' skip':'')},
1898
- h('span',{class:'tw'}, kids? '▸' : ''), data.bdd?null:h('span',{class:'cat'},s.category), gherkin(s.title), total&&!skip? h('span',{class:'tb',title:Math.round(pct)+'% of the test'}, h('i',{class:pct>=30?'slow':'',style:'width:'+Math.max(pct,s.duration>0?1.5:0)+'%'})) : null, h('span',{class:'d'},skip?'not run':ms(s.duration)));
1964
+ const timed=s.start!=null&&!skip;
1965
+ const row=h('div',{class:'step'+(bad?' bad':'')+(skip?' skip':''),'data-s':timed?s.start:null,'data-e':timed?s.start+s.duration:null},
1966
+ h('span',{class:'tw'}, kids? '▸' : ''), data.bdd?null:h('span',{class:'cat'},s.category), gherkin(s.title), total&&!skip? h('span',{class:'tb',title:Math.round(pct)+'% of the test'}, h('i',{class:pct>=30?'slow':'',style:'width:'+Math.max(pct,s.duration>0?1.5:0)+'%'})) : null, h('span',{class:'d'},skip?'not run':ms(s.duration)),
1967
+ // only for steps the video shows: not the browser launch and page setup that end before recording starts
1968
+ sync&&timed&&s.start+s.duration>sync.from+100? h('button',{class:'vplay',type:'button','data-s':s.start,title:'Play the video from this step','aria-label':'Play the video from this step',onclick:e=>{e.stopPropagation();sync.seek(s.start);}},'▶') : null);
1899
1969
  if(kids){ row.style.cursor='pointer'; row.addEventListener('click',()=>{li.classList.toggle('collapsed'); row.querySelector('.tw').textContent=li.classList.contains('collapsed')?'▸':'▾';}); if(!li.classList.contains('collapsed')) row.querySelector('.tw').textContent='▾'; }
1900
- li.append(row); if(bad) li.append(h('div',{class:'e'},s.error)); if(kids) li.append(stepTree(s.steps, total));
1970
+ li.append(row); if(bad) li.append(h('div',{class:'e'},s.error)); if(kids) li.append(stepTree(s.steps, total, sync));
1901
1971
  return li;
1902
1972
  }));
1903
1973
  }
package/dist/types.d.ts CHANGED
@@ -221,6 +221,8 @@ export interface StepData {
221
221
  error?: string;
222
222
  /** 'skipped' when the runner never executed it (a Cucumber step after a failed one) */
223
223
  status?: 'skipped';
224
+ /** When it started (ms since epoch), so the report can line steps up with the video. */
225
+ start?: number;
224
226
  steps: StepData[];
225
227
  }
226
228
  export interface AttachmentData {
@@ -257,6 +259,19 @@ export interface ResultData {
257
259
  text?: string;
258
260
  }[];
259
261
  api: ApiCall[];
262
+ /** What the browser reported while the test ran: uncaught JavaScript errors, console.error, failed requests. */
263
+ browser?: BrowserEvent[];
264
+ }
265
+ export interface BrowserEvent {
266
+ /** ms since epoch */
267
+ t: number;
268
+ kind: 'error' | 'console' | 'request';
269
+ text: string;
270
+ url?: string;
271
+ method?: string;
272
+ /** HTTP status of a request that got a 4xx/5xx; absent when it got no response at all */
273
+ status?: number;
274
+ stack?: string;
260
275
  }
261
276
  export interface TestData {
262
277
  id: string;
@@ -44,6 +44,7 @@ const template_1 = require("./template");
44
44
  const mask_1 = require("./mask");
45
45
  const pdf_1 = require("./pdf");
46
46
  const env_1 = require("./wdio/env");
47
+ const star_1 = require("./star");
47
48
  /** Writes the report into options.outputFolder (default reporting-labs) and returns the HTML path. */
48
49
  async function writeReport(tests, run, options = {}) {
49
50
  const outputFolder = options.outputFolder || 'reporting-labs';
@@ -134,8 +135,12 @@ async function writeReport(tests, run, options = {}) {
134
135
  }
135
136
  if (options.pdf !== false)
136
137
  await writePdf(htmlFile, outputFolder, options);
137
- if (options.announce !== false)
138
+ if (options.announce !== false) {
139
+ const star = (0, star_1.starLine)();
140
+ if (star)
141
+ console.log(star);
138
142
  console.log('');
143
+ }
139
144
  return htmlFile;
140
145
  }
141
146
  /** report.pdf next to the HTML; see writeReportPdf for which browser prints it (an installed Chrome or
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reporting-labs",
3
- "version": "0.6.21",
3
+ "version": "0.6.23",
4
4
  "description": "reportingLabs – beautiful, customizable single-file HTML test reports. One line of config. Playwright adapter included, more runners on the way.",
5
5
  "keywords": [
6
6
  "test-report",