reporting-labs 0.6.22 → 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 +6 -0
- package/dist/auto.js +66 -3
- package/dist/reporter.d.ts +1 -0
- package/dist/reporter.js +15 -2
- package/dist/template.html +74 -9
- package/dist/template.js +74 -9
- package/dist/types.d.ts +15 -0
- package/package.json +1 -1
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.
|
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 =>
|
|
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 =>
|
|
277
|
+
wrapAsync(bt, 'launchPersistentContext', ctx => { if (ctx?.request)
|
|
278
|
+
patchContext(ctx.request); watchContext(ctx); });
|
|
216
279
|
}
|
|
217
280
|
}
|
|
218
281
|
install();
|
package/dist/reporter.d.ts
CHANGED
package/dist/reporter.js
CHANGED
|
@@ -52,7 +52,7 @@ const comments_1 = require("./comments");
|
|
|
52
52
|
const DEFAULT_EMBED_LIMIT = 2 * 1024 * 1024;
|
|
53
53
|
/** Attach steps created by log() and the automatic API capture; the data shows in its own section, so hide the step. */
|
|
54
54
|
function isInternalAttach(s) {
|
|
55
|
-
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);
|
|
56
56
|
}
|
|
57
57
|
/** Playwright 1.63+ moved the target out of the title: title `Click`, subtitle `getByRole('button')`; title `Navigate`,
|
|
58
58
|
* subtitle `/login`. Put it back next to the title, as the report showed before. A test.step's own subtitle and
|
|
@@ -622,7 +622,7 @@ class ReportingLabsReporter {
|
|
|
622
622
|
return parts;
|
|
623
623
|
}
|
|
624
624
|
serializeResult(r, test) {
|
|
625
|
-
const logs = [], data = [], api = [];
|
|
625
|
+
const logs = [], data = [], api = [], browser = [];
|
|
626
626
|
const normal = [];
|
|
627
627
|
for (const a of r.attachments) {
|
|
628
628
|
const body = a.body ?? (a.path && fs.existsSync(a.path) ? fs.readFileSync(a.path) : undefined);
|
|
@@ -641,6 +641,13 @@ class ReportingLabsReporter {
|
|
|
641
641
|
catch { /* ignore */ }
|
|
642
642
|
continue;
|
|
643
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
|
+
}
|
|
644
651
|
if (a.contentType === 'application/x-rl-data' && body) {
|
|
645
652
|
data.push(this.toDataBlock(a.name, body.toString()));
|
|
646
653
|
continue;
|
|
@@ -671,13 +678,19 @@ class ReportingLabsReporter {
|
|
|
671
678
|
attachments: normal.map(a => this.serializeAttachment(a, test)).filter(Boolean),
|
|
672
679
|
stdout: r.stdout.map(c => this.masker.maskStr(stripAnsi(c.toString()))),
|
|
673
680
|
stderr: r.stderr.map(c => this.masker.maskStr(stripAnsi(c.toString()))),
|
|
681
|
+
...(browser.length ? { browser: browser.sort((x, y) => x.t - y.t) } : {}),
|
|
674
682
|
};
|
|
675
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
|
+
}
|
|
676
688
|
serializeStep(s) {
|
|
677
689
|
return {
|
|
678
690
|
title: this.masker.maskStr(stepTitle(s)),
|
|
679
691
|
category: s.category,
|
|
680
692
|
duration: s.duration,
|
|
693
|
+
start: s.startTime.getTime(),
|
|
681
694
|
error: s.error?.message ? this.masker.maskStr(stripAnsi(s.error.message)) : undefined,
|
|
682
695
|
steps: s.steps.filter(c => !isInternalAttach(c)).map(c => this.serializeStep(c)),
|
|
683
696
|
};
|
package/dist/template.html
CHANGED
|
@@ -514,6 +514,23 @@ html,body{-webkit-font-smoothing:antialiased}
|
|
|
514
514
|
/* tests view */
|
|
515
515
|
.main{margin-top:20px}
|
|
516
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}}
|
|
517
534
|
.tools{padding:12px;gap:8px;background:var(--surface)}
|
|
518
535
|
.tools input,.tools select{border-radius:8px;background:var(--bg);border-color:var(--line)}
|
|
519
536
|
.tools input:focus,.tools select:focus{border-color:var(--accent);outline:0;box-shadow:0 0 0 3px var(--accent-tint)}
|
|
@@ -1773,6 +1790,8 @@ function select(id, quiet){
|
|
|
1773
1790
|
const t=data.tests.find(x=>x.id===id); if(!t) return;
|
|
1774
1791
|
state.selected=id; state.retry=t.results.length-1; if(!quiet){ if(state.view!=='tests') showView('tests'); else setHash(); } refresh(true); renderDetail(t);
|
|
1775
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'}); }
|
|
1776
1795
|
}
|
|
1777
1796
|
function renderDetail(t, d, retryIdx){
|
|
1778
1797
|
d=d||$('#detail'); d.innerHTML='';
|
|
@@ -1795,10 +1814,30 @@ function renderDetail(t, d, retryIdx){
|
|
|
1795
1814
|
const r=t.results[retry]; if(!r){ d.append(h('p',{class:'empty'},'This test did not run.')); return; }
|
|
1796
1815
|
const body=h('div',{});
|
|
1797
1816
|
if(t.note&&retry===t.results.length-1) body.append(h('div',{class:'note '+(t.outcome==='passed'?'ok':'warn')}, t.note));
|
|
1798
|
-
|
|
1799
|
-
|
|
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);
|
|
1800
1838
|
body.append(h('h4',{class:'st-h'},data.bdd?'Scenario steps':'Steps', h('span',{class:'hint'},'bar = share of '+ms(stepTotal)),
|
|
1801
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);
|
|
1802
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))))); }
|
|
1803
1842
|
for(const b of r.data){ body.append(h('h4',{},b.name), dataBlock(b)); }
|
|
1804
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 ****')); }
|
|
@@ -1812,9 +1851,7 @@ function renderDetail(t, d, retryIdx){
|
|
|
1812
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); } }
|
|
1813
1852
|
const plainImgs=imgs.filter(a=>!/-(expected|actual|diff)(\.\w+)?$/.test(a.name));
|
|
1814
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]);
|
|
1815
|
-
if(vids.length){ body.append(h('h4',{},vids.length>1?'Videos':'Video'), h('div',{class:'vids'}, vids.map(a=>
|
|
1816
|
-
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.')); });
|
|
1817
|
-
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))); }
|
|
1818
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))))); }
|
|
1819
1856
|
if(traces.length){ body.append(h('h4',{},'Trace'), h('div',{class:'trace'}, traces.map(a=>h('div',{class:'trace-card'},
|
|
1820
1857
|
h('div',{}, h('b',{},a.name), a.size?h('span',{style:'color:var(--ink-3)'},' · '+kb(a.size)):null),
|
|
@@ -1828,15 +1865,43 @@ function renderDetail(t, d, retryIdx){
|
|
|
1828
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.'));
|
|
1829
1866
|
d.append(body);
|
|
1830
1867
|
}
|
|
1831
|
-
function
|
|
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){
|
|
1832
1894
|
return h('ul',{class:'steps'}, steps.map(s=>{
|
|
1833
1895
|
const bad=!!s.error, skip=s.status==='skipped', kids=s.steps.length>0, pct=total?Math.min(100,s.duration/total*100):0;
|
|
1834
1896
|
// a step with sub-steps starts collapsed; the path to a failure starts open unless expandFailedSteps is false
|
|
1835
1897
|
const li=h('li',{class:kids&&(data.options.expandFailedSteps===false||!hasError(s))?'collapsed':''});
|
|
1836
|
-
const
|
|
1837
|
-
|
|
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);
|
|
1838
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='▾'; }
|
|
1839
|
-
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));
|
|
1840
1905
|
return li;
|
|
1841
1906
|
}));
|
|
1842
1907
|
}
|
package/dist/template.js
CHANGED
|
@@ -585,6 +585,23 @@ html,body{-webkit-font-smoothing:antialiased}
|
|
|
585
585
|
/* tests view */
|
|
586
586
|
.main{margin-top:20px}
|
|
587
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}}
|
|
588
605
|
.tools{padding:12px;gap:8px;background:var(--surface)}
|
|
589
606
|
.tools input,.tools select{border-radius:8px;background:var(--bg);border-color:var(--line)}
|
|
590
607
|
.tools input:focus,.tools select:focus{border-color:var(--accent);outline:0;box-shadow:0 0 0 3px var(--accent-tint)}
|
|
@@ -1839,6 +1856,8 @@ function select(id, quiet){
|
|
|
1839
1856
|
const t=data.tests.find(x=>x.id===id); if(!t) return;
|
|
1840
1857
|
state.selected=id; state.retry=t.results.length-1; if(!quiet){ if(state.view!=='tests') showView('tests'); else setHash(); } refresh(true); renderDetail(t);
|
|
1841
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'}); }
|
|
1842
1861
|
}
|
|
1843
1862
|
function renderDetail(t, d, retryIdx){
|
|
1844
1863
|
d=d||$('#detail'); d.innerHTML='';
|
|
@@ -1861,10 +1880,30 @@ function renderDetail(t, d, retryIdx){
|
|
|
1861
1880
|
const r=t.results[retry]; if(!r){ d.append(h('p',{class:'empty'},'This test did not run.')); return; }
|
|
1862
1881
|
const body=h('div',{});
|
|
1863
1882
|
if(t.note&&retry===t.results.length-1) body.append(h('div',{class:'note '+(t.outcome==='passed'?'ok':'warn')}, t.note));
|
|
1864
|
-
|
|
1865
|
-
|
|
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);
|
|
1866
1904
|
body.append(h('h4',{class:'st-h'},data.bdd?'Scenario steps':'Steps', h('span',{class:'hint'},'bar = share of '+ms(stepTotal)),
|
|
1867
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);
|
|
1868
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))))); }
|
|
1869
1908
|
for(const b of r.data){ body.append(h('h4',{},b.name), dataBlock(b)); }
|
|
1870
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 ****')); }
|
|
@@ -1878,9 +1917,7 @@ function renderDetail(t, d, retryIdx){
|
|
|
1878
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); } }
|
|
1879
1918
|
const plainImgs=imgs.filter(a=>!/-(expected|actual|diff)(\.\w+)?$/.test(a.name));
|
|
1880
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]);
|
|
1881
|
-
if(vids.length){ body.append(h('h4',{},vids.length>1?'Videos':'Video'), h('div',{class:'vids'}, vids.map(a=>
|
|
1882
|
-
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.')); });
|
|
1883
|
-
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))); }
|
|
1884
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))))); }
|
|
1885
1922
|
if(traces.length){ body.append(h('h4',{},'Trace'), h('div',{class:'trace'}, traces.map(a=>h('div',{class:'trace-card'},
|
|
1886
1923
|
h('div',{}, h('b',{},a.name), a.size?h('span',{style:'color:var(--ink-3)'},' · '+kb(a.size)):null),
|
|
@@ -1894,15 +1931,43 @@ function renderDetail(t, d, retryIdx){
|
|
|
1894
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.'));
|
|
1895
1932
|
d.append(body);
|
|
1896
1933
|
}
|
|
1897
|
-
function
|
|
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){
|
|
1898
1960
|
return h('ul',{class:'steps'}, steps.map(s=>{
|
|
1899
1961
|
const bad=!!s.error, skip=s.status==='skipped', kids=s.steps.length>0, pct=total?Math.min(100,s.duration/total*100):0;
|
|
1900
1962
|
// a step with sub-steps starts collapsed; the path to a failure starts open unless expandFailedSteps is false
|
|
1901
1963
|
const li=h('li',{class:kids&&(data.options.expandFailedSteps===false||!hasError(s))?'collapsed':''});
|
|
1902
|
-
const
|
|
1903
|
-
|
|
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);
|
|
1904
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='▾'; }
|
|
1905
|
-
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));
|
|
1906
1971
|
return li;
|
|
1907
1972
|
}));
|
|
1908
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reporting-labs",
|
|
3
|
-
"version": "0.6.
|
|
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",
|