reporting-labs 0.6.11 → 0.6.13
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 +32 -2
- package/bin/cli.js +13 -0
- package/bin/config-template.txt +2 -0
- package/bin/snippets.code-snippets +78 -0
- package/dist/comments.d.ts +26 -0
- package/dist/comments.js +125 -0
- package/dist/explain.d.ts +1 -1
- package/dist/explain.js +4 -0
- package/dist/pdf.d.ts +14 -0
- package/dist/pdf.js +149 -0
- package/dist/reporter.d.ts +3 -2
- package/dist/reporter.js +44 -30
- package/dist/template.html +98 -30
- package/dist/template.js +98 -30
- package/dist/types.d.ts +8 -2
- package/dist/wdio/finalize.d.ts +1 -0
- package/dist/wdio/finalize.js +9 -23
- package/dist/wdio/reporter.d.ts +2 -0
- package/dist/wdio/reporter.js +46 -3
- package/package.json +6 -2
package/dist/template.js
CHANGED
|
@@ -415,6 +415,10 @@ li.collapsed>ul{display:none}
|
|
|
415
415
|
.wk .row{display:grid;grid-template-columns:36px 1fr 120px;gap:10px;align-items:center;font-size:12px}
|
|
416
416
|
.wk .k{font:12px var(--mono);color:var(--ink-3)} .wk .bar{height:12px;display:flex;border-radius:3px;overflow:hidden;background:var(--skip-bg)} .wk .bar i{display:block;height:100%}
|
|
417
417
|
.wk .n{font:11px var(--mono);color:var(--ink-3);text-align:right}
|
|
418
|
+
.wk .row{grid-template-columns:36px 1fr auto} .wk .n{white-space:nowrap}
|
|
419
|
+
.proj-sfx{font-weight:400;color:var(--ink-3);font-size:.9em}
|
|
420
|
+
/* the Breakdown card keeps its own height: a two-priority suite should not leave a tall empty card */
|
|
421
|
+
.bd-card{align-self:start}
|
|
418
422
|
.wk-sum{font-size:13px;color:var(--ink-2);margin-bottom:10px}
|
|
419
423
|
/* list: group toggle + folder tree */
|
|
420
424
|
.tools .seg,.bug-tools .seg{display:inline-flex;border:1px solid var(--line);border-radius:var(--radius);overflow:hidden}
|
|
@@ -450,7 +454,9 @@ table.tbl{border-collapse:collapse;font-size:12.5px;width:100%;min-width:100%}
|
|
|
450
454
|
.api-head .m{font:11px/1 var(--mono);font-weight:600;padding:4px 7px;border-radius:3px;color:#fff;background:var(--ink-3)}
|
|
451
455
|
.api-head .m.GET{background:#2A7FBF} .api-head .m.POST{background:var(--pass)} .api-head .m.PUT,.api-head .m.PATCH{background:#C77D14} .api-head .m.DELETE{background:var(--fail)}
|
|
452
456
|
.api-head .u{flex:1;font:12px var(--mono);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
453
|
-
.api-head .sc{font:12px var(--mono);font-weight:600} .api-head .sc.ok{color:var(--pass)} .api-head .sc.bad{color:var(--fail)} .api-head .sc.warn{color:#9A6A00}
|
|
457
|
+
.api-head .sc{font:12px var(--mono);font-weight:600} .api-head .sc.ok{color:var(--pass)} .api-head .sc.bad{color:var(--fail)} .api-head .sc.warn{color:#9A6A00} .api-head .sc.exp{color:var(--ink-2)}
|
|
458
|
+
.sc-exp{margin-left:6px;font:500 10.5px var(--sans);color:var(--ink-3);background:var(--surface-2);border:1px solid var(--line);border-radius:999px;padding:1px 7px;vertical-align:1px}
|
|
459
|
+
.api-stats .exp b{color:var(--ink-2)} .api-proj{color:var(--ink-3)}
|
|
454
460
|
.api-head .d{font:11px var(--mono);color:var(--ink-3)}
|
|
455
461
|
.api-body{display:grid;grid-template-columns:1fr 1fr;gap:0}
|
|
456
462
|
@media (max-width:900px){.api-body{grid-template-columns:1fr}}
|
|
@@ -630,13 +636,15 @@ html,body{-webkit-font-smoothing:antialiased}
|
|
|
630
636
|
.runbanner{margin-bottom:14px;padding:10px 14px;border-radius:10px;background:var(--flaky-bg);color:var(--flaky-ink);border:1px solid color-mix(in srgb,var(--flaky) 40%,transparent)}
|
|
631
637
|
.note{padding:10px 14px;border-radius:8px;margin-bottom:10px;border:1px solid var(--line)} .note.ok{background:var(--pass-bg);color:var(--ink)} .note.warn{background:var(--flaky-bg);color:var(--flaky-ink)}
|
|
632
638
|
.badge.xfail{background:var(--flaky-bg);color:var(--flaky-ink)}
|
|
639
|
+
.xp{font-weight:500} .xp.all{color:var(--ink)} .xp.some{color:var(--flaky-ink)}
|
|
640
|
+
.badge.xp{background:var(--surface-2);border:1px solid var(--line)} .badge.xp.some{background:var(--flaky-bg);border-color:transparent}
|
|
633
641
|
.errwrap+.errwrap{margin-top:14px}
|
|
634
642
|
.why{border:1px solid var(--line);border-radius:var(--radius);padding:10px 14px;margin-bottom:10px;background:var(--surface)}
|
|
635
643
|
.why-c{font-size:12.5px;color:var(--ink);margin-bottom:2px;line-height:1.4;overflow-wrap:anywhere} .why-c .why-k{margin-right:2px}
|
|
636
644
|
.why-l{display:flex;align-items:center;gap:8px;margin-bottom:4px} .why-k{font-size:12px;font-weight:600;color:var(--fail)} .why-a{font:11.5px var(--mono);color:var(--ink-3)}
|
|
637
645
|
.why-s{font-size:var(--fs);color:var(--ink);line-height:1.45;overflow-wrap:anywhere} .why-h{font-size:12.5px;color:var(--ink-2);margin-top:4px;line-height:1.45;overflow-wrap:anywhere}
|
|
638
646
|
.why.assertion .why-k,.why.visual .why-k{color:#9A6A00}
|
|
639
|
-
.why.script .why-k,.why.thrown .why-k,.why.file .why-k{color:var(--ink-2)}
|
|
647
|
+
.why.script .why-k,.why.thrown .why-k,.why.file .why-k,.why.crashed .why-k{color:var(--ink-2)}
|
|
640
648
|
.errloc{font-family:var(--mono);color:var(--ink-3);margin-bottom:6px} .errloc a{color:var(--accent-2);text-decoration:none} .errloc a:hover{text-decoration:underline}
|
|
641
649
|
.snip{margin:10px 0 0;background:var(--surface-2);border:1px solid var(--line);border-radius:8px;padding:10px 12px;font-family:var(--mono);line-height:1.55;white-space:pre;overflow:auto;color:var(--ink-2)}
|
|
642
650
|
/* ---------- triage extras: history, diff, export, env, heatmap ---------- */
|
|
@@ -831,6 +839,14 @@ const HIST = data.history||[];
|
|
|
831
839
|
const HRUNS = HIST.filter(e=>e&&e.tests); // entries that carry per-test outcomes; the last one is this run
|
|
832
840
|
const PREV = HRUNS.length>1 ? HRUNS.slice(0,-1) : []; // earlier runs only
|
|
833
841
|
const runLabel = e => e.label || new Date(e.time).toLocaleDateString(undefined,{month:'short',day:'numeric'});
|
|
842
|
+
/* Run-level trends (Trend card, KPI sparklines and "from last run", pass rate by priority) only use full-size
|
|
843
|
+
runs. A debug run of one spec or a --grep shares the history file with the full suite; a failing 1-test run
|
|
844
|
+
would read as a 0% day. A run is "small" when it ran fewer than half the median size of the recorded runs.
|
|
845
|
+
Per-test history (dots, flaky, new vs known) still uses every run: there a run only counts for the tests in it. */
|
|
846
|
+
const MED_SIZE = (()=>{ const z=HIST.map(e=>e.total||0).sort((a,b)=>a-b); return z.length? z[Math.floor(z.length/2)] : 0; })();
|
|
847
|
+
const isSmallRun = e => HIST.length>=3 && (e.total||0) < MED_SIZE/2;
|
|
848
|
+
const TREND = (()=>{ const f=HIST.filter((e,i)=>!isSmallRun(e)); return f.length>=2? f : HIST; })();
|
|
849
|
+
const SMALL_HIDDEN = HIST.length - TREND.length;
|
|
834
850
|
|
|
835
851
|
const state = { q:'', status:'all', project:'all', dims:{}, selected:null, retry:null, group:'file', open:{}, view:'overview' };
|
|
836
852
|
const DIMS = data.options.dimensions.filter(d=>data.tests.some(t=>t.meta[d]));
|
|
@@ -892,17 +908,20 @@ function failuresView(){
|
|
|
892
908
|
h('td',{class:'t'},t.file.split('/').pop()+(data.projects.length>1?' · '+t.project:'')), h('td',{},[t.meta.priority,t.meta.severity].filter(Boolean).join(' · ')), h('td',{},t.meta.owner||''), h('td',{},t.meta.story||t.meta.issue||''), h('td',{},t.results.length), PREV.length?h('td',{},(()=>{ const si=sinceInfo(t); return si? h('span',{class:'since-txt '+si.kind}, si.kind==='new'?'new':runLabel(si.since)) : h('span',{class:'t'},'–'); })()):null, HRUNS.length>1?h('td',{},dots(t,10)):null, h('td',{class:'t'},ms(t.duration))); })))));
|
|
893
909
|
return grid;
|
|
894
910
|
}
|
|
911
|
+
/** A 4xx/5xx is a failure only when the attempt that made the call failed. In a passing attempt it is the
|
|
912
|
+
* answer the test asked for (a 404 after a DELETE, a 401 for a bad token) — shown as "expected", never red. */
|
|
913
|
+
function apiCls(c,r){ const st=c.status||0; return st>=400 ? (r&&r.status==='passed'?'exp':'bad') : st>=300?'warn':'ok'; }
|
|
895
914
|
function apiView(){
|
|
896
|
-
const calls=[]; for(const t of data.tests) for(const r of t.results) for(const c of r.api) calls.push({c,t,r});
|
|
915
|
+
const calls=[]; for(const t of data.tests) for(const r of t.results) for(const c of r.api) calls.push({c,t,r,cls:apiCls(c,r)});
|
|
897
916
|
if(!calls.length) return h('div',{class:'card'},h('b',{},'No API calls recorded.'),' Add ',h('code',{},"import 'reporting-labs/auto'"),' to playwright.config.ts and every request.get / request.post / page.request call shows up here with headers, bodies and a cURL command. Calls made with other clients can be recorded with api().');
|
|
898
|
-
const bad=calls.filter(x=>(x.
|
|
899
|
-
calls.sort((a,b)=>(
|
|
917
|
+
const bad=calls.filter(x=>x.cls==='bad').length, expd=calls.filter(x=>x.cls==='exp').length, avg=Math.round(calls.reduce((a,x)=>a+(x.c.duration||0),0)/calls.length), slow=calls.filter(x=>(x.c.duration||0)>1000).length;
|
|
918
|
+
calls.sort((a,b)=>(b.cls==='bad')-(a.cls==='bad')||(b.c.duration||0)-(a.c.duration||0));
|
|
900
919
|
const byHost=new Map(); for(const x of calls){ try{ const hst=new URL(x.c.url).host; byHost.set(hst,(byHost.get(hst)||0)+1);}catch(e){} }
|
|
901
|
-
return h('div',{}, h('div',{class:'api-stats'}, h('span',{},h('b',{},calls.length),' calls'), h('span',{class:bad?'bad':''},h('b',{},bad),' failed (4xx/5xx)'), h('span',{},h('b',{},ms(avg)),' avg'), h('span',{},h('b',{},slow),' over 1s'), h('span',{},h('b',{},byHost.size),' host'+(byHost.size===1?'':'s'))),
|
|
920
|
+
return h('div',{}, h('div',{class:'api-stats'}, h('span',{},h('b',{},calls.length),' calls'), h('span',{class:bad?'bad':'',title:'4xx / 5xx responses in tests that failed'},h('b',{},bad),' failed (4xx/5xx)'), expd?h('span',{class:'exp',title:'4xx / 5xx responses in tests that passed: the answer the test expected, e.g. a 404 after a DELETE'},h('b',{},expd),' expected 4xx/5xx'):null, h('span',{},h('b',{},ms(avg)),' avg'), h('span',{},h('b',{},slow),' over 1s'), h('span',{},h('b',{},byHost.size),' host'+(byHost.size===1?'':'s'))),
|
|
902
921
|
h('div',{class:'card w12'}, h('table',{class:'apitbl'}, h('thead',{}, h('tr',{}, ['Method','URL','Status','Time','Test'].map(x=>h('th',{},x)))),
|
|
903
|
-
h('tbody',{}, calls.map(({c,t})=>{ const st=c.status||0
|
|
922
|
+
h('tbody',{}, calls.map(({c,t,cls})=>{ const st=c.status||0; return h('tr',{onclick:()=>select(t.id)},
|
|
904
923
|
h('td',{}, h('span',{class:'m '+c.method.toUpperCase(),style:'font:11px var(--mono);font-weight:600;padding:3px 6px;border-radius:3px;color:#fff;background:'+({GET:'#2A7FBF',POST:'var(--pass)',PUT:'#C77D14',PATCH:'#C77D14',DELETE:'var(--fail)'}[c.method.toUpperCase()]||'var(--ink-3)')},c.method.toUpperCase())),
|
|
905
|
-
h('td',{class:'u',title:c.url},c.url), h('td',{}, h('span',{class:'sc '+cls,style:'font:12px var(--mono);font-weight:600;color:'+(cls==='bad'?'var(--fail)':cls==='warn'?'var(--flaky-ink)':'var(--pass)')},st||'—')), h('td',{class:'t'},c.duration!=null?ms(c.duration):'—'), h('td',{class:'t',title:t.title},t.title)); })))));
|
|
924
|
+
h('td',{class:'u',title:c.url},c.url), h('td',{}, h('span',{class:'sc '+cls,style:'font:12px var(--mono);font-weight:600;color:'+(cls==='bad'?'var(--fail)':cls==='warn'?'var(--flaky-ink)':cls==='exp'?'var(--ink-2)':'var(--pass)'),title:cls==='exp'?'The test passed: this is the response it expected':''},st||'—'), cls==='exp'?h('span',{class:'sc-exp'},'expected'):null), h('td',{class:'t'},c.duration!=null?ms(c.duration):'—'), h('td',{class:'t',title:t.title},t.title, data.projects.length>1?h('span',{class:'api-proj'},' · '+t.project):null)); })))));
|
|
906
925
|
}
|
|
907
926
|
function timelineView(){
|
|
908
927
|
const W=data.options.widgets, cards=[];
|
|
@@ -918,8 +937,9 @@ function graphsView(){
|
|
|
918
937
|
return h('div',{class:'view-pad'},
|
|
919
938
|
h('div',{class:'grid graphs-grid'},
|
|
920
939
|
chartCard('outcomes-by-priority', 'Outcomes by priority', 'Stacked pass / fail / flaky / skipped for each priority tier.', chartPriorityOutcome),
|
|
940
|
+
data.projects.length>1? chartCard('outcomes-by-project', 'Outcomes by project', 'Pass / fail / flaky / skipped and the pass rate for each project (browser, device).', chartProjectOutcome) : null,
|
|
921
941
|
chartCard('failure-categories', 'Failure categories', 'What kinds of failures are hurting the suite.', chartFailureCategories),
|
|
922
|
-
chartCard('duration-distribution','Duration distribution', 'How
|
|
942
|
+
chartCard('duration-distribution','Duration distribution', 'How the durations of the tests that ran are spread.', chartDurationHistogram),
|
|
923
943
|
chartCard('trend-by-priority', 'Pass rate trend by priority', 'How each priority tier trends over the last runs.', chartTrendByPriority),
|
|
924
944
|
chartCard('owner-leaderboard', 'Owner leaderboard', 'Failures and flakes ranked by owner. Add meta({owner:...}) to see this.', chartOwnerLeaderboard),
|
|
925
945
|
));
|
|
@@ -974,6 +994,29 @@ function chartCard(id, title, sub, chartFn){
|
|
|
974
994
|
}
|
|
975
995
|
|
|
976
996
|
/* Chart 1: horizontal stacked bar per priority (P0..P4 in order, plus 'no priority') */
|
|
997
|
+
/* Chart 1b: the same stacked bars per Playwright project (chromium, firefox, Microsoft Edge...), with each
|
|
998
|
+
project's pass rate, so a browser that fails more than the others stands out. */
|
|
999
|
+
function chartProjectOutcome(){
|
|
1000
|
+
if(data.projects.length<2) return null;
|
|
1001
|
+
const outs=['passed','flaky','failed','timedOut','interrupted','skipped'];
|
|
1002
|
+
const colors={passed:'var(--pass)', flaky:'var(--flaky)', failed:'var(--fail)', timedOut:'var(--fail)', interrupted:'var(--fail)', skipped:'var(--skip)'};
|
|
1003
|
+
const rows=data.projects.map(p=>{ const m={}; for(const o of outs) m[o]=0; for(const t of data.tests) if(t.project===p) m[t.outcome]=(m[t.outcome]||0)+1; return {p,m}; }).filter(r=>outs.some(o=>r.m[o]));
|
|
1004
|
+
if(!rows.length) return null;
|
|
1005
|
+
const tot=r=>outs.reduce((a,o)=>a+r.m[o],0), maxN=Math.max(...rows.map(tot));
|
|
1006
|
+
const longest=Math.max(...rows.map(r=>r.p.length));
|
|
1007
|
+
const W=520, rowH=28, gap=10, labW=Math.min(170,Math.max(70,longest*7+10)), barW=W-labW-96;
|
|
1008
|
+
const H=rows.length*(rowH+gap)+30;
|
|
1009
|
+
const parts=rows.map((r,i)=>{
|
|
1010
|
+
const y=i*(rowH+gap)+18, n=tot(r), ran=n-r.m.skipped, rate=ran?Math.round(r.m.passed/ran*100):null, scale=barW/maxN;
|
|
1011
|
+
let x=labW; const segs=[];
|
|
1012
|
+
for(const o of outs){ const w=r.m[o]*scale; if(w<=0) continue; segs.push('<rect x="'+x+'" y="'+y+'" width="'+w+'" height="'+rowH+'" fill="'+colors[o]+'" data-outcome="'+o+'"><title>'+gEsc(r.p)+' · '+label[o]+' '+r.m[o]+'</title></rect>'); x+=w; }
|
|
1013
|
+
return '<text x="0" y="'+(y+rowH/2+4)+'" fill="var(--ink)" font-size="12" font-weight="600">'+gEsc(r.p)+'</text>'+segs.join('')+
|
|
1014
|
+
'<text x="'+(labW+barW+8)+'" y="'+(y+rowH/2+4)+'" fill="var(--ink-2)" font-size="12" font-variant-numeric="tabular-nums">'+n+(rate==null?'':' · <tspan fill="'+(rate===100?'var(--pass)':r.m.failed+r.m.timedOut+r.m.interrupted?'var(--fail)':'var(--ink-2)')+'" font-weight="600">'+rate+'%</tspan>')+'</text>';
|
|
1015
|
+
}).join('');
|
|
1016
|
+
const legend=outs.filter(o=>rows.some(r=>r.m[o]>0)).map(o=>'<rect width="10" height="10" fill="'+colors[o]+'"/><text x="14" y="9" fill="var(--ink-2)" font-size="11">'+label[o]+'</text>');
|
|
1017
|
+
const legendSvg='<g transform="translate('+labW+','+(H-2)+')">'+legend.map((g,i)=>'<g transform="translate('+(i*90)+',0)">'+g+'</g>').join('')+'</g>';
|
|
1018
|
+
return h('div',{class:'gchart-body',html:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '+W+' '+(H+18)+'" width="100%">'+parts+legendSvg+'</svg>'});
|
|
1019
|
+
}
|
|
977
1020
|
function chartPriorityOutcome(){
|
|
978
1021
|
const order = ['P0','P1','P2','P3','P4'];
|
|
979
1022
|
const outs = ['passed','flaky','failed','timedOut','interrupted','skipped'];
|
|
@@ -1028,7 +1071,7 @@ function chartDurationHistogram(){
|
|
|
1028
1071
|
{label:'30s+', min:30000,max:Infinity},
|
|
1029
1072
|
];
|
|
1030
1073
|
const counts = buckets.map(()=>0);
|
|
1031
|
-
for(const t of data.tests){ const d=t.duration||0; for(let i=0;i<buckets.length;i++){ if(d>=buckets[i].min && d<buckets[i].max){ counts[i]++; break; } } }
|
|
1074
|
+
for(const t of data.tests){ if(t.outcome==='skipped') continue; const d=t.duration||0; for(let i=0;i<buckets.length;i++){ if(d>=buckets[i].min && d<buckets[i].max){ counts[i]++; break; } } }
|
|
1032
1075
|
const maxN = Math.max(1,...counts);
|
|
1033
1076
|
const W=520, colW=80, gap=16, padL=32, padT=24, padB=36, chartH=180;
|
|
1034
1077
|
const H = chartH+padT+padB;
|
|
@@ -1043,7 +1086,7 @@ function chartDurationHistogram(){
|
|
|
1043
1086
|
|
|
1044
1087
|
/* Chart 4: multi-line — pass rate per priority over the last N history entries */
|
|
1045
1088
|
function chartTrendByPriority(){
|
|
1046
|
-
const hist =
|
|
1089
|
+
const hist = TREND;
|
|
1047
1090
|
if(hist.length < 2) return null;
|
|
1048
1091
|
const orders = ['P0','P1','P2','P3','P4'];
|
|
1049
1092
|
const seenPri = new Set();
|
|
@@ -1195,12 +1238,12 @@ function summary(){
|
|
|
1195
1238
|
const hasFail=data.tests.some(t=>isFail(t.outcome)||t.outcome==='flaky');
|
|
1196
1239
|
if(W.attention && hasFail) g.push(h('div',{class:'card w6 fail-rail'}, h('h2',{},'Needs attention', h('span',{class:'hint'},(failed+s.flaky)+' open · ranked by priority and severity')), attention(8)));
|
|
1197
1240
|
const clusters=failureClusters(); if(clusters.length) g.push(h('div',{class:'card w6 fail-rail'}, h('h2',{},'Failure clusters', h('span',{class:'hint'},clusters.length+' root cause'+(clusters.length>1?'s':'')+' · '+clusters.reduce((a,c)=>a+c.tests.length,0)+' failures')), clustersView(clusters.slice(0,6)), clusters.length>6?h('div',{class:'attn-foot'}, h('button',{onclick:()=>showView('failures')},'View all '+clusters.length+' clusters →')):null));
|
|
1198
|
-
if(W.dimensions) g.push(h('div',{class:'card w8'}, h('h2',{},'Breakdown', h('span',{class:'hint'},'click a row to filter')), breakdown()));
|
|
1241
|
+
if(W.dimensions) g.push(h('div',{class:'card w8 bd-card'}, h('h2',{},'Breakdown', h('span',{class:'hint'},'click a row to filter')), breakdown()));
|
|
1199
1242
|
if(W.slowest){ const reg=regressions().length; g.push(h('div',{class:'card'}, h('h2',{},'Slowest tests', reg?h('span',{class:'hint badge'},reg+' got slower'):null), tabbed([['slow','Slowest',slowest],['reg','Got slower'+(reg?' ('+reg+')':''),slowerView]]))); }
|
|
1200
1243
|
if(W.flaky!==false && HRUNS.length>1) g.push(h('div',{class:'card'}, h('h2',{},'Flakiest tests', h('span',{class:'hint'},'last '+Math.min(10,HRUNS.length)+' runs')), flakiest()));
|
|
1201
1244
|
if(W.skipped!==false) { const sc=skippedCard(); if(sc) g.push(sc); }
|
|
1202
1245
|
if(W.environment!==false) { const ec=envCard(); if(ec) g.push(ec); }
|
|
1203
|
-
if(data.history.length>1) g.push(h('div',{class:'card w12'}, h('h2',{},'Trend', h('span',{class:'hint'},'last '+
|
|
1246
|
+
if(data.history.length>1) g.push(h('div',{class:'card w12'}, h('h2',{},'Trend', h('span',{class:'hint'},'last '+TREND.length+' runs'+(SMALL_HIDDEN?' · '+SMALL_HIDDEN+' small run'+(SMALL_HIDDEN>1?'s':'')+' (under '+Math.ceil(MED_SIZE/2)+' tests) not plotted':''))), trend()));
|
|
1204
1247
|
else if(data.history.length===1) g.push(h('div',{class:'card w12'}, h('h2',{},'Trend', h('span',{class:'hint'},'from the second run')), h('div',{class:'nudge'}, h('b',{},'First run recorded.'),' Run the suite once more and this card shows the pass-rate trend, and every failure gets "new this run" or "failing since #…", last-10-runs dots, a Flakiest tests card and a Got slower tab. History lives in ',h('code',{},data.historyFile||'reporting-labs.history.json'),', commit it or cache it in CI.')));
|
|
1205
1248
|
const ge=data.globalErrors||[], go=data.globalOutput||[];
|
|
1206
1249
|
if(ge.length||go.some(x=>x.stream==='err')) g.unshift(h('div',{class:'card w12 fail-rail'}, h('h2',{}, ge.length? ge.length+' error'+(ge.length>1?'s':'')+' outside tests' : 'Output outside tests', h('span',{class:'hint'},'spec files that failed to load, global setup, worker crashes')),
|
|
@@ -1214,10 +1257,15 @@ function pill(key,text,n,color,sub,tone,series){
|
|
|
1214
1257
|
series? spark(series,color) : null, h('div',{class:'l'},text), h('div',{class:'v'},n), h('div',{class:'d '+(tone||'')},sub||''));
|
|
1215
1258
|
}
|
|
1216
1259
|
function initials(name){ return (name||'').split(/[\s\-–—·]+/).filter(Boolean).slice(0,2).map(w=>w[0]).join('').toUpperCase()||'R'; }
|
|
1260
|
+
/* The run this one is compared with: the latest earlier run of a comparable size (a full run is not compared
|
|
1261
|
+
with a one-spec debug run, nor a debug run with the full suite); with a build label, a different build. */
|
|
1217
1262
|
function prevRun(){
|
|
1218
1263
|
const H=data.history||[]; if(H.length<2) return null;
|
|
1219
|
-
const cur=H[H.length-1]
|
|
1220
|
-
|
|
1264
|
+
const cur=H[H.length-1], n=cur.total||0;
|
|
1265
|
+
const comparable=e=> isSmallRun(cur) ? (e.total||0)>=n/2 && (e.total||0)<=n*2 : !isSmallRun(e);
|
|
1266
|
+
let fallback=null;
|
|
1267
|
+
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]; }
|
|
1268
|
+
return fallback;
|
|
1221
1269
|
}
|
|
1222
1270
|
|
|
1223
1271
|
/* ---------- run history per test ---------- */
|
|
@@ -1265,7 +1313,7 @@ function slowerView(){
|
|
|
1265
1313
|
const rows=regressions().slice(0,6);
|
|
1266
1314
|
if(!rows.length) return h('div',{class:'ok'},'No test got 2× slower than last run.');
|
|
1267
1315
|
return h('ul',{class:'slow'}, rows.map(({t,prev,cur,ratio})=>h('li',{}, h('button',{onclick:()=>select(t.id)},
|
|
1268
|
-
h('span',{}, h('span',{class:'t'},t.title), h('span',{class:'bar',style:'--w:'+Math.min(100,Math.round(prev/cur*100))+'%'}, h('i',{style:'background:var(--flaky)'}))),
|
|
1316
|
+
h('span',{}, h('span',{class:'t'},t.title, data.projects.length>1?h('small',{class:'proj-sfx'},' · '+t.project):null), h('span',{class:'bar',style:'--w:'+Math.min(100,Math.round(prev/cur*100))+'%'}, h('i',{style:'background:var(--flaky)'}))),
|
|
1269
1317
|
h('span',{class:'d'}, h('b',{style:'color:var(--fail)'},'×'+(ratio>=10?Math.round(ratio):ratio.toFixed(1))), ' ', ms(prev)+' → '+ms(cur))))));
|
|
1270
1318
|
}
|
|
1271
1319
|
/* sparklines from the whole history (counts, no per-test data needed) */
|
|
@@ -1276,7 +1324,7 @@ function spark(series, color, w, h2){
|
|
|
1276
1324
|
const pts=series.map((v,i)=>x(i)+','+y(v)).join(' ');
|
|
1277
1325
|
return h('span',{class:'sp','aria-hidden':'true',html:'<svg viewBox="0 0 '+w+' '+h2+'" width="'+w+'" height="'+h2+'"><polyline points="'+pts+'" fill="none" stroke="'+color+'" stroke-width="1.5" stroke-linejoin="round" stroke-linecap="round" opacity=".9"/><circle cx="'+x(n-1)+'" cy="'+y(series[n-1])+'" r="2.2" fill="'+color+'"/></svg>'});
|
|
1278
1326
|
}
|
|
1279
|
-
function hseries(f){ return
|
|
1327
|
+
function hseries(f){ return TREND.slice(-12).map(f); }
|
|
1280
1328
|
/* owner rollup for the Failures view and the copied summary */
|
|
1281
1329
|
function byOwner(){
|
|
1282
1330
|
const m=new Map();
|
|
@@ -1414,13 +1462,28 @@ function donut(){
|
|
|
1414
1462
|
const svg=h('div',{html:'<svg viewBox="0 0 132 132">'+arcs+'<text class="c" x="66" y="64" text-anchor="middle">'+rate+'%</text><text class="cl" x="66" y="80" text-anchor="middle">pass rate</text></svg>'}).firstChild;
|
|
1415
1463
|
return h('div',{class:'donut'}, svg, h('div',{class:'legend'}, parts.map(([k,n])=>h('button',{onclick:()=>{state.status=k;refresh();showView('tests');}}, h('span',{class:'dot',style:'background:'+colorOf(k)}), h('span',{},label[k]), h('span',{class:'n'},n)))));
|
|
1416
1464
|
}
|
|
1465
|
+
/* Cross-project signal. The same test (file, describe path, title) runs once per project — a browser, a
|
|
1466
|
+
device. Failing in every project it ran in points at the app or the test itself; failing in some projects
|
|
1467
|
+
only points at those browsers. Skipped runs do not count; a flaky pass counts as a pass. */
|
|
1468
|
+
var XP=null; // var: the views are built before this line runs
|
|
1469
|
+
function xpKey(t){ return t.file+'::'+t.path.join('/')+'::'+t.title; }
|
|
1470
|
+
function xproj(t){
|
|
1471
|
+
if(data.projects.length<2) return null;
|
|
1472
|
+
if(!XP){ XP=new Map(); for(const u of data.tests){ if(u.outcome==='skipped') continue; const g=XP.get(xpKey(u))||[]; g.push(u); XP.set(xpKey(u),g); } }
|
|
1473
|
+
const g=XP.get(xpKey(t))||[]; if(g.length<2) return null;
|
|
1474
|
+
const bad=g.filter(u=>isFail(u.outcome)); if(!bad.length) return null;
|
|
1475
|
+
if(bad.length===g.length) return {all:true, text:g.length===2?'fails on both projects':'fails on all '+g.length+' projects', tip:'The same failure in every project it ran in: look at the app or the test, not the browser'};
|
|
1476
|
+
const names=bad.map(u=>u.project), good=g.filter(u=>!isFail(u.outcome)).map(u=>u.project);
|
|
1477
|
+
return {all:false, text: names.length<=2? 'only on '+names.join(' and ') : 'on '+names.length+' of '+g.length+' projects', tip:'Passes on '+good.join(', ')+': specific to '+names.join(', ')};
|
|
1478
|
+
}
|
|
1479
|
+
function xpTag(xp,cls){ return h('span',{class:'xp '+(xp.all?'all':'some')+(cls?' '+cls:''),title:xp.tip},xp.text); }
|
|
1417
1480
|
function attention(limit){
|
|
1418
1481
|
const bad=data.tests.filter(t=>isFail(t.outcome)||t.outcome==='flaky').sort((a,b)=>rank(a)-rank(b)||(isFail(b.outcome)-isFail(a.outcome))||b.duration-a.duration);
|
|
1419
1482
|
if(!bad.length) return h('div',{class:'ok'},'No failures. Ship it.');
|
|
1420
1483
|
const groups=new Map(); for(const t of bad){ const k=t.file+'::'+t.path.join('/')+'::'+t.title; const g=groups.get(k)||{t,projects:[]}; g.projects.push(t.project); groups.set(k,g); }
|
|
1421
1484
|
const all=[...groups.values()], rows=limit?all.slice(0,limit):all;
|
|
1422
1485
|
const sub=(t,projects)=>{ const parts=[t.file.split('/').pop()];
|
|
1423
|
-
if(data.projects.length>1) parts.push(projects.length>1? projects.length+' projects' : projects[0]);
|
|
1486
|
+
if(data.projects.length>1){ const xp=xproj(t); parts.push(xp? xpTag(xp) : projects.length>1? projects.length+' projects' : projects[0]); }
|
|
1424
1487
|
const si=sinceInfo(t); if(si) parts.push(si.kind==='new'? h('b',{class:'new'},'new this run') : 'failing since '+runLabel(si.since));
|
|
1425
1488
|
const le=t.results[t.results.length-1]&&t.results[t.results.length-1].errors[0]; if(le&&le.explain) parts.push(h('span',{class:'rsn',title:le.explain.summary},le.explain.label));
|
|
1426
1489
|
else if(t.outcome==='flaky') parts.push('passed on retry '+t.results.length);
|
|
@@ -1504,7 +1567,7 @@ function clusterLine(c){
|
|
|
1504
1567
|
// in place and "show fewer" folds it again. Each name opens that test.
|
|
1505
1568
|
function clusterWho(byTitle, all){
|
|
1506
1569
|
const entries=[...byTitle.entries()], names=all?entries:entries.slice(0,6), extra=entries.length-names.length;
|
|
1507
|
-
const who=names.map(([title,ts])=>h('button',{onclick:()=>select(ts[0].id),title:ts.map(t=>t.project).join(', ')}, h('span',{class:'tri'},'›'), title, data.projects.length>1&&ts.length>1? h('small',{},' ×'+ts.length) : null));
|
|
1570
|
+
const who=names.map(([title,ts])=>h('button',{onclick:()=>select(ts[0].id),title:ts.map(t=>t.project).join(', ')}, h('span',{class:'tri'},'›'), title, data.projects.length>1&&ts.length>1? h('small',{},' ×'+ts.length) : null, (()=>{ const xp=xproj(ts[0]); return xp? h('small',{class:'xp '+(xp.all?'all':'some'),title:xp.tip},' · '+xp.text) : null; })()));
|
|
1508
1571
|
const swap=(ev,toAll)=>{ const d=ev.currentTarget.closest('.who'); d.replaceChildren(); for(const n of clusterWho(byTitle,toAll)) d.append(n); };
|
|
1509
1572
|
if(extra>0) who.push(h('button',{class:'ex',onclick:ev=>swap(ev,true),title:'Show all '+entries.length+' tests'},'+'+extra+' more'));
|
|
1510
1573
|
else if(all&&entries.length>6) who.push(h('button',{class:'ex',onclick:ev=>swap(ev,false)},'show fewer'));
|
|
@@ -1518,7 +1581,7 @@ function clustersView(cl){
|
|
|
1518
1581
|
}));
|
|
1519
1582
|
}
|
|
1520
1583
|
function trend(){
|
|
1521
|
-
const H=
|
|
1584
|
+
const H=TREND, W=760, HT=170, padL=34, padR=12, padT=12, padB=26, n=H.length;
|
|
1522
1585
|
const x=i=>padL+(n===1?0:i/(n-1))*(W-padL-padR), y=v=>padT+(1-v/100)*(HT-padT-padB);
|
|
1523
1586
|
const rate=e=>{ const ran=e.total-e.skipped; return ran?Math.round(e.passed/ran*100):0; };
|
|
1524
1587
|
const failPct=e=>{ const ran=e.total-e.skipped; return ran?Math.round(e.failed/ran*100):0; };
|
|
@@ -1528,9 +1591,14 @@ function trend(){
|
|
|
1528
1591
|
svg+='<path class="area" d="M'+x(0)+','+y(0)+' '+H.map((e,i)=>'L'+x(i)+','+y(rate(e))).join(' ')+' L'+x(n-1)+','+y(0)+' Z"/>';
|
|
1529
1592
|
svg+='<polyline class="fail" points="'+H.map((e,i)=>x(i)+','+y(failPct(e))).join(' ')+'"/>';
|
|
1530
1593
|
svg+='<polyline class="pass" points="'+H.map((e,i)=>x(i)+','+y(rate(e))).join(' ')+'"/>';
|
|
1531
|
-
svg+=H.map((e,i)=>'<circle class="pt'+(i===n-1?' now':'')+'" cx="'+x(i)+'" cy="'+y(rate(e))+'" r="3.5"><title>'+new Date(e.time).toLocaleString()+(e.label?' · '+e.label:'')+' · '+rate(e)+'% pass · '+e.failed+' failed · '+ms(e.duration)+'</title></circle>').join('');
|
|
1532
|
-
|
|
1533
|
-
|
|
1594
|
+
svg+=H.map((e,i)=>'<circle class="pt'+(i===n-1&&e===HIST[HIST.length-1]?' now':'')+'" cx="'+x(i)+'" cy="'+y(rate(e))+'" r="3.5"><title>'+new Date(e.time).toLocaleString()+(e.label?' · '+e.label:'')+' · '+rate(e)+'% pass · '+e.failed+' failed · '+ms(e.duration)+'</title></circle>').join('');
|
|
1595
|
+
// Several runs on one day get the time too; longer labels mean fewer of them, so they never overlap
|
|
1596
|
+
const day=e=>new Date(e.time).toLocaleDateString(undefined,{month:'short',day:'numeric'});
|
|
1597
|
+
const days=H.filter(e=>!e.label).map(day), twice=days.length!==new Set(days).size;
|
|
1598
|
+
const step=Math.max(1,Math.ceil(n/(twice?5:8)));
|
|
1599
|
+
const shown=H.map((e,i)=>i===n-1||(i%step===0&&n-1-i>=step));
|
|
1600
|
+
const axis=e=> e.label || (twice ? day(e)+' '+new Date(e.time).toLocaleTimeString(undefined,{hour:'numeric',minute:'2-digit'}) : day(e));
|
|
1601
|
+
svg+=H.map((e,i)=>shown[i]?'<text x="'+x(i)+'" y="'+(HT-6)+'" text-anchor="'+(i===n-1&&n>1?'end':i===0&&twice?'start':'middle')+'">'+escape(axis(e))+'</text>':'').join('');
|
|
1534
1602
|
const colW=n>1?(x(1)-x(0)):(W-padL-padR);
|
|
1535
1603
|
svg+='<line class="guide" x1="0" x2="0" y1="'+padT+'" y2="'+y(0)+'" style="display:none"/>';
|
|
1536
1604
|
svg+=H.map((e,i)=>'<rect class="hit" data-i="'+i+'" x="'+(x(i)-colW/2)+'" y="0" width="'+colW+'" height="'+HT+'" fill="transparent"/>').join('');
|
|
@@ -1555,7 +1623,7 @@ function trend(){
|
|
|
1555
1623
|
svgEl.addEventListener('mousemove',ev=>{ const r=ev.target.closest&&ev.target.closest('.hit'); if(!r){ tip.hidden=true; guide.style.display='none'; return; } show(+r.dataset.i,ev); });
|
|
1556
1624
|
svgEl.addEventListener('mouseleave',()=>{ tip.hidden=true; guide.style.display='none'; });
|
|
1557
1625
|
wrap.append(
|
|
1558
|
-
h('div',{class:'trend-cap'}, h('span',{style:'color:var(--pass)'},'— pass rate'), h('span',{style:'color:var(--fail)'},'- - fail rate'), h('span',{style:'color:var(--accent)'},'▮ duration'), h('span',{style:'margin-left:auto'}, 'this run: '+rate(
|
|
1626
|
+
h('div',{class:'trend-cap'}, h('span',{style:'color:var(--pass)'},'— pass rate'), h('span',{style:'color:var(--fail)'},'- - fail rate'), h('span',{style:'color:var(--accent)'},'▮ duration'), h('span',{style:'margin-left:auto'}, 'this run: '+rate(HIST[HIST.length-1])+'% · '+ms(HIST[HIST.length-1].duration)+(isSmallRun(HIST[HIST.length-1])?' · small run, not plotted':''))));
|
|
1559
1627
|
return wrap;
|
|
1560
1628
|
}
|
|
1561
1629
|
function workers(){
|
|
@@ -1594,7 +1662,7 @@ function slowest(){
|
|
|
1594
1662
|
const top=[...data.tests].filter(t=>t.outcome!=='skipped').sort((a,b)=>b.duration-a.duration).slice(0,5);
|
|
1595
1663
|
const max=top[0]?top[0].duration:1;
|
|
1596
1664
|
return h('ul',{class:'slow'}, top.map(t=>h('li',{}, h('button',{onclick:()=>select(t.id)},
|
|
1597
|
-
h('span',{}, h('span',{class:'t'},t.title), h('span',{class:'bar',style:'--w:'+Math.max(4,Math.round(t.duration/max*100))+'%'}, h('i',{}))), h('span',{class:'d'},ms(t.duration))))));
|
|
1665
|
+
h('span',{}, h('span',{class:'t'},t.title, data.projects.length>1?h('small',{class:'proj-sfx'},' · '+t.project):null), h('span',{class:'bar',style:'--w:'+Math.max(4,Math.round(t.duration/max*100))+'%'}, h('i',{}))), h('span',{class:'d'},ms(t.duration))))));
|
|
1598
1666
|
}
|
|
1599
1667
|
function projects(){
|
|
1600
1668
|
return h('div',{class:'proj'}, data.projects.map(p=>{
|
|
@@ -1698,7 +1766,7 @@ function renderDetail(t, d, retryIdx){
|
|
|
1698
1766
|
h('button',{class:'btn',onclick:e=>copyText(location.href.split('#')[0]+'#t='+t.id,e.currentTarget,'Link copied')},'Copy link'),
|
|
1699
1767
|
(()=>{ const r=t.results[t.results.length-1]; const e=r&&r.errors[0]; return e? [h('button',{class:'btn',onclick:ev=>copyText(t.title+'\n'+t.file+':'+t.line+'\n\n'+e.message,ev.currentTarget,'Error copied')},'Copy error'), h('button',{class:'btn primary',onclick:()=>openBugReport(t)},'Bug report')] : null; })(),
|
|
1700
1768
|
editorLink(t))),
|
|
1701
|
-
h('div',{class:'badges'}, h('span',{class:'badge '+t.outcome},label[t.outcome]), t.expectedFailure? h('span',{class:'badge xfail',title:'Marked test.fail(): failing is the expected result'},'Expected failure') : null, sinceBadge(t), dots(t,10), data.bdd?h('span',{class:'badge scenario'},'Scenario'):null, t.tags.map(g=>h('span',{class:'badge tag'},g)), data.projects.length>1?h('span',{class:'badge tag'},t.project):null, h('span',{class:'loc'}, t.file+':'+t.line+' · '+ms(t.duration)+(t.outcome==='timedOut'&&t.timeout?' · timeout '+ms(t.timeout):'')+(t.retries?' · retries '+t.retries:''))));
|
|
1769
|
+
h('div',{class:'badges'}, h('span',{class:'badge '+t.outcome},label[t.outcome]), t.expectedFailure? h('span',{class:'badge xfail',title:'Marked test.fail(): failing is the expected result'},'Expected failure') : null, sinceBadge(t), dots(t,10), data.bdd?h('span',{class:'badge scenario'},'Scenario'):null, t.tags.map(g=>h('span',{class:'badge tag'},g)), data.projects.length>1?h('span',{class:'badge tag'},t.project):null, (()=>{ const xp=isFail(t.outcome)&&xproj(t); return xp? xpTag(xp,'badge') : null; })(), h('span',{class:'loc'}, t.file+':'+t.line+' · '+ms(t.duration)+(t.outcome==='timedOut'&&t.timeout?' · timeout '+ms(t.timeout):'')+(t.retries?' · retries '+t.retries:''))));
|
|
1702
1770
|
const metaKeys=Object.keys(t.meta);
|
|
1703
1771
|
const linkFor=(k,v)=>{ if(t.links&&t.links[k]) return t.links[k]; const tpl=data.options.links[k]||data.options.links['*']; if(tpl) return tpl.replace('{id}',encodeURIComponent(v)); if(/^https?:\/\//.test(v)) return v; return null; };
|
|
1704
1772
|
if(metaKeys.length) d.append(h('div',{class:'metas'}, metaKeys.map(k=>{ const v=t.meta[k], low=/^(P[3-4]|low|minor|trivial|normal|medium)$/i.test(v); const parts=(t.links&&t.links[k])||!data.options.links[k]&&!data.options.links['*']?[v]:v.split(/,\s+/); const nodes=[]; parts.forEach((part,i)=>{ const href=linkFor(k,part); if(i) nodes.push(', '); nodes.push(href? h('a',{href,target:'_blank',rel:'noopener'},part) : h('span',{class:'v'},part)); }); return h('span',{class:'meta '+k+(low?' low':'')}, h('span',{class:'k'},k), ...nodes); })));
|
|
@@ -1714,7 +1782,7 @@ function renderDetail(t, d, retryIdx){
|
|
|
1714
1782
|
if(r.steps.length){ const stepTotal=Math.max(1, r.duration||0, r.steps.reduce((a,x)=>a+x.duration,0)); body.append(h('h4',{},data.bdd?'Scenario steps':'Steps', h('span',{class:'hint'},'bar = share of '+ms(stepTotal))), stepTree(r.steps, stepTotal)); }
|
|
1715
1783
|
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))))); }
|
|
1716
1784
|
for(const b of r.data){ body.append(h('h4',{},b.name), dataBlock(b)); }
|
|
1717
|
-
if(r.api.length){ body.append(h('h4',{},r.api.length+' API call'+(r.api.length>1?'s':'')), ...r.api.map(apiPanel)); body.append(h('div',{class:'mask-note'},'Secrets and auth headers are masked as ****')); }
|
|
1785
|
+
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 ****')); }
|
|
1718
1786
|
const imgs=r.attachments.filter(a=>a.src&&a.contentType.startsWith('image/'));
|
|
1719
1787
|
const vids=r.attachments.filter(a=>a.src&&a.contentType.startsWith('video/'));
|
|
1720
1788
|
const traces=r.attachments.filter(a=>a.src&&(a.name==='trace'||/\.zip$/.test(a.src)));
|
|
@@ -1759,10 +1827,10 @@ function dataBlock(b){
|
|
|
1759
1827
|
if(b.kind==='kv') return h('dl',{class:'kv2'}, b.kv.map(([k,v])=>[h('dt',{},k),h('dd',{class:v==='****'?'mask':''},v)]));
|
|
1760
1828
|
return h('pre',{class:'txt'},b.text);
|
|
1761
1829
|
}
|
|
1762
|
-
function apiPanel(c){
|
|
1763
|
-
const st=c.status||0, cls=
|
|
1830
|
+
function apiPanel(c,r){
|
|
1831
|
+
const st=c.status||0, cls=apiCls(c,r);
|
|
1764
1832
|
const wrap=h('div',{class:'api collapsed'});
|
|
1765
|
-
const head=h('button',{class:'api-head',onclick:()=>wrap.classList.toggle('collapsed')}, h('span',{class:'m '+c.method.toUpperCase()},c.method.toUpperCase()), h('span',{class:'u',title:c.url},c.url), st?h('span',{class:'sc '+cls},st):null, c.duration!=null?h('span',{class:'d'},ms(c.duration)):null);
|
|
1833
|
+
const head=h('button',{class:'api-head',onclick:()=>wrap.classList.toggle('collapsed')}, h('span',{class:'m '+c.method.toUpperCase()},c.method.toUpperCase()), h('span',{class:'u',title:c.url},c.url), st?h('span',{class:'sc '+cls,title:cls==='exp'?'The test passed: this is the response it expected':''},st):null, cls==='exp'?h('span',{class:'sc-exp'},'expected'):null, c.duration!=null?h('span',{class:'d'},ms(c.duration)):null);
|
|
1766
1834
|
const pre=v=>v==null?null:h('pre',{}, typeof v==='string'?v:JSON.stringify(v,null,2));
|
|
1767
1835
|
const col=(title,headers,bodyv)=>h('div',{class:'api-col'}, h('h5',{},title), headers&&Object.keys(headers).length? [h('h5',{},'Headers'), pre(headers)] : null, bodyv!=null? [h('h5',{},'Body'), pre(bodyv)] : h('div',{style:'font-size:12px;color:var(--ink-3)'},'no body'));
|
|
1768
1836
|
const tools=h('div',{class:'api-tools'}, h('button',{class:'btn',onclick:e=>copyText(curlOf(c),e.currentTarget,'Copied')},'Copy as cURL'), h('button',{class:'btn',onclick:e=>copyText(c.url,e.currentTarget,'Copied')},'Copy URL'));
|
package/dist/types.d.ts
CHANGED
|
@@ -19,11 +19,17 @@ export interface ReportingLabsOptions {
|
|
|
19
19
|
jsonFile?: string;
|
|
20
20
|
/** Also write a print-ready `report.pdf` next to the HTML, rendered by headless Chromium from the
|
|
21
21
|
* report's own PDF layout (executive summary, charts, failure analysis, the full test-case table and
|
|
22
|
-
* screenshots of failures).
|
|
23
|
-
*
|
|
22
|
+
* screenshots of failures). Printed by the Chromium that Playwright provides, else by an installed
|
|
23
|
+
* Chrome, Edge or Chromium, whichever browser the tests ran on (Firefox and WebKit runs included). Default: true — set `false` to skip,
|
|
24
|
+
* `{ file }` to rename, `{ chromePath }` to name the browser (or set CHROME_PATH). The report also has
|
|
25
|
+
* an "Export PDF" button. */
|
|
24
26
|
pdf?: boolean | {
|
|
25
27
|
file?: string;
|
|
28
|
+
chromePath?: string;
|
|
26
29
|
};
|
|
30
|
+
/** Read meta from a comment right above a test or describe: `/** @owner naveen @priority P0 *\/`. `@key value`
|
|
31
|
+
* pairs become meta, a bare `@word` a tag; meta() in the test wins. Default: true */
|
|
32
|
+
commentMeta?: boolean;
|
|
27
33
|
/** Inline screenshots as base64 (single file, opens anywhere). Default: true */
|
|
28
34
|
embedAttachments?: boolean;
|
|
29
35
|
/** Max size (bytes) of a single attachment to embed. Larger ones are copied as files. Default: 2 MB */
|
package/dist/wdio/finalize.d.ts
CHANGED
package/dist/wdio/finalize.js
CHANGED
|
@@ -48,6 +48,7 @@ const fs = __importStar(require("fs"));
|
|
|
48
48
|
const path = __importStar(require("path"));
|
|
49
49
|
const template_1 = require("../template");
|
|
50
50
|
const mask_1 = require("../mask");
|
|
51
|
+
const pdf_1 = require("../pdf");
|
|
51
52
|
const env_1 = require("./env");
|
|
52
53
|
async function reportingLabsComplete(options = {}) {
|
|
53
54
|
const outputFolder = options.outputFolder || 'reporting-labs';
|
|
@@ -176,28 +177,13 @@ async function reportingLabsComplete(options = {}) {
|
|
|
176
177
|
console.log('');
|
|
177
178
|
return htmlFile;
|
|
178
179
|
}
|
|
179
|
-
/**
|
|
180
|
+
/** report.pdf next to the HTML; see writeReportPdf for which browser prints it (an installed Chrome or
|
|
181
|
+
* Edge when the project has no Playwright). Never fails the run. */
|
|
180
182
|
async function writePdf(htmlFile, outputFolder, options) {
|
|
181
|
-
const
|
|
182
|
-
const pdfFile = path.join(outputFolder,
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
try {
|
|
188
|
-
const page = await browser.newPage();
|
|
189
|
-
await page.goto(pathToFileURL(htmlFile).href, { waitUntil: 'load' });
|
|
190
|
-
await page.evaluate(() => window.reportingLabsPreparePrint?.());
|
|
191
|
-
await page.pdf({ path: pdfFile, printBackground: true, preferCSSPageSize: true });
|
|
192
|
-
}
|
|
193
|
-
finally {
|
|
194
|
-
await browser.close();
|
|
195
|
-
}
|
|
196
|
-
if (options.announce !== false)
|
|
197
|
-
console.log(` reporting-labs: PDF written to ${path.relative(process.cwd(), pdfFile)}`);
|
|
198
|
-
}
|
|
199
|
-
catch (e) {
|
|
200
|
-
if (options.announce !== false)
|
|
201
|
-
console.log(` reporting-labs: PDF skipped — ${String(e.message).split('\n')[0]}`);
|
|
202
|
-
}
|
|
183
|
+
const pdfOpt = typeof options.pdf === 'object' ? options.pdf : {};
|
|
184
|
+
const pdfFile = path.join(outputFolder, pdfOpt.file || 'report.pdf');
|
|
185
|
+
const r = await (0, pdf_1.writeReportPdf)(htmlFile, pdfFile, pdfOpt.chromePath);
|
|
186
|
+
if (options.announce === false)
|
|
187
|
+
return;
|
|
188
|
+
console.log(r.ok ? ` reporting-labs: PDF written to ${path.relative(process.cwd(), pdfFile)}` : ` reporting-labs: PDF skipped — ${r.reason}`);
|
|
203
189
|
}
|
package/dist/wdio/reporter.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export interface ReportingLabsWdioOptions {
|
|
|
19
19
|
maskKeys?: string[];
|
|
20
20
|
maskValues?: string[];
|
|
21
21
|
maskFromEnv?: boolean;
|
|
22
|
+
/** Read meta from a comment right above it() / describe(): `/** @owner naveen @priority P0 *\/`. Default: true */
|
|
23
|
+
commentMeta?: boolean;
|
|
22
24
|
[k: string]: unknown;
|
|
23
25
|
}
|
|
24
26
|
export default class ReportingLabsWdioReporter extends EventEmitter {
|
package/dist/wdio/reporter.js
CHANGED
|
@@ -52,6 +52,8 @@ const fs = __importStar(require("fs"));
|
|
|
52
52
|
const path = __importStar(require("path"));
|
|
53
53
|
const mask_1 = require("../mask");
|
|
54
54
|
const explain_1 = require("../explain");
|
|
55
|
+
const comments_1 = require("../comments");
|
|
56
|
+
const url_1 = require("url");
|
|
55
57
|
const META_KEYS = ['priority', 'severity', 'feature', 'owner', 'epic', 'story', 'issue', 'bug', 'component', 'module', 'team', 'sprint', 'testcase', 'tms', 'requirement'];
|
|
56
58
|
exports.META_KEYS = META_KEYS;
|
|
57
59
|
/** WebDriver command name → readable step verb. Commands not listed (reads, internals) are not steps. */
|
|
@@ -121,14 +123,43 @@ class ReportingLabsWdioReporter extends node_events_1.EventEmitter {
|
|
|
121
123
|
retry: test.retries || 0, status: 'passed', duration: 0, startTime: now, workerIndex: numericCid(this.cid),
|
|
122
124
|
errors: [], steps: [], attachments: [], stdout: [], stderr: [], logs: [], data: [], api: [],
|
|
123
125
|
};
|
|
124
|
-
const
|
|
126
|
+
const abs = srcPath(test.file || this.specs[0] || '');
|
|
127
|
+
const file = this.rel(abs);
|
|
125
128
|
const tagSource = [test.title || '', ...this.suiteStack].join(' ');
|
|
126
|
-
const tags =
|
|
129
|
+
const tags = tagSource.match(/@[A-Za-z][\w:.=-]*/g) || [];
|
|
130
|
+
// WDIO gives no line numbers: find it('title') in the spec, for the source link and the comment above it
|
|
131
|
+
// Each describe is looked up after the one around it, then the test after its own describe.
|
|
132
|
+
const at = [];
|
|
133
|
+
let from = 0;
|
|
134
|
+
for (const st of this.suiteStack) {
|
|
135
|
+
const ln = abs ? (0, comments_1.lineOfTitle)(abs, st, 'describe|context|suite', from) : 0;
|
|
136
|
+
if (ln) {
|
|
137
|
+
at.push(ln);
|
|
138
|
+
from = ln;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const line = abs ? (0, comments_1.lineOfTitle)(abs, test.title || '', 'it|test|specify', from) : 0;
|
|
142
|
+
const fromComments = {};
|
|
143
|
+
if (abs && this.options.commentMeta !== false) {
|
|
144
|
+
try {
|
|
145
|
+
for (const ln of [...at, line].filter(Boolean)) {
|
|
146
|
+
const c = (0, comments_1.commentMetaAt)(abs, ln);
|
|
147
|
+
Object.assign(fromComments, c.meta);
|
|
148
|
+
for (const g of c.tags)
|
|
149
|
+
if (!tags.includes(g) && !META_KEYS.includes(g.slice(1).toLowerCase()))
|
|
150
|
+
tags.push(g);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch { /* comments are a convenience: never fail the run over them */ }
|
|
154
|
+
}
|
|
127
155
|
const { meta } = metaFromTags(tags, META_KEYS);
|
|
156
|
+
for (const [k, v] of Object.entries(fromComments))
|
|
157
|
+
if (META_KEYS.includes(k))
|
|
158
|
+
meta[k] = this.masker.maskStr(v);
|
|
128
159
|
const t = {
|
|
129
160
|
id: test.uid || `${file}:${test.title}`,
|
|
130
161
|
key: '', title: this.masker.maskStr(test.title || ''), path: this.suiteStack.map(s => this.masker.maskStr(s)),
|
|
131
|
-
file, line
|
|
162
|
+
file, line, project: this.capsName, tags, annotations: [], meta,
|
|
132
163
|
outcome: 'passed', duration: 0, results: [result], retries: test.retries,
|
|
133
164
|
};
|
|
134
165
|
t.key = `${t.project}::${t.file}::${[...t.path, t.title].join(' › ')}`;
|
|
@@ -237,6 +268,7 @@ class ReportingLabsWdioReporter extends node_events_1.EventEmitter {
|
|
|
237
268
|
catch { /* best-effort; finalize will simply see fewer parts */ }
|
|
238
269
|
}
|
|
239
270
|
rel(file) {
|
|
271
|
+
file = srcPath(file);
|
|
240
272
|
if (!file)
|
|
241
273
|
return file;
|
|
242
274
|
try {
|
|
@@ -330,3 +362,14 @@ function metaFromTags(tags, dims) {
|
|
|
330
362
|
}
|
|
331
363
|
return { meta, clean };
|
|
332
364
|
}
|
|
365
|
+
/** A spec path WDIO may hand over as a file:// URL. */
|
|
366
|
+
function srcPath(f) {
|
|
367
|
+
if (!f.startsWith('file:'))
|
|
368
|
+
return f;
|
|
369
|
+
try {
|
|
370
|
+
return (0, url_1.fileURLToPath)(f);
|
|
371
|
+
}
|
|
372
|
+
catch {
|
|
373
|
+
return f;
|
|
374
|
+
}
|
|
375
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reporting-labs",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"description": "reportingLabs
|
|
3
|
+
"version": "0.6.13",
|
|
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",
|
|
7
7
|
"html-report",
|
|
@@ -71,6 +71,10 @@
|
|
|
71
71
|
"bugs": {
|
|
72
72
|
"url": "https://github.com/naveenautomationlabs/reporting-labs/issues"
|
|
73
73
|
},
|
|
74
|
+
"funding": {
|
|
75
|
+
"type": "individual",
|
|
76
|
+
"url": "https://reportinglabs.dev/support"
|
|
77
|
+
},
|
|
74
78
|
"engines": {
|
|
75
79
|
"node": ">=18"
|
|
76
80
|
},
|