reporting-labs 0.6.23 → 0.6.25
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 +1 -1
- package/dist/auto.js +14 -0
- package/dist/reporter.d.ts +2 -0
- package/dist/reporter.js +20 -2
- package/dist/template.html +51 -17
- package/dist/template.js +51 -17
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -317,7 +317,7 @@ are right; data tables and the steps left unrun need 8+.
|
|
|
317
317
|
### Failures: everything you need to triage
|
|
318
318
|
|
|
319
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.
|
|
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. A popup or second tab has its own recording, and every player follows the steps.
|
|
321
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`).
|
|
322
322
|
- **By owner**: who to ping, with failed and flaky counts. Click an owner to filter.
|
|
323
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
|
@@ -171,12 +171,26 @@ function note(ev) {
|
|
|
171
171
|
return;
|
|
172
172
|
info.attach('rl:browser', { body: JSON.stringify({ t: Date.now(), ...ev }), contentType: 'application/x-rl-browser' }).catch(() => { });
|
|
173
173
|
}
|
|
174
|
+
/** A recorded page opened. Playwright names the test's videos video.webm, video-1.webm, ... in the order their pages
|
|
175
|
+
* opened, so the n-th note here is when video n starts: the report can then play a popup's recording in step too. */
|
|
176
|
+
const pagesSeen = new Map();
|
|
177
|
+
function notePage() {
|
|
178
|
+
const info = currentTest();
|
|
179
|
+
if (!info)
|
|
180
|
+
return;
|
|
181
|
+
const key = info.testId + ':' + info.retry;
|
|
182
|
+
const i = pagesSeen.get(key) ?? 0;
|
|
183
|
+
pagesSeen.set(key, i + 1);
|
|
184
|
+
info.attach('rl:page', { body: JSON.stringify({ i, t: Date.now() }), contentType: 'application/x-rl-page' }).catch(() => { });
|
|
185
|
+
}
|
|
174
186
|
/** Listen to a browser context: uncaught page errors, console.error, and requests that failed or got 4xx/5xx. */
|
|
175
187
|
function watchContext(ctx) {
|
|
176
188
|
if (!ctx || typeof ctx.on !== 'function' || ctx[WATCHED])
|
|
177
189
|
return;
|
|
178
190
|
ctx[WATCHED] = true;
|
|
179
191
|
const onPage = (page) => {
|
|
192
|
+
if (safe(() => page.video()))
|
|
193
|
+
notePage();
|
|
180
194
|
page.on('pageerror', (err) => note({ kind: 'error', text: oneLine(err?.message || err), stack: oneLine(err?.stack, 4000), url: safe(() => page.url()) }));
|
|
181
195
|
page.on('console', (msg) => {
|
|
182
196
|
if (msg.type() !== 'error')
|
package/dist/reporter.d.ts
CHANGED
|
@@ -61,6 +61,8 @@ export default class ReportingLabsReporter implements Reporter {
|
|
|
61
61
|
private serializeError;
|
|
62
62
|
private outcome;
|
|
63
63
|
private titlePath;
|
|
64
|
+
/** A video's first frame: Playwright saves the n-th recorded page of a test as video-n.webm (the first as video.webm). */
|
|
65
|
+
private withVideoStart;
|
|
64
66
|
private serializeResult;
|
|
65
67
|
private browserEvent;
|
|
66
68
|
private serializeStep;
|
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|rl:browser|(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS) )/.test(s.title);
|
|
55
|
+
return s.category === 'test.attach' && /^Attach "(rl:log|rl:browser|rl:page|(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
|
|
@@ -621,9 +621,18 @@ class ReportingLabsReporter {
|
|
|
621
621
|
}
|
|
622
622
|
return parts;
|
|
623
623
|
}
|
|
624
|
+
/** A video's first frame: Playwright saves the n-th recorded page of a test as video-n.webm (the first as video.webm). */
|
|
625
|
+
withVideoStart(out, a, pageOpened) {
|
|
626
|
+
if (!out || !a.path || !a.contentType.startsWith('video/'))
|
|
627
|
+
return out;
|
|
628
|
+
const m = /^video(?:-(\d+))?\.webm$/.exec(path.basename(a.path));
|
|
629
|
+
const t = m ? pageOpened[m[1] ? Number(m[1]) : 0] : undefined;
|
|
630
|
+
return t != null ? { ...out, videoStart: t } : out;
|
|
631
|
+
}
|
|
624
632
|
serializeResult(r, test) {
|
|
625
633
|
const logs = [], data = [], api = [], browser = [];
|
|
626
634
|
const normal = [];
|
|
635
|
+
const pageOpened = []; // when each recorded page opened, in order (reporting-labs/auto)
|
|
627
636
|
for (const a of r.attachments) {
|
|
628
637
|
const body = a.body ?? (a.path && fs.existsSync(a.path) ? fs.readFileSync(a.path) : undefined);
|
|
629
638
|
if (a.contentType === 'application/x-rl-log' && body) {
|
|
@@ -641,6 +650,15 @@ class ReportingLabsReporter {
|
|
|
641
650
|
catch { /* ignore */ }
|
|
642
651
|
continue;
|
|
643
652
|
}
|
|
653
|
+
if (a.contentType === 'application/x-rl-page' && body) {
|
|
654
|
+
try {
|
|
655
|
+
const pg = JSON.parse(body.toString());
|
|
656
|
+
if (Number.isInteger(pg.i) && typeof pg.t === 'number')
|
|
657
|
+
pageOpened[pg.i] = pg.t;
|
|
658
|
+
}
|
|
659
|
+
catch { /* ignore */ }
|
|
660
|
+
continue;
|
|
661
|
+
}
|
|
644
662
|
if (a.contentType === 'application/x-rl-browser' && body) {
|
|
645
663
|
try {
|
|
646
664
|
browser.push(this.browserEvent(JSON.parse(body.toString())));
|
|
@@ -675,7 +693,7 @@ class ReportingLabsReporter {
|
|
|
675
693
|
workerIndex: r.parallelIndex,
|
|
676
694
|
errors: r.errors.map(e => this.serializeError(e)),
|
|
677
695
|
steps: r.steps.filter(s => !isInternalAttach(s)).map(s => this.serializeStep(s)),
|
|
678
|
-
attachments: normal.map(a => this.serializeAttachment(a, test)).filter(Boolean),
|
|
696
|
+
attachments: normal.map(a => this.withVideoStart(this.serializeAttachment(a, test), a, pageOpened)).filter(Boolean),
|
|
679
697
|
stdout: r.stdout.map(c => this.masker.maskStr(stripAnsi(c.toString()))),
|
|
680
698
|
stderr: r.stderr.map(c => this.masker.maskStr(stripAnsi(c.toString()))),
|
|
681
699
|
...(browser.length ? { browser: browser.sort((x, y) => x.t - y.t) } : {}),
|
package/dist/template.html
CHANGED
|
@@ -316,6 +316,7 @@ li.collapsed>ul{display:none}
|
|
|
316
316
|
.vids figure{margin:0;border:1px solid var(--line);border-radius:var(--radius);overflow:hidden;background:#000}
|
|
317
317
|
.vids video{width:100%;display:block;max-height:420px;background:#000}
|
|
318
318
|
.vids figcaption{font:11px var(--mono);padding:6px 8px;color:var(--ink-2);background:var(--surface-2)}
|
|
319
|
+
.vids figure{transition:opacity .2s} .vids figure.off{opacity:.45}
|
|
319
320
|
.trace-card{border:1px solid var(--line);border-radius:var(--radius);padding:12px 14px;display:flex;flex-direction:column;gap:8px;font-size:13px}
|
|
320
321
|
.trace-how{color:var(--ink-2);font-size:12px} .trace-how code{font:12px var(--mono);background:var(--surface-2);padding:1px 5px;border-radius:3px}
|
|
321
322
|
.trace-card .dl{align-self:flex-start;font-size:12px;padding:6px 10px;border:1px solid var(--accent);border-radius:var(--radius);text-decoration:none}
|
|
@@ -594,9 +595,9 @@ html,body{-webkit-font-smoothing:antialiased}
|
|
|
594
595
|
.chg .seg:hover,.chg .seg[aria-expanded=true]{border-bottom-color:currentColor}
|
|
595
596
|
.chg .seg.nf{color:var(--fail)} .chg .seg.fx{color:var(--pass)} .chg .seg.sf{color:var(--ink)} .chg .seg.sl{color:var(--flaky-ink)} .chg .seg.nt{color:var(--accent-2)}
|
|
596
597
|
.chg .same{color:var(--ink-3)} .chg .spacer{flex:1}
|
|
597
|
-
.chg-list[hidden]{display:none} .chg-list{flex-basis:100%;list-style:none;margin:2px 0 0;padding:8px 0 0;border-top:1px solid var(--line);display:grid;gap:2px}
|
|
598
|
+
.chg-list[hidden]{display:none} .chg-list{flex-basis:100%;min-width:0;max-height:396px;overflow-y:auto;list-style:none;margin:2px 0 0;padding:8px 0 0;border-top:1px solid var(--line);display:grid;grid-template-columns:minmax(0,1fr);gap:2px} .chg-list li{min-width:0}
|
|
598
599
|
.chg-list button{display:flex;align-items:center;gap:8px;width:100%;text-align:left;padding:4px 6px;border-radius:6px;color:var(--ink);font:inherit;cursor:pointer;min-width:0} .chg-list button:hover{background:var(--surface-2)}
|
|
599
|
-
.chg-list .st{width:8px;height:8px;border-radius:50%;flex:none} .chg-list .n{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} .chg-list .f{margin-left:auto;flex:none;color:var(--ink-3);font-size:12px} .chg-list .more{color:var(--ink-3);font-size:12px;padding:4px 6px}
|
|
600
|
+
.chg-list .st{width:8px;height:8px;border-radius:50%;flex:none} .chg-list .n{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} .chg-list .f{margin-left:auto;flex:none;max-width:40%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--ink-3);font-size:12px} .chg-list .more{color:var(--ink-3);font-size:12px;padding:4px 6px}
|
|
600
601
|
.rerun{display:flex;align-items:center;gap:10px;margin:12px 0;padding:5px 5px 5px 12px;background:var(--surface-2);border-radius:6px;min-width:0}
|
|
601
602
|
.rerun .k{flex:none;font-size:12px;color:var(--ink-3)} .rerun code{flex:1;min-width:0;font:12px var(--mono);color:var(--ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis} .rerun .btn{flex:none;background:var(--surface)}
|
|
602
603
|
@media print{.chg,.rerun{display:none}}
|
|
@@ -1237,12 +1238,25 @@ function initials(name){ return (name||'').split(/[\s\-–—·]+/).filter(Boole
|
|
|
1237
1238
|
function prevRun(){
|
|
1238
1239
|
const H=data.history||[]; if(H.length<2) return null;
|
|
1239
1240
|
const cur=H[H.length-1], n=cur.total||0;
|
|
1240
|
-
|
|
1241
|
+
// a pass rate is only compared with a run of a similar size: never a full run with a debug run of a few specs,
|
|
1242
|
+
// nor a re-run of the failed tests with the full run
|
|
1243
|
+
const comparable=e=> (e.total||0)>=n/2 && (e.total||0)<=n*2;
|
|
1241
1244
|
let fallback=null;
|
|
1242
1245
|
for(let i=H.length-2;i>=0;i--){ if(!comparable(H[i])) continue; if(!cur.label||H[i].label!==cur.label) return H[i]; if(!fallback) fallback=H[i]; }
|
|
1243
1246
|
return fallback;
|
|
1244
1247
|
}
|
|
1245
1248
|
|
|
1249
|
+
/* The run "Since last run" compares with: the latest earlier run that ran at least half of this run's tests. So a
|
|
1250
|
+
full run that follows a debug run of a few specs is compared with the last full run, and a re-run of the failed
|
|
1251
|
+
tests with the run they failed in. History written before per-test results were kept falls back to prevRun(). */
|
|
1252
|
+
function changesBase(){
|
|
1253
|
+
const H=data.history||[]; if(H.length<2) return null;
|
|
1254
|
+
const keys=data.tests.map(t=>t.key); if(!keys.length) return null;
|
|
1255
|
+
if(!H.slice(0,-1).some(e=>e.tests)) return prevRun();
|
|
1256
|
+
for(let i=H.length-2;i>=0;i--){ const e=H[i]; if(!e.tests) continue; let n=0; for(const k of keys) if(e.tests[k]) n++; if(n>=keys.length/2) return e; }
|
|
1257
|
+
return null;
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1246
1260
|
/* ---------- since last run, and the command to run tests again ---------- */
|
|
1247
1261
|
/* The command that runs these tests again. The runner gives the shape in data.rerun ({pre, sep, post}) and each test
|
|
1248
1262
|
its target first, then options it needs (Playwright: file:line, then --project=...). Targets and options are
|
|
@@ -1256,7 +1270,7 @@ function rerunCmd(ts){
|
|
|
1256
1270
|
/* One line under the cards: what changed against the previous comparable run, each part opens its tests.
|
|
1257
1271
|
Without history it still offers the command for the failed tests. */
|
|
1258
1272
|
function changesLine(){
|
|
1259
|
-
const p=
|
|
1273
|
+
const p=changesBase(), base=p&&p.tests? p : null;
|
|
1260
1274
|
const failed=data.tests.filter(t=>isFail(t.outcome)), cmd=rerunCmd(failed);
|
|
1261
1275
|
if(!base&&!cmd) return null;
|
|
1262
1276
|
const segs=[];
|
|
@@ -1275,8 +1289,9 @@ function changesLine(){
|
|
|
1275
1289
|
const toggle=(k,ts,btn)=>{ el.querySelectorAll('.seg').forEach(b=>b.setAttribute('aria-expanded','false'));
|
|
1276
1290
|
if(open===k){ open=null; list.hidden=true; return; }
|
|
1277
1291
|
open=k; btn.setAttribute('aria-expanded','true'); list.hidden=false; list.innerHTML='';
|
|
1278
|
-
|
|
1279
|
-
|
|
1292
|
+
// every test the number counts: past about 12 rows the list scrolls inside the card
|
|
1293
|
+
list.append(...ts.map(t=>h('li',{}, h('button',{onclick:()=>select(t.id),title:t.title}, h('span',{class:'st '+t.outcome}), h('span',{class:'n'},t.title), h('span',{class:'f'},t.file.split('/').pop()+(data.projects.length>1&&t.project?' · '+t.project:''))))));
|
|
1294
|
+
list.scrollTop=0;
|
|
1280
1295
|
};
|
|
1281
1296
|
if(base) el.append(h('span',{class:'lead'},'Since last run', h('small',{},runLabel(base))));
|
|
1282
1297
|
else el.append(h('span',{class:'lead'}, failed.length+' failed'));
|
|
@@ -1820,17 +1835,36 @@ function renderDetail(t, d, retryIdx){
|
|
|
1820
1835
|
const near=fail!=null? (r.browser||[]).filter(e=>e.t<=fail&&fail-e.t<=5000).length : 0;
|
|
1821
1836
|
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
1837
|
if(bsec&&failedRun) body.append(bsec);
|
|
1823
|
-
//
|
|
1824
|
-
|
|
1838
|
+
// each video's first frame on the wall clock: given by the runner (Node.js: when its page opened; Java, Python: the
|
|
1839
|
+
// page closed minus the video's length), or for an older Node.js report the first video from its "Create page" step.
|
|
1840
|
+
// A popup or second tab has its own recording: every player follows the steps, each from its own start.
|
|
1841
|
+
const allVids=r.attachments.filter(a=>a.src&&a.contentType.startsWith('video/')),
|
|
1842
|
+
starts=allVids.map((a,i)=>a.videoStart||(i===0? videoStart(r.steps) : null)), v0=starts.some(x=>x!=null)? Math.min(...starts.filter(x=>x!=null)) : null;
|
|
1825
1843
|
let sync=null;
|
|
1826
1844
|
if(v0!=null){
|
|
1827
|
-
const
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1845
|
+
const many=allVids.length>1;
|
|
1846
|
+
const figs=allVids.map((a,i)=>videoFigure(a, many? 'page '+(i+1)+(starts[i]!=null&&i>0? ', opened at '+ms(Math.max(0,starts[i]-r.startTime)) : '') : null)),
|
|
1847
|
+
players=figs.map((f,i)=>({...f, s0:starts[i]})).filter(p=>p.s0!=null), tree=()=>body.querySelectorAll('.step[data-s]');
|
|
1848
|
+
const len=p=>isFinite(p.v.duration)? p.v.duration*1000 : Infinity, covers=(p,abs)=>abs>=p.s0&&abs<=p.s0+len(p);
|
|
1849
|
+
const light=at=>{ 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'); };
|
|
1850
|
+
const show=(p,on)=>{ if(many){ p.fig.classList.toggle('off',!on); } };
|
|
1851
|
+
sync={ from:v0, seek:abs=>{
|
|
1852
|
+
// the players recording at that moment play from it; the others wait (dimmed) and join when their page opens
|
|
1853
|
+
let first=null;
|
|
1854
|
+
for(const p of players){ if(covers(p,abs)){ p.v.currentTime=(abs-p.s0)/1000; p.v.play().catch(()=>{}); show(p,true); first=first||p; } else { p.v.pause(); p.v.currentTime=abs<p.s0||!isFinite(len(p))? 0 : len(p)/1000; show(p,false); } }
|
|
1855
|
+
if(!first){ first=players.reduce((a,b)=>b.s0<a.s0?b:a); first.v.currentTime=Math.max(0,(abs-first.s0)/1000); first.v.play().catch(()=>{}); show(first,true); }
|
|
1856
|
+
first.v.scrollIntoView({block:'nearest',behavior:'smooth'}); } };
|
|
1857
|
+
// a step that starts after every recording ended (closing the browser) has nothing to show
|
|
1858
|
+
const hideLate=()=>{ if(players.some(p=>!isFinite(p.v.duration))) return; const end=Math.max(...players.map(p=>p.s0+len(p))); for(const b of body.querySelectorAll('.vplay[data-s]')) if(+b.dataset.s>=end) b.hidden=true; };
|
|
1859
|
+
for(const p of players){
|
|
1860
|
+
p.v.addEventListener('loadedmetadata',hideLate);
|
|
1861
|
+
p.v.addEventListener('timeupdate',()=>{ if(many&&p.fig.classList.contains('off')) return; const at=p.s0+p.v.currentTime*1000; light(at);
|
|
1862
|
+
// a page opened while this one plays: start its recording too
|
|
1863
|
+
if(many&&!p.v.paused) for(const o of players) if(o!==p&&o.v.paused&&covers(o,at)&&o.v.currentTime*1000<at-o.s0-400){ o.v.currentTime=(at-o.s0)/1000; o.v.play().catch(()=>{}); show(o,true); } });
|
|
1864
|
+
if(many) p.v.addEventListener('ended',()=>show(p,false));
|
|
1865
|
+
}
|
|
1866
|
+
body.append(h('h4',{},many?'Videos':'Video'), h('div',{class:'vsync'},
|
|
1867
|
+
h('span',{class:'hint'}, many? 'In step with the test: each page (a popup, a second tab) has its own recording, and they play together. The step playing lights up below. Click ▶ on a step to watch it.' : 'In step with the test: the step playing lights up below. Click ▶ on a step to watch it.'),
|
|
1834
1868
|
fail!=null? h('button',{class:'btn primary',type:'button',onclick:()=>sync.seek(fail-5000)},'▶ Watch the failure') : null),
|
|
1835
1869
|
h('div',{class:'vids'}, figs.map(f=>f.fig)));
|
|
1836
1870
|
}
|
|
@@ -1865,9 +1899,9 @@ function renderDetail(t, d, retryIdx){
|
|
|
1865
1899
|
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.'));
|
|
1866
1900
|
d.append(body);
|
|
1867
1901
|
}
|
|
1868
|
-
function videoFigure(a){ const fig=h('figure',{}); const v=h('video',{src:a.src,controls:'',preload:'metadata',playsinline:''});
|
|
1902
|
+
function videoFigure(a, label){ const fig=h('figure',{}); const v=h('video',{src:a.src,controls:'',preload:'metadata',playsinline:''});
|
|
1869
1903
|
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}; }
|
|
1904
|
+
fig.append(v, h('figcaption',{}, a.name, label?h('span',{},' · '+label):null, 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
1905
|
/* Playwright starts recording a page's video when the page is created: the first "Create page" step ends at the
|
|
1872
1906
|
video's 0:00 (measured within ~20ms). Without that step (other runners) the video is not lined up with steps. */
|
|
1873
1907
|
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; }
|
package/dist/template.js
CHANGED
|
@@ -387,6 +387,7 @@ li.collapsed>ul{display:none}
|
|
|
387
387
|
.vids figure{margin:0;border:1px solid var(--line);border-radius:var(--radius);overflow:hidden;background:#000}
|
|
388
388
|
.vids video{width:100%;display:block;max-height:420px;background:#000}
|
|
389
389
|
.vids figcaption{font:11px var(--mono);padding:6px 8px;color:var(--ink-2);background:var(--surface-2)}
|
|
390
|
+
.vids figure{transition:opacity .2s} .vids figure.off{opacity:.45}
|
|
390
391
|
.trace-card{border:1px solid var(--line);border-radius:var(--radius);padding:12px 14px;display:flex;flex-direction:column;gap:8px;font-size:13px}
|
|
391
392
|
.trace-how{color:var(--ink-2);font-size:12px} .trace-how code{font:12px var(--mono);background:var(--surface-2);padding:1px 5px;border-radius:3px}
|
|
392
393
|
.trace-card .dl{align-self:flex-start;font-size:12px;padding:6px 10px;border:1px solid var(--accent);border-radius:var(--radius);text-decoration:none}
|
|
@@ -665,9 +666,9 @@ html,body{-webkit-font-smoothing:antialiased}
|
|
|
665
666
|
.chg .seg:hover,.chg .seg[aria-expanded=true]{border-bottom-color:currentColor}
|
|
666
667
|
.chg .seg.nf{color:var(--fail)} .chg .seg.fx{color:var(--pass)} .chg .seg.sf{color:var(--ink)} .chg .seg.sl{color:var(--flaky-ink)} .chg .seg.nt{color:var(--accent-2)}
|
|
667
668
|
.chg .same{color:var(--ink-3)} .chg .spacer{flex:1}
|
|
668
|
-
.chg-list[hidden]{display:none} .chg-list{flex-basis:100%;list-style:none;margin:2px 0 0;padding:8px 0 0;border-top:1px solid var(--line);display:grid;gap:2px}
|
|
669
|
+
.chg-list[hidden]{display:none} .chg-list{flex-basis:100%;min-width:0;max-height:396px;overflow-y:auto;list-style:none;margin:2px 0 0;padding:8px 0 0;border-top:1px solid var(--line);display:grid;grid-template-columns:minmax(0,1fr);gap:2px} .chg-list li{min-width:0}
|
|
669
670
|
.chg-list button{display:flex;align-items:center;gap:8px;width:100%;text-align:left;padding:4px 6px;border-radius:6px;color:var(--ink);font:inherit;cursor:pointer;min-width:0} .chg-list button:hover{background:var(--surface-2)}
|
|
670
|
-
.chg-list .st{width:8px;height:8px;border-radius:50%;flex:none} .chg-list .n{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} .chg-list .f{margin-left:auto;flex:none;color:var(--ink-3);font-size:12px} .chg-list .more{color:var(--ink-3);font-size:12px;padding:4px 6px}
|
|
671
|
+
.chg-list .st{width:8px;height:8px;border-radius:50%;flex:none} .chg-list .n{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} .chg-list .f{margin-left:auto;flex:none;max-width:40%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--ink-3);font-size:12px} .chg-list .more{color:var(--ink-3);font-size:12px;padding:4px 6px}
|
|
671
672
|
.rerun{display:flex;align-items:center;gap:10px;margin:12px 0;padding:5px 5px 5px 12px;background:var(--surface-2);border-radius:6px;min-width:0}
|
|
672
673
|
.rerun .k{flex:none;font-size:12px;color:var(--ink-3)} .rerun code{flex:1;min-width:0;font:12px var(--mono);color:var(--ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis} .rerun .btn{flex:none;background:var(--surface)}
|
|
673
674
|
@media print{.chg,.rerun{display:none}}
|
|
@@ -1303,12 +1304,25 @@ function initials(name){ return (name||'').split(/[\s\-–—·]+/).filter(Boole
|
|
|
1303
1304
|
function prevRun(){
|
|
1304
1305
|
const H=data.history||[]; if(H.length<2) return null;
|
|
1305
1306
|
const cur=H[H.length-1], n=cur.total||0;
|
|
1306
|
-
|
|
1307
|
+
// a pass rate is only compared with a run of a similar size: never a full run with a debug run of a few specs,
|
|
1308
|
+
// nor a re-run of the failed tests with the full run
|
|
1309
|
+
const comparable=e=> (e.total||0)>=n/2 && (e.total||0)<=n*2;
|
|
1307
1310
|
let fallback=null;
|
|
1308
1311
|
for(let i=H.length-2;i>=0;i--){ if(!comparable(H[i])) continue; if(!cur.label||H[i].label!==cur.label) return H[i]; if(!fallback) fallback=H[i]; }
|
|
1309
1312
|
return fallback;
|
|
1310
1313
|
}
|
|
1311
1314
|
|
|
1315
|
+
/* The run "Since last run" compares with: the latest earlier run that ran at least half of this run's tests. So a
|
|
1316
|
+
full run that follows a debug run of a few specs is compared with the last full run, and a re-run of the failed
|
|
1317
|
+
tests with the run they failed in. History written before per-test results were kept falls back to prevRun(). */
|
|
1318
|
+
function changesBase(){
|
|
1319
|
+
const H=data.history||[]; if(H.length<2) return null;
|
|
1320
|
+
const keys=data.tests.map(t=>t.key); if(!keys.length) return null;
|
|
1321
|
+
if(!H.slice(0,-1).some(e=>e.tests)) return prevRun();
|
|
1322
|
+
for(let i=H.length-2;i>=0;i--){ const e=H[i]; if(!e.tests) continue; let n=0; for(const k of keys) if(e.tests[k]) n++; if(n>=keys.length/2) return e; }
|
|
1323
|
+
return null;
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1312
1326
|
/* ---------- since last run, and the command to run tests again ---------- */
|
|
1313
1327
|
/* The command that runs these tests again. The runner gives the shape in data.rerun ({pre, sep, post}) and each test
|
|
1314
1328
|
its target first, then options it needs (Playwright: file:line, then --project=...). Targets and options are
|
|
@@ -1322,7 +1336,7 @@ function rerunCmd(ts){
|
|
|
1322
1336
|
/* One line under the cards: what changed against the previous comparable run, each part opens its tests.
|
|
1323
1337
|
Without history it still offers the command for the failed tests. */
|
|
1324
1338
|
function changesLine(){
|
|
1325
|
-
const p=
|
|
1339
|
+
const p=changesBase(), base=p&&p.tests? p : null;
|
|
1326
1340
|
const failed=data.tests.filter(t=>isFail(t.outcome)), cmd=rerunCmd(failed);
|
|
1327
1341
|
if(!base&&!cmd) return null;
|
|
1328
1342
|
const segs=[];
|
|
@@ -1341,8 +1355,9 @@ function changesLine(){
|
|
|
1341
1355
|
const toggle=(k,ts,btn)=>{ el.querySelectorAll('.seg').forEach(b=>b.setAttribute('aria-expanded','false'));
|
|
1342
1356
|
if(open===k){ open=null; list.hidden=true; return; }
|
|
1343
1357
|
open=k; btn.setAttribute('aria-expanded','true'); list.hidden=false; list.innerHTML='';
|
|
1344
|
-
|
|
1345
|
-
|
|
1358
|
+
// every test the number counts: past about 12 rows the list scrolls inside the card
|
|
1359
|
+
list.append(...ts.map(t=>h('li',{}, h('button',{onclick:()=>select(t.id),title:t.title}, h('span',{class:'st '+t.outcome}), h('span',{class:'n'},t.title), h('span',{class:'f'},t.file.split('/').pop()+(data.projects.length>1&&t.project?' · '+t.project:''))))));
|
|
1360
|
+
list.scrollTop=0;
|
|
1346
1361
|
};
|
|
1347
1362
|
if(base) el.append(h('span',{class:'lead'},'Since last run', h('small',{},runLabel(base))));
|
|
1348
1363
|
else el.append(h('span',{class:'lead'}, failed.length+' failed'));
|
|
@@ -1886,17 +1901,36 @@ function renderDetail(t, d, retryIdx){
|
|
|
1886
1901
|
const near=fail!=null? (r.browser||[]).filter(e=>e.t<=fail&&fail-e.t<=5000).length : 0;
|
|
1887
1902
|
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
1903
|
if(bsec&&failedRun) body.append(bsec);
|
|
1889
|
-
//
|
|
1890
|
-
|
|
1904
|
+
// each video's first frame on the wall clock: given by the runner (Node.js: when its page opened; Java, Python: the
|
|
1905
|
+
// page closed minus the video's length), or for an older Node.js report the first video from its "Create page" step.
|
|
1906
|
+
// A popup or second tab has its own recording: every player follows the steps, each from its own start.
|
|
1907
|
+
const allVids=r.attachments.filter(a=>a.src&&a.contentType.startsWith('video/')),
|
|
1908
|
+
starts=allVids.map((a,i)=>a.videoStart||(i===0? videoStart(r.steps) : null)), v0=starts.some(x=>x!=null)? Math.min(...starts.filter(x=>x!=null)) : null;
|
|
1891
1909
|
let sync=null;
|
|
1892
1910
|
if(v0!=null){
|
|
1893
|
-
const
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1911
|
+
const many=allVids.length>1;
|
|
1912
|
+
const figs=allVids.map((a,i)=>videoFigure(a, many? 'page '+(i+1)+(starts[i]!=null&&i>0? ', opened at '+ms(Math.max(0,starts[i]-r.startTime)) : '') : null)),
|
|
1913
|
+
players=figs.map((f,i)=>({...f, s0:starts[i]})).filter(p=>p.s0!=null), tree=()=>body.querySelectorAll('.step[data-s]');
|
|
1914
|
+
const len=p=>isFinite(p.v.duration)? p.v.duration*1000 : Infinity, covers=(p,abs)=>abs>=p.s0&&abs<=p.s0+len(p);
|
|
1915
|
+
const light=at=>{ 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'); };
|
|
1916
|
+
const show=(p,on)=>{ if(many){ p.fig.classList.toggle('off',!on); } };
|
|
1917
|
+
sync={ from:v0, seek:abs=>{
|
|
1918
|
+
// the players recording at that moment play from it; the others wait (dimmed) and join when their page opens
|
|
1919
|
+
let first=null;
|
|
1920
|
+
for(const p of players){ if(covers(p,abs)){ p.v.currentTime=(abs-p.s0)/1000; p.v.play().catch(()=>{}); show(p,true); first=first||p; } else { p.v.pause(); p.v.currentTime=abs<p.s0||!isFinite(len(p))? 0 : len(p)/1000; show(p,false); } }
|
|
1921
|
+
if(!first){ first=players.reduce((a,b)=>b.s0<a.s0?b:a); first.v.currentTime=Math.max(0,(abs-first.s0)/1000); first.v.play().catch(()=>{}); show(first,true); }
|
|
1922
|
+
first.v.scrollIntoView({block:'nearest',behavior:'smooth'}); } };
|
|
1923
|
+
// a step that starts after every recording ended (closing the browser) has nothing to show
|
|
1924
|
+
const hideLate=()=>{ if(players.some(p=>!isFinite(p.v.duration))) return; const end=Math.max(...players.map(p=>p.s0+len(p))); for(const b of body.querySelectorAll('.vplay[data-s]')) if(+b.dataset.s>=end) b.hidden=true; };
|
|
1925
|
+
for(const p of players){
|
|
1926
|
+
p.v.addEventListener('loadedmetadata',hideLate);
|
|
1927
|
+
p.v.addEventListener('timeupdate',()=>{ if(many&&p.fig.classList.contains('off')) return; const at=p.s0+p.v.currentTime*1000; light(at);
|
|
1928
|
+
// a page opened while this one plays: start its recording too
|
|
1929
|
+
if(many&&!p.v.paused) for(const o of players) if(o!==p&&o.v.paused&&covers(o,at)&&o.v.currentTime*1000<at-o.s0-400){ o.v.currentTime=(at-o.s0)/1000; o.v.play().catch(()=>{}); show(o,true); } });
|
|
1930
|
+
if(many) p.v.addEventListener('ended',()=>show(p,false));
|
|
1931
|
+
}
|
|
1932
|
+
body.append(h('h4',{},many?'Videos':'Video'), h('div',{class:'vsync'},
|
|
1933
|
+
h('span',{class:'hint'}, many? 'In step with the test: each page (a popup, a second tab) has its own recording, and they play together. The step playing lights up below. Click ▶ on a step to watch it.' : 'In step with the test: the step playing lights up below. Click ▶ on a step to watch it.'),
|
|
1900
1934
|
fail!=null? h('button',{class:'btn primary',type:'button',onclick:()=>sync.seek(fail-5000)},'▶ Watch the failure') : null),
|
|
1901
1935
|
h('div',{class:'vids'}, figs.map(f=>f.fig)));
|
|
1902
1936
|
}
|
|
@@ -1931,9 +1965,9 @@ function renderDetail(t, d, retryIdx){
|
|
|
1931
1965
|
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.'));
|
|
1932
1966
|
d.append(body);
|
|
1933
1967
|
}
|
|
1934
|
-
function videoFigure(a){ const fig=h('figure',{}); const v=h('video',{src:a.src,controls:'',preload:'metadata',playsinline:''});
|
|
1968
|
+
function videoFigure(a, label){ const fig=h('figure',{}); const v=h('video',{src:a.src,controls:'',preload:'metadata',playsinline:''});
|
|
1935
1969
|
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}; }
|
|
1970
|
+
fig.append(v, h('figcaption',{}, a.name, label?h('span',{},' · '+label):null, 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
1971
|
/* Playwright starts recording a page's video when the page is created: the first "Create page" step ends at the
|
|
1938
1972
|
video's 0:00 (measured within ~20ms). Without that step (other runners) the video is not lined up with steps. */
|
|
1939
1973
|
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; }
|
package/dist/types.d.ts
CHANGED
|
@@ -234,6 +234,8 @@ export interface AttachmentData {
|
|
|
234
234
|
text?: string;
|
|
235
235
|
/** bytes on disk, when known */
|
|
236
236
|
size?: number;
|
|
237
|
+
/** A video's first frame (ms since epoch), when the runner knows it: lines the video up with the steps. */
|
|
238
|
+
videoStart?: number;
|
|
237
239
|
}
|
|
238
240
|
export interface ResultData {
|
|
239
241
|
retry: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reporting-labs",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.25",
|
|
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",
|