reporting-labs 0.6.18 → 0.6.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -259,13 +259,46 @@ open reporting-labs/index.html
259
259
 
260
260
  Run it two or three times to see the history features (new vs known failures, flaky dots, got slower, trend).
261
261
 
262
+ For Cucumber feature files on Playwright, [`examples-playwright-bdd/`](https://github.com/naveenautomationlabs/reporting-labs/tree/main/examples-playwright-bdd) runs [playwright-bdd](https://github.com/vitalets/playwright-bdd) against a tiny offline shop app: `cd examples-playwright-bdd && npm install && npm test`.
263
+
262
264
  For Cypress, [`examples-cypress/`](https://github.com/naveenautomationlabs/reporting-labs/tree/main/examples-cypress) is a tiny offline shop app with a few specs (steps, API calls, a flaky test, a failing hook): `cd examples-cypress && npm install && npx cypress run`. With Cucumber: [`examples-cypress-cucumber/`](https://github.com/naveenautomationlabs/reporting-labs/tree/main/examples-cypress-cucumber), the same app with feature files.
263
265
 
266
+ ### Playwright with Cucumber (playwright-bdd)
267
+
268
+ [playwright-bdd](https://github.com/vitalets/playwright-bdd) runs `.feature` files on the Playwright test runner, so
269
+ `playwright.config.ts`, fixtures, projects, retries and sharding all stay. Add the reporter as usual; nothing else to
270
+ set up:
271
+
272
+ ```ts
273
+ // playwright.config.ts
274
+ import 'reporting-labs/auto';
275
+ import { defineConfig } from '@playwright/test';
276
+ import { defineBddConfig } from 'playwright-bdd';
277
+
278
+ const testDir = defineBddConfig({ features: 'features/**/*.feature', steps: 'steps/**/*.ts' });
279
+
280
+ export default defineConfig({
281
+ testDir,
282
+ reporter: [['list'], ['reporting-labs', { title: 'Checkout regression' }]],
283
+ });
284
+ ```
285
+
286
+ Run `npx bddgen && npx playwright test`. Each scenario is a report row:
287
+ - **At its line in the `.feature` file**, under its Feature and Rule, with a Scenario badge (not the generated `.features-gen` spec).
288
+ - **Given / When / Then steps** with the Playwright calls each one made; Background steps next to the scenario's own; the steps a failure left unrun greyed out.
289
+ - **Scenario Outline rows** named after their values, with the row as an Examples table; data tables and doc strings as test data. A password column is masked.
290
+ - **Tags:** `@P0`–`@P4` set the priority, `@blocker` / `@critical` / `@major` / `@minor` / `@trivial` the severity, `@owner:asha` / `@story:SHOP-12` / `@feature:…` any meta; anything else is a tag.
291
+ - **Errors:** the step definition line, or the step in the feature file; "Step not defined" for `Missing step`, "Step defined twice".
292
+
293
+ playwright-bdd 8 and 9 give all of it. With playwright-bdd 7 the scenario's location, Feature / Rule and Outline rows
294
+ are right; data tables and the steps left unrun need 8+.
295
+
264
296
  ## A tour of the report
265
297
 
266
298
  ### Overview: the whole run on one screen
267
299
 
268
300
  - **Tiles**: pass rate with a ring and the change from the last run, then passed / failed / flaky / skipped. Click a tile to see those tests.
301
+ - **Since last run**: one line under the tiles with what changed against the previous run: new failures, fixed, still failing, got slower, new tests. Click a number to see those tests. **Copy re-run command** on the same line copies one command for every failed test.
269
302
  - **Run strip**: every test as one small cell, in run order. Hover for the name, click to open.
270
303
  - **Needs attention**: failures sorted by priority and severity, with the spec file, the owner, and whether the failure is new or has been failing for a while.
271
304
  - **Failure clusters**: failures grouped by error message. 30 red tests with one cause read as one problem.
@@ -279,6 +312,7 @@ For Cypress, [`examples-cypress/`](https://github.com/naveenautomationlabs/repor
279
312
  ### Failures: everything you need to triage
280
313
 
281
314
  - **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.
315
+ - **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`).
282
316
  - **By owner**: who to ping, with failed and flaky counts. Click an owner to filter.
283
317
  - **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.
284
318
  - **Copy summary**: a Slack or Teams message with the top failures, owners and ticket keys.
@@ -309,6 +343,7 @@ The reporter keeps a small file, `reporting-labs.history.json`, next to your con
309
343
  | Did this break just now, or has it been red for days? | `new this run` or `failing since #1838` on every failure |
310
344
  | Which tests are flaky? | Last-10-runs dots on every failure, plus the Flakiest tests card |
311
345
  | What got slower? | Got slower tab on the Slowest card |
346
+ | What changed since the last run? | The Since last run line: new failures, fixed, still failing, got slower, new tests |
312
347
  | Are we getting better or worse? | Trend chart with pass rate, fail rate and duration per run |
313
348
 
314
349
  The first run has nothing to compare with. These cards fill in from the second run.
@@ -347,7 +382,7 @@ Every outcome Playwright can produce, not just pass and fail:
347
382
  | Single HTML file, opens without a server | ❌<br><sub>a folder, served by `show-report`</sub> | 🟡<br><sub>single-file mode (2.24+, Allure 3)</sub> | ✅ |
348
383
  | Nothing extra to install | ✅ | ❌<br><sub>Allure CLI; Allure 2 needs Java</sub> | ✅<br><sub>one package</sub> |
349
384
  | Setup | ✅<br><sub>built in</sub> | 🟡<br><sub>reporter + generate step</sub> | ✅<br><sub>one line</sub> |
350
- | Frameworks | ❌<br><sub>Playwright only</sub> | ✅<br><sub>many languages</sub> | ✅<br><sub>Playwright, Cypress (+ Cucumber), WebdriverIO, pytest, pytest-bdd, Robot, JUnit 5, TestNG, Cucumber</sub> |
385
+ | Frameworks | ❌<br><sub>Playwright only</sub> | ✅<br><sub>many languages</sub> | ✅<br><sub>Playwright (+ BDD), Cypress (+ Cucumber), WebdriverIO, pytest, pytest-bdd, Robot, JUnit 5, TestNG, Cucumber</sub> |
351
386
  | **Each test** | | | |
352
387
  | Steps, screenshots, videos, traces | ✅ | ✅ | ✅ |
353
388
  | Logs and test data | 🟡<br><sub>as attachments</sub> | 🟡<br><sub>attachments, parameters</sub> | ✅<br><sub>`log()`, `testData()`</sub> |
@@ -840,4 +875,8 @@ Full details for security reviewers and client projects, including what is read,
840
875
 
841
876
  ## License
842
877
 
843
- MIT © Naveen Automation Labs
878
+ MIT © 2026 Naveen Khunteta (Naveen Automation Labs), first released in September 2026. See [LICENSE](./LICENSE).
879
+
880
+ **Name and logo.** The code is MIT-licensed. The reportingLabs name and logo are not: forks and derived projects are welcome, but please don't use them in a way that suggests your project is reportingLabs or endorsed by it.
881
+
882
+ **Building on reportingLabs?** You're welcome to. If your project uses its code or is modelled on its report, a link back to [reportingLabs](https://github.com/naveenautomationlabs/reporting-labs) is appreciated.
package/dist/bdd.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ import type { TestData } from './types';
2
+ interface BddStep {
3
+ pwStepLine: number;
4
+ gherkinStepLine: number;
5
+ textWithKeyword: string;
6
+ isBg?: boolean;
7
+ }
8
+ interface BddTest {
9
+ pwTestLine: number;
10
+ pickleLine: number;
11
+ tags?: string[];
12
+ steps: BddStep[];
13
+ }
14
+ interface BddSpec {
15
+ uri: string;
16
+ feature: string;
17
+ tests: BddTest[]; /** playwright-bdd 7: by "describe|…|test" title */
18
+ byTitle?: Map<string, BddTest>;
19
+ }
20
+ type Masker = {
21
+ maskStr(s: string): string;
22
+ isSensitive(k: string): boolean;
23
+ learn(v: string): void;
24
+ };
25
+ /** The bdd data of a generated spec file, or null when it is not one. */
26
+ export declare function bddSpec(specFile: string, roots: string[]): BddSpec | null;
27
+ /**
28
+ * Turns a playwright-bdd test into a scenario row. `specFile` is the generated spec (absolute), `rel` makes a path
29
+ * relative the way the rest of the report does, `masker` is the report's masker.
30
+ */
31
+ export declare function applyBdd(t: TestData, specFile: string, roots: string[], rel: (f: string) => string, masker: Masker): boolean;
32
+ export {};
package/dist/bdd.js ADDED
@@ -0,0 +1,274 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.bddSpec = bddSpec;
37
+ exports.applyBdd = applyBdd;
38
+ /**
39
+ * playwright-bdd (github.com/vitalets/playwright-bdd): its tests run on the Playwright runner, so they reach the
40
+ * reporter as ordinary tests in generated spec files (.features-gen/…/x.feature.spec.js). Each generated file carries
41
+ * the feature file it came from (`$uri`) and a `bddFileData` block: for every test its line in the feature file, its
42
+ * tags, and every step with its line in the feature file.
43
+ *
44
+ * With that and the feature file itself, a scenario becomes a report row like the Cucumber ones elsewhere: at its
45
+ * line in the .feature file, under its Feature and Rule, Outline rows named after their values with the row as an
46
+ * Examples table, data tables and doc strings as test data, Background steps next to the scenario's own, the steps a
47
+ * failure left unrun greyed out, and an error in the generated file pointed at the step in the feature file.
48
+ *
49
+ * Read only, and never fatal: a file that is not a playwright-bdd spec (or a format this does not know) is left as
50
+ * it is.
51
+ */
52
+ const fs = __importStar(require("fs"));
53
+ const path = __importStar(require("path"));
54
+ const specCache = new Map();
55
+ const linesCache = new Map();
56
+ function lines(file) {
57
+ let l = linesCache.get(file);
58
+ if (!l) {
59
+ try {
60
+ l = fs.readFileSync(file, 'utf8').split(/\r?\n/);
61
+ }
62
+ catch {
63
+ l = [];
64
+ }
65
+ linesCache.set(file, l);
66
+ }
67
+ return l;
68
+ }
69
+ /** The bdd data of a generated spec file, or null when it is not one. */
70
+ function bddSpec(specFile, roots) {
71
+ if (specCache.has(specFile))
72
+ return specCache.get(specFile);
73
+ let out = null;
74
+ try {
75
+ const src = fs.readFileSync(specFile, 'utf8');
76
+ const uri = /\$uri:\s*\[?\(\{\}, use\) => use\((['"])(.+?)\1\)/.exec(src)?.[2] ?? /^\/\/ Generated from: (.+)$/m.exec(src)?.[1]?.trim();
77
+ // $uri is relative to the config folder; try the usual roots
78
+ const feature = uri ? [...roots, path.dirname(specFile)].map(r => path.resolve(r, uri)).find(f => fs.existsSync(f)) : undefined;
79
+ const block = /bdd-data-start\s*\n([\s\S]*?)\n\s*\]; \/\/ bdd-data-end/.exec(src); // playwright-bdd 8+
80
+ const meta = /const bddFileMeta = (\{[\s\S]*?\n\});/.exec(src); // playwright-bdd 7
81
+ if (uri && feature && block) {
82
+ const tests = JSON.parse('[' + block[1].trim().replace(/,\s*$/, '') + ']');
83
+ if (Array.isArray(tests))
84
+ out = { uri, feature, tests };
85
+ }
86
+ else if (uri && feature && meta) {
87
+ const byTitle = new Map();
88
+ for (const [k, v] of Object.entries(JSON.parse(meta[1].replace(/,(\s*\})$/, '$1')))) {
89
+ const line = parseInt(String(v?.pickleLocation ?? ''), 10);
90
+ if (line > 0)
91
+ byTitle.set(k, { pwTestLine: 0, pickleLine: line, tags: v.tags, steps: [] });
92
+ }
93
+ out = { uri, feature, tests: [], byTitle };
94
+ }
95
+ }
96
+ catch {
97
+ out = null;
98
+ }
99
+ specCache.set(specFile, out);
100
+ return out;
101
+ }
102
+ const cells = (row) => row.trim().replace(/^\|/, '').replace(/\|$/, '').split('|').map(c => c.trim().replace(/\\\|/g, '|'));
103
+ const isRow = (l) => !!l && /^\s*\|/.test(l);
104
+ /** The Examples header and the row at `line` (1-based), when that line is an Examples row. */
105
+ function exampleAt(src, line) {
106
+ if (!isRow(src[line - 1]))
107
+ return undefined;
108
+ let top = line;
109
+ while (top > 1 && isRow(src[top - 2]))
110
+ top--;
111
+ if (top === line)
112
+ return undefined; // the header row itself
113
+ let outline;
114
+ for (let i = top - 2; i >= 0; i--) {
115
+ const m = /^\s*(?:Scenario Outline|Scenario Template|Scenario|Example):\s*(.*)$/.exec(src[i]);
116
+ if (m) {
117
+ outline = m[1].trim();
118
+ break;
119
+ }
120
+ }
121
+ return { header: cells(src[top - 1]), values: cells(src[line - 1]), outline };
122
+ }
123
+ /** The data table or doc string right under the step at `line`. */
124
+ function argumentAt(src, line) {
125
+ let i = line; // the line after the step (0-based index = line)
126
+ while (i < src.length && !src[i].trim())
127
+ i++;
128
+ if (isRow(src[i])) {
129
+ const rows = [];
130
+ while (isRow(src[i]))
131
+ rows.push(cells(src[i++]));
132
+ return { table: rows };
133
+ }
134
+ const open = /^(\s*)("""|```)/.exec(src[i] ?? '');
135
+ if (open) {
136
+ const indent = open[1].length, fence = open[2], body = [];
137
+ for (i++; i < src.length && !src[i].trim().startsWith(fence); i++)
138
+ body.push(src[i].slice(Math.min(indent, src[i].search(/\S|$/))));
139
+ return { docString: body.join('\n') };
140
+ }
141
+ return undefined;
142
+ }
143
+ function frame(src, line) {
144
+ if (line < 1 || line > src.length)
145
+ return undefined;
146
+ const lo = Math.max(1, line - 2), hi = Math.min(src.length, line + 2), w = String(hi).length;
147
+ const rows = [];
148
+ for (let n = lo; n <= hi; n++)
149
+ rows.push(`${n === line ? '>' : ' '} ${String(n).padStart(w)} | ${src[n - 1]}`);
150
+ return rows.join('\n');
151
+ }
152
+ /**
153
+ * Turns a playwright-bdd test into a scenario row. `specFile` is the generated spec (absolute), `rel` makes a path
154
+ * relative the way the rest of the report does, `masker` is the report's masker.
155
+ */
156
+ function applyBdd(t, specFile, roots, rel, masker) {
157
+ const spec = bddSpec(specFile, roots);
158
+ if (!spec)
159
+ return false;
160
+ const bt = spec.tests.find(x => x.pwTestLine === t.line) ?? spec.byTitle?.get([...t.path.slice(1), t.title].join('|'));
161
+ if (!bt)
162
+ return false;
163
+ const src = lines(spec.feature);
164
+ const generated = rel(specFile);
165
+ // a tag that became meta (@P1, @critical, @owner:asha) is not also a tag chip, as in the other Cucumber reports
166
+ t.tags = t.tags.filter(g => {
167
+ const tag = g.replace(/^@/, '');
168
+ const kv = /^([a-z_-]+)[:=](.+)$/i.exec(tag);
169
+ if (kv)
170
+ return !(kv[1].toLowerCase() in t.meta);
171
+ if (/^P[0-4]$/i.test(tag))
172
+ return !t.meta.priority;
173
+ if (/^(blocker|critical|major|minor|trivial)$/i.test(tag))
174
+ return !t.meta.severity;
175
+ return true;
176
+ });
177
+ t.file = rel(spec.feature);
178
+ t.line = bt.pickleLine;
179
+ t.column = undefined;
180
+ // Rule: blocks keep their label in the breadcrumb; an Outline's own describe is folded into the title
181
+ const rules = new Set(src.map(l => /^\s*Rule:\s*(.*)$/.exec(l)?.[1]?.trim()).filter(Boolean));
182
+ const ex = exampleAt(src, bt.pickleLine);
183
+ t.path = t.path.filter(p => !(ex?.outline && (p === ex.outline || p === masker.maskStr(ex.outline)))).map(p => rules.has(p) ? 'Rule: ' + p : p);
184
+ const data = [];
185
+ const table = (name, header, rows) => {
186
+ const sens = header.map(h => masker.isSensitive(h));
187
+ const masked = rows.map(r => r.map((c, i) => { if (sens[i]) {
188
+ masker.learn(c);
189
+ return '****';
190
+ } return masker.maskStr(c); }));
191
+ data.push({ name: masker.maskStr(name), kind: 'table', columns: header.map(h => masker.maskStr(h)), rows: masked });
192
+ };
193
+ if (ex) {
194
+ table('Examples', ex.header, [ex.values]);
195
+ const vals = ex.values.join(', ');
196
+ const base = /^Example #\d+$/.test(t.title) && ex.outline ? ex.outline : t.title;
197
+ t.title = masker.maskStr(`${base} (${vals.length > 60 ? vals.slice(0, 60) + '…' : vals})`);
198
+ }
199
+ for (const st of bt.steps) {
200
+ const arg = argumentAt(src, st.gherkinStepLine);
201
+ if (arg?.table && arg.table.length) {
202
+ const [head, ...rest] = arg.table;
203
+ if (rest.length)
204
+ table(st.textWithKeyword, head, rest);
205
+ else
206
+ data.push({ name: masker.maskStr(st.textWithKeyword), kind: 'table', columns: head.map(c => masker.maskStr(c)), rows: [] });
207
+ }
208
+ else if (typeof arg?.docString === 'string') {
209
+ data.push({ name: masker.maskStr(st.textWithKeyword), kind: 'text', text: masker.maskStr(arg.docString) });
210
+ }
211
+ }
212
+ for (const r of t.results) {
213
+ if (data.length)
214
+ r.data.push(...data.map(d => ({ ...d })));
215
+ r.steps = scenarioSteps(r, bt, masker);
216
+ for (const e of r.errors)
217
+ pointAtFeature(e, generated, bt, t.file, src, masker);
218
+ // a step with no definition never starts: it is the failing step, not one left unrun
219
+ const missing = r.errors.map(e => /Missing step:\s*(.+)$/m.exec(e.message)?.[1]?.trim()).find(Boolean);
220
+ if (missing) {
221
+ const st = r.steps.find(x => x.status === 'skipped' && x.title === masker.maskStr(missing));
222
+ if (st) {
223
+ delete st.status;
224
+ st.error = masker.maskStr(`Missing step: ${missing}`);
225
+ }
226
+ }
227
+ }
228
+ return true;
229
+ }
230
+ /** Background steps (run in a beforeEach hook) next to the scenario's own, then the steps that did not run.
231
+ * Gherkin steps are known by their text (keyword included, in whatever language the feature file is written). */
232
+ function scenarioSteps(r, bt, masker) {
233
+ const texts = new Set(bt.steps.map(s => masker.maskStr(s.textWithKeyword)));
234
+ const isGherkin = (s) => s.category === 'test.step' && texts.has(s.title);
235
+ const out = [...r.steps];
236
+ const before = out.findIndex(s => s.category === 'hook' && /^Before Hooks$/.test(s.title));
237
+ const bg = [];
238
+ if (before >= 0) {
239
+ const hooks = out[before];
240
+ const pull = (list) => list.filter(s => {
241
+ if (s.category === 'hook' && s.title === 'Background') {
242
+ s.steps = s.steps.filter(c => { if (isGherkin(c)) {
243
+ bg.push(c);
244
+ return false;
245
+ } return true; });
246
+ }
247
+ else
248
+ s.steps = pull(s.steps);
249
+ return true;
250
+ });
251
+ hooks.steps = pull(hooks.steps);
252
+ if (bg.length)
253
+ out.splice(before + 1, 0, ...bg);
254
+ }
255
+ const ran = out.filter(isGherkin).length;
256
+ const missing = bt.steps.slice(ran);
257
+ if (missing.length && r.status !== 'passed') {
258
+ const after = out.findIndex(s => s.category === 'hook' && /^After Hooks$/.test(s.title));
259
+ const skipped = missing.map(m => ({ title: masker.maskStr(m.textWithKeyword), category: 'test.step', duration: 0, status: 'skipped', steps: [] }));
260
+ out.splice(after >= 0 ? after : out.length, 0, ...skipped);
261
+ }
262
+ return out;
263
+ }
264
+ /** An error located in the generated spec (a missing step, a step that threw there) points at the feature file. */
265
+ function pointAtFeature(e, generated, bt, featureRel, src, masker) {
266
+ if (!e.location || e.location.file !== generated)
267
+ return;
268
+ const st = bt.steps.find(s => s.pwStepLine === e.location.line);
269
+ const line = st?.gherkinStepLine ?? bt.pickleLine;
270
+ e.location = { file: featureRel, line, column: 0 };
271
+ const snip = frame(src, line);
272
+ if (snip)
273
+ e.snippet = masker.maskStr(snip);
274
+ }
@@ -143,6 +143,9 @@ export declare class CypressCollector {
143
143
  private prepareAssets;
144
144
  afterSpec(spec?: CySpec, results?: CyRunResult): void;
145
145
  afterRun(results?: CyAfterRun): Promise<string | undefined>;
146
+ /** `npx cypress run --spec "a.cy.ts,b.cy.ts"` from the project folder, with the browser (when not the default
147
+ * Electron) and the config file (when not one Cypress finds on its own). */
148
+ private rerunShape;
146
149
  /** One Cypress test → one report row. Cypress gives the attempts' states but one duration and one error (the last). */
147
150
  toTest(ct: CyTest, abs: string, file: string, startTime: number): TestData;
148
151
  /** What the support file sent for this test: real per-attempt times, steps, API calls, each attempt's error, meta(). */
@@ -270,6 +270,9 @@ class CypressCollector {
270
270
  for (const t of this.tests) {
271
271
  t.project = project;
272
272
  t.key = `${project}::${t.file}::${[...t.path, t.title].join(' › ')}`;
273
+ // Cypress runs a spec, not one test of it: the re-run target is the spec file
274
+ if (t.file)
275
+ t.rerun = [t.file];
273
276
  }
274
277
  const start = Date.parse(results.startedTestsAt ?? '') || this.startTime || Date.now();
275
278
  const end = Date.parse(results.endedTestsAt ?? '') || this.endTime || Date.now();
@@ -277,7 +280,19 @@ class CypressCollector {
277
280
  const version = this.cypressVersion || results.cypressVersion || '';
278
281
  const bver = results.browserVersion ? ` ${results.browserVersion}` : '';
279
282
  const envRows = version ? [{ k: 'Cypress', v: version + (project ? ` · ${project}${bver}` : '') }] : [];
280
- return (0, write_report_1.writeReport)(this.tests, { startTime: start, endTime: Math.max(end, start), runStatus: failed ? 'failed' : 'passed', workers: 1, envRows }, { ...this.options, outputFolder: this.outDir, logo: this.resolveLogo(this.options.logo), bdd: this.options.bdd });
283
+ return (0, write_report_1.writeReport)(this.tests, { startTime: start, endTime: Math.max(end, start), runStatus: failed ? 'failed' : 'passed', workers: 1, envRows, rerun: this.rerunShape(project) }, { ...this.options, outputFolder: this.outDir, logo: this.resolveLogo(this.options.logo), bdd: this.options.bdd });
284
+ }
285
+ /** `npx cypress run --spec "a.cy.ts,b.cy.ts"` from the project folder, with the browser (when not the default
286
+ * Electron) and the config file (when not one Cypress finds on its own). */
287
+ rerunShape(browser) {
288
+ let pre = 'npx cypress run';
289
+ const cfg = typeof this.config.configFile === 'string' ? this.config.configFile : '';
290
+ if (cfg && (path.dirname(path.resolve(this.base, cfg)) !== this.base || !/^cypress\.config\.[mc]?[jt]s$/.test(path.basename(cfg)))) {
291
+ pre += ' --config-file ' + (0, reporter_2.shellArg)(path.relative(this.base, path.resolve(this.base, cfg)).split(path.sep).join('/'));
292
+ }
293
+ if (browser && browser !== 'electron')
294
+ pre += ' --browser ' + (0, reporter_2.shellArg)(browser);
295
+ return { pre: pre + ' --spec "', sep: ',', post: '"' };
281
296
  }
282
297
  /** One Cypress test → one report row. Cypress gives the attempts' states but one duration and one error (the last). */
283
298
  toTest(ct, abs, file, startTime) {
package/dist/explain.js CHANGED
@@ -40,6 +40,13 @@ function explainError(raw) {
40
40
  const timeoutMs = Number(pick(msg, /(?:Timeout|timeout of|Timed out)\s+(\d+)ms/i) ?? 0) || undefined;
41
41
  const action = pick(first, /^(?:Error: |TimeoutError: )?([a-zA-Z]+\.[a-zA-Z]+):/);
42
42
  const url = pick(msg, /(?:navigating to|at)\s+"?(https?:\/\/[^\s"]+)/);
43
+ // ── playwright-bdd: a step with no step definition, or with several ──────
44
+ const bddMissing = msg.match(/^(?:Error:\s*)?Missing step:\s*(.+)$/m);
45
+ if (bddMissing)
46
+ return out('script', `The step "${short(bddMissing[1].trim(), 90)}" has no step definition.`, 'Add a Given / When / Then for it in your steps files (npx bddgen prints a snippet for it), or check the steps paths in defineBddConfig().', { label: 'Step not defined' });
47
+ const bddTwice = msg.match(/Multiple definitions matched scenario step\.\s*\n\s*Step:\s*(.+?)(?:\s+#\s|\n|$)/);
48
+ if (bddTwice)
49
+ return out('script', `More than one step definition matches "${short(bddTwice[1].trim(), 90)}".`, 'Make the step texts or their expressions differ, so exactly one step definition matches.', { label: 'Step defined twice' });
43
50
  // ── Whole-test and hook timeouts ─────────────────────────────────────────
44
51
  let m = msg.match(/"(beforeAll|beforeEach|afterAll|afterEach)" hook timeout of (\d+)ms exceeded/);
45
52
  if (m)
package/dist/mask.js CHANGED
@@ -41,6 +41,7 @@ const NOT_A_SECRET = new Set(['valid', 'invalid', 'visible', 'hidden', 'required
41
41
  'correct', 'incorrect', 'wrong', 'right', 'expired', 'set', 'unset', 'not', 'present', 'absent', 'ok', 'true', 'false', 'masked', 'blank',
42
42
  'too', 'the', 'a', 'an', 'same', 'different', 'changed', 'unchanged', 'shown', 'displayed', 'accepted', 'rejected', 'weak', 'strong']);
43
43
  const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
44
+ const NOT_SECRET_ENV = new Set(['PWD', 'OLDPWD']);
44
45
  function makeMasker(extraKeys = [], opts = {}) {
45
46
  const keys = [...DEFAULT_KEYS, ...extraKeys.map(k => k.toLowerCase())];
46
47
  const isSensitive = (k) => { const l = k.toLowerCase(); return keys.some(s => l === s || l.includes(s)); };
@@ -81,9 +82,11 @@ function makeMasker(extraKeys = [], opts = {}) {
81
82
  if (opts.fromEnv !== false) {
82
83
  // PASSWORD=…, API_TOKEN=…, OAUTH_CLIENT_SECRET=… in the environment: the values a CI job injects are the
83
84
  // ones that end up in log lines. Short values are skipped so a plain word is not blanked everywhere.
85
+ // PWD / OLDPWD are the shell's current folder ("pwd" is also a password key): learning them would blank the
86
+ // project path in every stack trace and editor link
84
87
  try {
85
88
  for (const [k, v] of Object.entries(process.env))
86
- if (isSensitive(k))
89
+ if (isSensitive(k) && !NOT_SECRET_ENV.has(k.toUpperCase()))
87
90
  learn(v, 6);
88
91
  }
89
92
  catch { /* no env access */ }
@@ -110,6 +113,20 @@ function makeMasker(extraKeys = [], opts = {}) {
110
113
  // expect(token, 'token should match').toBe('x') -> Expected: "x" / Received: "tok_9f8e..."
111
114
  const MENTIONS_SECRET = new RegExp(`\\b(?:${SPOKEN_KEYS.join('|')})s?\\b`, 'i');
112
115
  const COMPARED = /\b(Expected|Received|Actual|expected|received|actual|got)(\s*[:=]\s*)(["'\u201c]?)([^"'\u201d\s]+)/g;
116
+ // In source code (error snippets) a key is followed by code, not by its value: `const token = await login()`,
117
+ // `password: user.password`, `apiKey = process.env.API_KEY`, `authorization: \`Bearer ${token}\``. Masking these
118
+ // would also teach the masker "await" and blank every `await` in the report.
119
+ const CODE_WORDS = new Set(['await', 'async', 'new', 'this', 'self', 'null', 'undefined', 'none', 'nil', 'true', 'false', 'function', 'return', 'typeof', 'require', 'import', 'yield', 'const', 'let', 'var',
120
+ // type names: `password: string`, `token: str`, `pin: int`
121
+ 'string', 'number', 'boolean', 'bigint', 'any', 'unknown', 'object', 'void', 'never', 'symbol', 'str', 'int', 'float', 'bool', 'bytes', 'dict', 'list']);
122
+ const isCodeRef = (raw) => {
123
+ const v = raw.replace(/[)\]},;:.]+$/, '');
124
+ return CODE_WORDS.has(v.toLowerCase())
125
+ || /^`?\$\{/.test(v)
126
+ || /^\{(?:[a-z_][A-Za-z_]*)?\}?$/.test(v) // a placeholder: password {string}, password={password}, password={}
127
+ || /^`?(Bearer|Basic|Digest|Token)$/i.test(v)
128
+ || /^(process\.env|import\.meta\.env|os\.environ|os\.getenv|System\.getenv|ENV)\b/.test(v);
129
+ };
113
130
  const maskStr = (input) => {
114
131
  let s = input;
115
132
  s = s.replace(CARD_NUMBER, m => luhn(m) ? '****' : m);
@@ -126,10 +143,15 @@ function makeMasker(extraKeys = [], opts = {}) {
126
143
  s = s.replace(URL_USERINFO, (_m, a, value, b) => { learn(value); return `${a}****${b}`; });
127
144
  s = s.replace(CLI_USER, (_m, a, value) => { learn(value); return `${a}****`; });
128
145
  s = s.replace(CREDS_PAIR, (_m, a, b, value) => { learn(value); return `${a}${b}****`; });
129
- s = s.replace(KV, (_m, q1, key, q2, sep, q3, value) => { learn(value); return `${q1}${key}${q2}${sep}${q3}****`; });
146
+ s = s.replace(KV, (m, q1, key, q2, sep, q3, value) => {
147
+ if (isCodeRef(value))
148
+ return m; // `token = await login()`: code, not a secret (and never learn "await")
149
+ learn(value);
150
+ return `${q1}${key}${q2}${sep}${q3}****`;
151
+ });
130
152
  s = s.replace(SPOKEN, (m, key, between, value) => {
131
153
  const word = value.toLowerCase().replace(/[^a-z0-9]/g, '');
132
- if (NOT_A_SECRET.has(word) || value.includes('*'))
154
+ if (NOT_A_SECRET.has(word) || value.includes('*') || isCodeRef(value))
133
155
  return m;
134
156
  const explicit = /\b(is|was|of|as)\b|['"]$|[:=]\s*$/.test(between);
135
157
  if (explicit || looksSecret(value)) {
@@ -140,7 +162,7 @@ function makeMasker(extraKeys = [], opts = {}) {
140
162
  });
141
163
  s = s.replace(VALUE_THEN_KEY, (m, value, rest) => {
142
164
  const word = value.toLowerCase().replace(/[^a-z0-9]/g, '');
143
- if (NOT_A_SECRET.has(word) || value.includes('*') || !looksSecret(value))
165
+ if (NOT_A_SECRET.has(word) || value.includes('*') || isCodeRef(value) || !looksSecret(value))
144
166
  return m;
145
167
  learn(value);
146
168
  return `****${rest}`;
@@ -50,6 +50,13 @@ export default class ReportingLabsReporter implements Reporter {
50
50
  private extractMeta;
51
51
  /** A local image file (path relative to the config) is embedded as a data URI so the report stays self-contained. URLs and data URIs pass through. */
52
52
  private resolveLogo;
53
+ /** A test's re-run target: its spec file and line from where the command runs (the working folder), and its
54
+ * project when the config has more than one. A playwright-bdd scenario is its generated spec. */
55
+ private rerunTarget;
56
+ /** `npx playwright test`, with -c when the config is not the one Playwright finds on its own, and `npx bddgen &&`
57
+ * first for playwright-bdd (the generated specs are rebuilt from the feature files). */
58
+ private rerunShape;
59
+ private bddRoots;
53
60
  private rel;
54
61
  private serializeError;
55
62
  private outcome;
@@ -58,6 +65,8 @@ export default class ReportingLabsReporter implements Reporter {
58
65
  private serializeStep;
59
66
  private serializeAttachment;
60
67
  }
68
+ /** Quotes a command-line argument when it needs it (spaces, quotes, shell characters). */
69
+ export declare function shellArg(s: string): string;
61
70
  /**
62
71
  * The environment name the run was pointed at, from the process environment: the variable named
63
72
  * by `envVar` if given, else the usual names (ENV, TEST_ENV, APP_ENV, TARGET_ENV, …), else any
package/dist/reporter.js CHANGED
@@ -33,6 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.shellArg = shellArg;
36
37
  exports.detectEnvName = detectEnvName;
37
38
  exports.ciRunLabel = ciRunLabel;
38
39
  exports.ciLink = ciLink;
@@ -45,12 +46,32 @@ const template_1 = require("./template");
45
46
  const mask_1 = require("./mask");
46
47
  const explain_1 = require("./explain");
47
48
  const pdf_1 = require("./pdf");
49
+ const bdd_1 = require("./bdd");
48
50
  const comments_1 = require("./comments");
49
51
  const DEFAULT_EMBED_LIMIT = 2 * 1024 * 1024;
50
52
  /** Attach steps created by log() and the automatic API capture; the data shows in its own section, so hide the step. */
51
53
  function isInternalAttach(s) {
52
54
  return s.category === 'test.attach' && /^Attach "(rl:log|(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS) )/.test(s.title);
53
55
  }
56
+ /** Playwright 1.63+ moved the target out of the title: title `Click`, subtitle `getByRole('button')`; title `Navigate`,
57
+ * subtitle `/login`. Put it back next to the title, as the report showed before. A test.step's own subtitle and
58
+ * params are shown too: `Open product · SKU 42 (id: 42, currency: USD)`. Older Playwright has no subtitle: unchanged. */
59
+ function stepTitle(s) {
60
+ const x = s;
61
+ let title = s.title;
62
+ const sub = typeof x.subtitle === 'string' ? x.subtitle.trim() : '';
63
+ if (s.category === 'test.step') {
64
+ if (sub)
65
+ title += ` · ${sub}`;
66
+ const p = x.params && typeof x.params === 'object' ? Object.entries(x.params) : [];
67
+ if (p.length)
68
+ title += ` (${p.map(([k, v]) => `${k}: ${typeof v === 'string' ? v : JSON.stringify(v)}`).join(', ')})`;
69
+ }
70
+ else if (sub && !title.includes(sub)) {
71
+ title += ` ${sub}`;
72
+ }
73
+ return title;
74
+ }
54
75
  /** Meta keys shown on every test and turned into links, without being breakdown dimensions. */
55
76
  const META_KEYS = ['priority', 'severity', 'feature', 'owner', 'epic', 'story', 'issue', 'bug', 'component', 'module', 'team', 'sprint', 'testcase', 'tms', 'requirement'];
56
77
  class ReportingLabsReporter {
@@ -125,6 +146,7 @@ class ReportingLabsReporter {
125
146
  const tests = [];
126
147
  const projects = new Set();
127
148
  let workers = 0;
149
+ let bddSpecs = false;
128
150
  for (const test of this.suite.allTests()) {
129
151
  const project = test.parent.project()?.name ?? '';
130
152
  projects.add(project);
@@ -140,7 +162,7 @@ class ReportingLabsReporter {
140
162
  const annotations = [...test.annotations, ...resultAnn.filter(a => !test.annotations.some(b => b.type === a.type && b.description === a.description))];
141
163
  const fromComments = this.commentMeta(test);
142
164
  const extracted = this.extractMeta(test, fromComments);
143
- tests.push({
165
+ const t = {
144
166
  id: test.id,
145
167
  key: `${project}::${file}::${[...titlePath, test.title].join(' › ')}${test.repeatEachIndex ? ' #' + (test.repeatEachIndex + 1) : ''}`,
146
168
  title: test.title,
@@ -161,7 +183,14 @@ class ReportingLabsReporter {
161
183
  retries: test.retries,
162
184
  duration: results.reduce((a, r) => a + r.duration, 0),
163
185
  results,
164
- });
186
+ rerun: this.rerunTarget(test.location.file, test.location.line, project),
187
+ };
188
+ // playwright-bdd: the scenario at its .feature file and line, Gherkin details from the generated spec
189
+ if ((0, bdd_1.applyBdd)(t, test.location.file, this.bddRoots(), f => this.rel(f), this.masker)) {
190
+ bddSpecs = true;
191
+ t.key = `${project}::${t.file}::${[...t.path, t.title].join(' › ')}${test.repeatEachIndex ? ' #' + (test.repeatEachIndex + 1) : ''}`;
192
+ }
193
+ tests.push(t);
165
194
  }
166
195
  const stats = { passed: 0, failed: 0, skipped: 0, flaky: 0, timedOut: 0, interrupted: 0, total: tests.length };
167
196
  for (const t of tests)
@@ -198,11 +227,12 @@ class ReportingLabsReporter {
198
227
  history,
199
228
  bdd,
200
229
  rootDir: base,
201
- env: this.collectEnv(base),
230
+ env: this.collectEnv(base, projects),
202
231
  runStatus: result.status,
203
232
  globalErrors: this.globalErrors,
204
233
  globalOutput: this.globalOutput,
205
234
  shard: this.config.shard ? { current: this.config.shard.current, total: this.config.shard.total } : undefined,
235
+ rerun: this.rerunShape(bddSpecs),
206
236
  options: {
207
237
  logo: this.resolveLogo(this.options.logo),
208
238
  accent: this.options.accent,
@@ -223,6 +253,7 @@ class ReportingLabsReporter {
223
253
  flaky: this.options.widgets?.flaky ?? true,
224
254
  environment: this.options.widgets?.environment ?? true,
225
255
  skipped: this.options.widgets?.skipped ?? true,
256
+ changes: this.options.widgets?.changes ?? true,
226
257
  },
227
258
  dimensions: this.dimensions(),
228
259
  dimensionOrder: {
@@ -332,7 +363,7 @@ class ReportingLabsReporter {
332
363
  await Promise.all([...paths].map(wait));
333
364
  }
334
365
  /** Runtime facts for the Environment card: Playwright, Node, OS, browsers, CI job, git commit. */
335
- collectEnv(base) {
366
+ collectEnv(base, ran = new Set()) {
336
367
  const rows = [];
337
368
  const env = process.env;
338
369
  let pw = '';
@@ -344,7 +375,9 @@ class ReportingLabsReporter {
344
375
  rows.push({ k: 'Playwright', v: pw });
345
376
  rows.push({ k: 'Node', v: process.version });
346
377
  rows.push({ k: 'OS', v: `${os.type()} ${os.release()} (${os.arch()})` });
347
- const browsers = [...new Set(this.config.projects.map(p => { const u = p.use ?? {}; return [u.browserName, u.channel].filter(Boolean).join('/') || (u.defaultBrowserType ?? ''); }).filter(Boolean))];
378
+ // the projects that ran: not one left out by --project or by `default: false` (Playwright 1.64)
379
+ const ranProjects = this.config.projects.filter(p => !ran.size || ran.has(p.name));
380
+ const browsers = [...new Set(ranProjects.map(p => { const u = p.use ?? {}; return [u.browserName, u.channel].filter(Boolean).join('/') || (u.defaultBrowserType ?? ''); }).filter(Boolean))];
348
381
  if (browsers.length)
349
382
  rows.push({ k: 'Browsers', v: browsers.join(', ') });
350
383
  if (this.config.shard)
@@ -510,6 +543,25 @@ class ReportingLabsReporter {
510
543
  }
511
544
  return `data:${type};base64,${fs.readFileSync(file).toString('base64')}`;
512
545
  }
546
+ /** A test's re-run target: its spec file and line from where the command runs (the working folder), and its
547
+ * project when the config has more than one. A playwright-bdd scenario is its generated spec. */
548
+ rerunTarget(file, line, project) {
549
+ const out = [shellArg(path.relative(process.cwd(), file).split(path.sep).join('/') + ':' + line)];
550
+ if (this.config.projects.length > 1 && project)
551
+ out.push('--project=' + shellArg(project));
552
+ return out;
553
+ }
554
+ /** `npx playwright test`, with -c when the config is not the one Playwright finds on its own, and `npx bddgen &&`
555
+ * first for playwright-bdd (the generated specs are rebuilt from the feature files). */
556
+ rerunShape(bdd) {
557
+ const cfg = this.config.configFile;
558
+ const own = cfg && (path.dirname(cfg) !== process.cwd() || !/^playwright\.config\.[mc]?[jt]s$/.test(path.basename(cfg)));
559
+ const c = own ? ' -c ' + shellArg(path.relative(process.cwd(), cfg).split(path.sep).join('/')) : '';
560
+ return { pre: (bdd ? 'npx bddgen && ' : '') + 'npx playwright test' + c + ' ', sep: ' ' };
561
+ }
562
+ bddRoots() {
563
+ return [...new Set([this.config.configFile ? path.dirname(this.config.configFile) : '', this.config.rootDir, process.cwd()].filter(Boolean))];
564
+ }
513
565
  rel(file) {
514
566
  const base = this.config.configFile ? path.dirname(this.config.configFile) : this.config.rootDir;
515
567
  return path.relative(base, file).split(path.sep).join('/');
@@ -617,7 +669,7 @@ class ReportingLabsReporter {
617
669
  }
618
670
  serializeStep(s) {
619
671
  return {
620
- title: this.masker.maskStr(s.title),
672
+ title: this.masker.maskStr(stepTitle(s)),
621
673
  category: s.category,
622
674
  duration: s.duration,
623
675
  error: s.error?.message ? this.masker.maskStr(stripAnsi(s.error.message)) : undefined,
@@ -668,6 +720,10 @@ class ReportingLabsReporter {
668
720
  }
669
721
  }
670
722
  exports.default = ReportingLabsReporter;
723
+ /** Quotes a command-line argument when it needs it (spaces, quotes, shell characters). */
724
+ function shellArg(s) {
725
+ return /^[\w@%+=:,./-]+$/.test(s) ? s : '"' + s.replace(/(["\\$`])/g, '\\$1') + '"';
726
+ }
671
727
  /** Run number from the CI system, used to label history entries when metadata.build is not set. */
672
728
  /** Variables whose name ends in ENV but never hold an environment name. */
673
729
  const NOT_AN_ENV_VAR = new Set(['GITHUB_ENV', 'NODE_ENV', 'BASH_ENV', 'VIRTUAL_ENV', 'CONDA_DEFAULT_ENV', 'RUNNER_ENVIRONMENT', 'PIPENV_ACTIVE', 'ZSH_ENV', 'JAVA_ENV', 'DOTNET_ENVIRONMENT', 'ASPNETCORE_ENVIRONMENT', 'HOSTING_ENVIRONMENT']);
@@ -753,7 +809,7 @@ function gitInfo(cwd, env) {
753
809
  return out;
754
810
  }
755
811
  function extFor(ct) {
756
- const m = { 'image/png': '.png', 'image/jpeg': '.jpg', 'video/webm': '.webm', 'video/mp4': '.mp4', 'application/zip': '.zip', 'application/pdf': '.pdf' };
812
+ const m = { 'image/png': '.png', 'image/jpeg': '.jpg', 'image/webp': '.webp', 'image/gif': '.gif', 'video/webm': '.webm', 'video/mp4': '.mp4', 'application/zip': '.zip', 'application/pdf': '.pdf' };
757
813
  return m[ct] ?? '';
758
814
  }
759
815
  function fmt(v) {
@@ -567,6 +567,19 @@ html,body{-webkit-font-smoothing:antialiased}
567
567
  /* ---------- run status, errors outside tests, snippets ---------- */
568
568
  .att-err{padding:12px 14px;background:var(--fail-bg);color:var(--ink);border-radius:8px 8px 0 0;line-height:1.5} .att-err code{font:12px var(--mono);background:var(--surface);padding:1px 5px;border-radius:4px}
569
569
  .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)}
570
+ /* ---------- since last run, run again ---------- */
571
+ .chg{display:flex;align-items:center;flex-wrap:wrap;gap:6px 16px;margin-top:16px;padding:10px 12px 10px 16px;background:var(--surface);border:1px solid var(--line);border-radius:8px;color:var(--ink-2)}
572
+ .chg .lead{font-weight:600;color:var(--ink)} .chg .lead small{font-weight:400;color:var(--ink-3);margin-left:6px}
573
+ .chg .seg{font:inherit;color:inherit;padding:2px 0;border-bottom:1px dashed transparent;cursor:pointer} .chg .seg b{font-weight:600}
574
+ .chg .seg:hover,.chg .seg[aria-expanded=true]{border-bottom-color:currentColor}
575
+ .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)}
576
+ .chg .same{color:var(--ink-3)} .chg .spacer{flex:1}
577
+ .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}
578
+ .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)}
579
+ .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}
580
+ .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}
581
+ .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)}
582
+ @media print{.chg,.rerun{display:none}}
570
583
  .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)}
571
584
  .badge.xfail{background:var(--flaky-bg);color:var(--flaky-ink)}
572
585
  .xp{font-weight:500} .xp.all{color:var(--ink)} .xp.some{color:var(--flaky-ink)}
@@ -834,6 +847,7 @@ function failuresView(){
834
847
  const cl=failureClusters();
835
848
  const grid=h('div',{class:'grid'});
836
849
  grid.append(h('div',{class:'w12 fx-tools'}, h('span',{class:'fx-sum'}, bad.length+' failed or flaky', PREV.length? ' · '+bad.filter(t=>isFail(t.outcome)&&sinceInfo(t).kind==='new').length+' new since '+runLabel(PREV[PREV.length-1]) : ''), h('span',{class:'spacer'}),
850
+ (()=>{ const c=rerunCmd(data.tests.filter(t=>isFail(t.outcome))); return c? h('button',{class:'btn',title:c,onclick:e=>copyText(c,e.currentTarget,'Command copied')},'Copy re-run command') : null; })(),
837
851
  h('button',{class:'btn',onclick:exportCsv,title:'Failures as CSV for Jira or a sheet'},'Download CSV'), h('button',{class:'btn',onclick:exportJson,title:'Failures as JSON'},'Download JSON'), h('button',{class:'btn primary',onclick:e=>copyText(summaryMarkdown(),e.currentTarget,'Copied for Slack')},'Copy summary')));
838
852
  if(cl.length) grid.append(h('div',{class:'card w6 fail-rail'}, h('h2',{},'Failure clusters', h('span',{class:'hint'},cl.length+' distinct error'+(cl.length>1?'s':''))), clustersView(cl)));
839
853
  if(DIMS.length) grid.append(h('div',{class:'card w6 fail-rail'}, h('h2',{},'Needs attention', h('span',{class:'hint'},'ranked by priority and severity')), attention()));
@@ -1167,7 +1181,8 @@ function summary(){
1167
1181
  pill('passed','Passed',s.passed,'var(--pass)', ok&&s.passed? 'Every test on first attempt' : 'On first attempt', '', hseries(e=>e.passed)),
1168
1182
  pill('failed','Failed',failed,'var(--fail)', failed? (nNew!=null? nNew+' new · '+(failed-nNew)+' known' : nClu+' root cause'+(nClu===1?'':'s')) : 'Nothing broke', failed?'down':'', hseries(e=>e.failed)),
1169
1183
  pill('flaky','Flaky',s.flaky,'var(--flaky)', s.flaky? 'Passed on retry' : 'No retries needed', '', hseries(e=>e.flaky)),
1170
- pill('skipped','Skipped',s.skipped,'var(--skip)', s.skipped? 'Not executed' : 'Everything ran', '', hseries(e=>e.skipped))));
1184
+ pill('skipped','Skipped',s.skipped,'var(--skip)', s.skipped? 'Not executed' : 'Everything ran', '', hseries(e=>e.skipped))),
1185
+ data.options.widgets.changes!==false? changesLine() : null);
1171
1186
  if(data.options.widgets.runStrip && data.tests.length){
1172
1187
  const strip = h('div',{class:'strip',id:'strip'}, data.tests.map(t=>h('button',{class:'cell '+t.outcome,'data-id':t.id,title:t.title+' · '+label[t.outcome]+' · '+ms(t.duration),'aria-label':t.title,onclick:()=>select(t.id)})));
1173
1188
  el.append(strip, h('div',{class:'strip-cap'}, 'Every test in run order. Hover for details, click to open.'));
@@ -1206,6 +1221,51 @@ function prevRun(){
1206
1221
  return fallback;
1207
1222
  }
1208
1223
 
1224
+ /* ---------- since last run, and the command to run tests again ---------- */
1225
+ /* The command that runs these tests again. The runner gives the shape in data.rerun ({pre, sep, post}) and each test
1226
+ its target first, then options it needs (Playwright: file:line, then --project=...). Targets and options are
1227
+ de-duplicated, so a spec that failed twice is listed once. */
1228
+ function rerunCmd(ts){
1229
+ const R=data.rerun; if(!R) return '';
1230
+ const ok=ts.filter(t=>t.rerun&&t.rerun.length); if(!ok.length) return '';
1231
+ const uniq=a=>[...new Set(a)];
1232
+ return R.pre+uniq(ok.map(t=>t.rerun[0])).join(R.sep)+(R.post||'')+uniq(ok.flatMap(t=>t.rerun.slice(1))).map(o=>' '+o).join('');
1233
+ }
1234
+ /* One line under the cards: what changed against the previous comparable run, each part opens its tests.
1235
+ Without history it still offers the command for the failed tests. */
1236
+ function changesLine(){
1237
+ const p=prevRun(), base=p&&p.tests? p : null;
1238
+ const failed=data.tests.filter(t=>isFail(t.outcome)), cmd=rerunCmd(failed);
1239
+ if(!base&&!cmd) return null;
1240
+ const segs=[];
1241
+ if(base){
1242
+ const was=t=>{ const r=base.tests[t.key]; return r? r[0] : null; };
1243
+ const nf=[], fx=[], sf=[], nt=[];
1244
+ for(const t of data.tests){ const w=was(t), f=isFail(t.outcome);
1245
+ if(!w) nt.push(t);
1246
+ if(f&&w!=='f') nf.push(t); else if(f) sf.push(t); else if(w==='f'&&(t.outcome==='passed'||t.outcome==='flaky')) fx.push(t); }
1247
+ const sl=regressions().map(r=>r.t).filter(t=>!isFail(t.outcome)), pl=(n,a,b)=>n===1?a:b;
1248
+ segs.push(['nf',nf,pl(nf.length,'new failure','new failures')], ['fx',fx,'fixed'], ['sf',sf,'still failing'], ['sl',sl,'got slower'], ['nt',nt,pl(nt.length,'new test','new tests')]);
1249
+ }
1250
+ const shown=segs.filter(x=>x[1].length);
1251
+ const el=h('div',{class:'chg'}), list=h('ul',{class:'chg-list',hidden:''});
1252
+ let open=null;
1253
+ const toggle=(k,ts,btn)=>{ el.querySelectorAll('.seg').forEach(b=>b.setAttribute('aria-expanded','false'));
1254
+ if(open===k){ open=null; list.hidden=true; return; }
1255
+ open=k; btn.setAttribute('aria-expanded','true'); list.hidden=false; list.innerHTML='';
1256
+ list.append(...ts.slice(0,12).map(t=>h('li',{}, h('button',{onclick:()=>select(t.id)}, 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:''))))));
1257
+ if(ts.length>12) list.append(h('li',{class:'more'},'and '+(ts.length-12)+' more'));
1258
+ };
1259
+ if(base) el.append(h('span',{class:'lead'},'Since last run', h('small',{},runLabel(base))));
1260
+ else el.append(h('span',{class:'lead'}, failed.length+' failed'));
1261
+ if(base&&!shown.length) el.append(h('span',{class:'same'},'Same results, nothing changed.'));
1262
+ for(const [k,ts,txt] of shown){ const b=h('button',{class:'seg '+k,'aria-expanded':'false',onclick:()=>toggle(k,ts,b)}, h('b',{},ts.length),' '+txt); el.append(b); }
1263
+ el.append(h('span',{class:'spacer'}));
1264
+ if(cmd) el.append(h('button',{class:'btn',title:cmd,onclick:e=>copyText(cmd,e.currentTarget,'Command copied')},'Copy re-run command'+(failed.length>1?' ('+failed.length+' failed)':'')));
1265
+ el.append(list);
1266
+ return el;
1267
+ }
1268
+
1209
1269
  /* ---------- run history per test ---------- */
1210
1270
  function runsOf(t){ return HRUNS.map(e=>({e, r:(t.key&&e.tests[t.key])||null})); }
1211
1271
  /* new vs known: walk back through earlier runs while the test kept failing */
@@ -1718,6 +1778,7 @@ function renderDetail(t, d, retryIdx){
1718
1778
  (()=>{ 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; })(),
1719
1779
  editorLink(t))),
1720
1780
  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:''))));
1781
+ const rc=rerunCmd([t]); if(rc) d.append(h('div',{class:'rerun'}, h('span',{class:'k'},'Run again'), h('code',{title:rc},rc), h('button',{class:'btn',onclick:e=>copyText(rc,e.currentTarget,'Copied')},'Copy')));
1721
1782
  const metaKeys=Object.keys(t.meta);
1722
1783
  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; };
1723
1784
  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); })));
package/dist/template.js CHANGED
@@ -638,6 +638,19 @@ html,body{-webkit-font-smoothing:antialiased}
638
638
  /* ---------- run status, errors outside tests, snippets ---------- */
639
639
  .att-err{padding:12px 14px;background:var(--fail-bg);color:var(--ink);border-radius:8px 8px 0 0;line-height:1.5} .att-err code{font:12px var(--mono);background:var(--surface);padding:1px 5px;border-radius:4px}
640
640
  .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)}
641
+ /* ---------- since last run, run again ---------- */
642
+ .chg{display:flex;align-items:center;flex-wrap:wrap;gap:6px 16px;margin-top:16px;padding:10px 12px 10px 16px;background:var(--surface);border:1px solid var(--line);border-radius:8px;color:var(--ink-2)}
643
+ .chg .lead{font-weight:600;color:var(--ink)} .chg .lead small{font-weight:400;color:var(--ink-3);margin-left:6px}
644
+ .chg .seg{font:inherit;color:inherit;padding:2px 0;border-bottom:1px dashed transparent;cursor:pointer} .chg .seg b{font-weight:600}
645
+ .chg .seg:hover,.chg .seg[aria-expanded=true]{border-bottom-color:currentColor}
646
+ .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)}
647
+ .chg .same{color:var(--ink-3)} .chg .spacer{flex:1}
648
+ .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}
649
+ .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)}
650
+ .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}
651
+ .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}
652
+ .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)}
653
+ @media print{.chg,.rerun{display:none}}
641
654
  .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)}
642
655
  .badge.xfail{background:var(--flaky-bg);color:var(--flaky-ink)}
643
656
  .xp{font-weight:500} .xp.all{color:var(--ink)} .xp.some{color:var(--flaky-ink)}
@@ -900,6 +913,7 @@ function failuresView(){
900
913
  const cl=failureClusters();
901
914
  const grid=h('div',{class:'grid'});
902
915
  grid.append(h('div',{class:'w12 fx-tools'}, h('span',{class:'fx-sum'}, bad.length+' failed or flaky', PREV.length? ' · '+bad.filter(t=>isFail(t.outcome)&&sinceInfo(t).kind==='new').length+' new since '+runLabel(PREV[PREV.length-1]) : ''), h('span',{class:'spacer'}),
916
+ (()=>{ const c=rerunCmd(data.tests.filter(t=>isFail(t.outcome))); return c? h('button',{class:'btn',title:c,onclick:e=>copyText(c,e.currentTarget,'Command copied')},'Copy re-run command') : null; })(),
903
917
  h('button',{class:'btn',onclick:exportCsv,title:'Failures as CSV for Jira or a sheet'},'Download CSV'), h('button',{class:'btn',onclick:exportJson,title:'Failures as JSON'},'Download JSON'), h('button',{class:'btn primary',onclick:e=>copyText(summaryMarkdown(),e.currentTarget,'Copied for Slack')},'Copy summary')));
904
918
  if(cl.length) grid.append(h('div',{class:'card w6 fail-rail'}, h('h2',{},'Failure clusters', h('span',{class:'hint'},cl.length+' distinct error'+(cl.length>1?'s':''))), clustersView(cl)));
905
919
  if(DIMS.length) grid.append(h('div',{class:'card w6 fail-rail'}, h('h2',{},'Needs attention', h('span',{class:'hint'},'ranked by priority and severity')), attention()));
@@ -1233,7 +1247,8 @@ function summary(){
1233
1247
  pill('passed','Passed',s.passed,'var(--pass)', ok&&s.passed? 'Every test on first attempt' : 'On first attempt', '', hseries(e=>e.passed)),
1234
1248
  pill('failed','Failed',failed,'var(--fail)', failed? (nNew!=null? nNew+' new · '+(failed-nNew)+' known' : nClu+' root cause'+(nClu===1?'':'s')) : 'Nothing broke', failed?'down':'', hseries(e=>e.failed)),
1235
1249
  pill('flaky','Flaky',s.flaky,'var(--flaky)', s.flaky? 'Passed on retry' : 'No retries needed', '', hseries(e=>e.flaky)),
1236
- pill('skipped','Skipped',s.skipped,'var(--skip)', s.skipped? 'Not executed' : 'Everything ran', '', hseries(e=>e.skipped))));
1250
+ pill('skipped','Skipped',s.skipped,'var(--skip)', s.skipped? 'Not executed' : 'Everything ran', '', hseries(e=>e.skipped))),
1251
+ data.options.widgets.changes!==false? changesLine() : null);
1237
1252
  if(data.options.widgets.runStrip && data.tests.length){
1238
1253
  const strip = h('div',{class:'strip',id:'strip'}, data.tests.map(t=>h('button',{class:'cell '+t.outcome,'data-id':t.id,title:t.title+' · '+label[t.outcome]+' · '+ms(t.duration),'aria-label':t.title,onclick:()=>select(t.id)})));
1239
1254
  el.append(strip, h('div',{class:'strip-cap'}, 'Every test in run order. Hover for details, click to open.'));
@@ -1272,6 +1287,51 @@ function prevRun(){
1272
1287
  return fallback;
1273
1288
  }
1274
1289
 
1290
+ /* ---------- since last run, and the command to run tests again ---------- */
1291
+ /* The command that runs these tests again. The runner gives the shape in data.rerun ({pre, sep, post}) and each test
1292
+ its target first, then options it needs (Playwright: file:line, then --project=...). Targets and options are
1293
+ de-duplicated, so a spec that failed twice is listed once. */
1294
+ function rerunCmd(ts){
1295
+ const R=data.rerun; if(!R) return '';
1296
+ const ok=ts.filter(t=>t.rerun&&t.rerun.length); if(!ok.length) return '';
1297
+ const uniq=a=>[...new Set(a)];
1298
+ return R.pre+uniq(ok.map(t=>t.rerun[0])).join(R.sep)+(R.post||'')+uniq(ok.flatMap(t=>t.rerun.slice(1))).map(o=>' '+o).join('');
1299
+ }
1300
+ /* One line under the cards: what changed against the previous comparable run, each part opens its tests.
1301
+ Without history it still offers the command for the failed tests. */
1302
+ function changesLine(){
1303
+ const p=prevRun(), base=p&&p.tests? p : null;
1304
+ const failed=data.tests.filter(t=>isFail(t.outcome)), cmd=rerunCmd(failed);
1305
+ if(!base&&!cmd) return null;
1306
+ const segs=[];
1307
+ if(base){
1308
+ const was=t=>{ const r=base.tests[t.key]; return r? r[0] : null; };
1309
+ const nf=[], fx=[], sf=[], nt=[];
1310
+ for(const t of data.tests){ const w=was(t), f=isFail(t.outcome);
1311
+ if(!w) nt.push(t);
1312
+ if(f&&w!=='f') nf.push(t); else if(f) sf.push(t); else if(w==='f'&&(t.outcome==='passed'||t.outcome==='flaky')) fx.push(t); }
1313
+ const sl=regressions().map(r=>r.t).filter(t=>!isFail(t.outcome)), pl=(n,a,b)=>n===1?a:b;
1314
+ segs.push(['nf',nf,pl(nf.length,'new failure','new failures')], ['fx',fx,'fixed'], ['sf',sf,'still failing'], ['sl',sl,'got slower'], ['nt',nt,pl(nt.length,'new test','new tests')]);
1315
+ }
1316
+ const shown=segs.filter(x=>x[1].length);
1317
+ const el=h('div',{class:'chg'}), list=h('ul',{class:'chg-list',hidden:''});
1318
+ let open=null;
1319
+ const toggle=(k,ts,btn)=>{ el.querySelectorAll('.seg').forEach(b=>b.setAttribute('aria-expanded','false'));
1320
+ if(open===k){ open=null; list.hidden=true; return; }
1321
+ open=k; btn.setAttribute('aria-expanded','true'); list.hidden=false; list.innerHTML='';
1322
+ list.append(...ts.slice(0,12).map(t=>h('li',{}, h('button',{onclick:()=>select(t.id)}, 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:''))))));
1323
+ if(ts.length>12) list.append(h('li',{class:'more'},'and '+(ts.length-12)+' more'));
1324
+ };
1325
+ if(base) el.append(h('span',{class:'lead'},'Since last run', h('small',{},runLabel(base))));
1326
+ else el.append(h('span',{class:'lead'}, failed.length+' failed'));
1327
+ if(base&&!shown.length) el.append(h('span',{class:'same'},'Same results, nothing changed.'));
1328
+ for(const [k,ts,txt] of shown){ const b=h('button',{class:'seg '+k,'aria-expanded':'false',onclick:()=>toggle(k,ts,b)}, h('b',{},ts.length),' '+txt); el.append(b); }
1329
+ el.append(h('span',{class:'spacer'}));
1330
+ if(cmd) el.append(h('button',{class:'btn',title:cmd,onclick:e=>copyText(cmd,e.currentTarget,'Command copied')},'Copy re-run command'+(failed.length>1?' ('+failed.length+' failed)':'')));
1331
+ el.append(list);
1332
+ return el;
1333
+ }
1334
+
1275
1335
  /* ---------- run history per test ---------- */
1276
1336
  function runsOf(t){ return HRUNS.map(e=>({e, r:(t.key&&e.tests[t.key])||null})); }
1277
1337
  /* new vs known: walk back through earlier runs while the test kept failing */
@@ -1784,6 +1844,7 @@ function renderDetail(t, d, retryIdx){
1784
1844
  (()=>{ 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; })(),
1785
1845
  editorLink(t))),
1786
1846
  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:''))));
1847
+ const rc=rerunCmd([t]); if(rc) d.append(h('div',{class:'rerun'}, h('span',{class:'k'},'Run again'), h('code',{title:rc},rc), h('button',{class:'btn',onclick:e=>copyText(rc,e.currentTarget,'Copied')},'Copy')));
1787
1848
  const metaKeys=Object.keys(t.meta);
1788
1849
  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; };
1789
1850
  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); })));
package/dist/types.d.ts CHANGED
@@ -62,6 +62,8 @@ export interface ReportingLabsOptions {
62
62
  environment?: boolean;
63
63
  /** Skipped tests with their reasons. Default: true */
64
64
  skipped?: boolean;
65
+ /** The "Since last run" line under the cards (new failures, fixed, still failing, got slower, new tests) with the command to re-run the failed tests. Default: true */
66
+ changes?: boolean;
65
67
  };
66
68
  /**
67
69
  * Annotation/tag keys treated as chart dimensions (priority, severity, owner...).
@@ -287,6 +289,8 @@ export interface TestData {
287
289
  timeout?: number;
288
290
  retries?: number;
289
291
  column?: number;
292
+ /** What runs this test again: its target (a file:line, a spec), then options it needs. See ReportData.rerun. */
293
+ rerun?: string[];
290
294
  }
291
295
  export interface ReportData {
292
296
  title: string;
@@ -318,6 +322,12 @@ export interface ReportData {
318
322
  current: number;
319
323
  total: number;
320
324
  };
325
+ /** How a re-run command is put together: pre + the tests' targets joined with sep + post, then their options. */
326
+ rerun?: {
327
+ pre: string;
328
+ sep: string;
329
+ post?: string;
330
+ };
321
331
  /** Set by `reporting-labs merge`: one lane name per worker (S1·w0, S1·w1, S2·w0 ...) and each shard's size and timing. */
322
332
  workerLabels?: string[];
323
333
  shardInfo?: Array<{
@@ -1,3 +1,5 @@
1
1
  import { type WriteReportOptions } from '../write-report';
2
2
  export type ReportingLabsCompleteOptions = WriteReportOptions;
3
3
  export declare function reportingLabsComplete(options?: ReportingLabsCompleteOptions): Promise<string | undefined>;
4
+ /** The config file of this wdio run, from the launcher's command line (`wdio run ./wdio.conf.ts`, or `wdio wdio.conf.js`). */
5
+ export declare function wdioConfigArg(argv: string[]): string | undefined;
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.reportingLabsComplete = reportingLabsComplete;
37
+ exports.wdioConfigArg = wdioConfigArg;
37
38
  /**
38
39
  * Combines the per-runner partials written by the WDIO reporter into the one report —
39
40
  * index.html, report.json and (best-effort) report.pdf. Call it from `onComplete` in wdio.conf:
@@ -47,6 +48,7 @@ exports.reportingLabsComplete = reportingLabsComplete;
47
48
  const fs = __importStar(require("fs"));
48
49
  const path = __importStar(require("path"));
49
50
  const write_report_1 = require("../write-report");
51
+ const reporter_1 = require("../reporter");
50
52
  async function reportingLabsComplete(options = {}) {
51
53
  const outputFolder = options.outputFolder || 'reporting-labs';
52
54
  const partsDir = path.join(outputFolder, '.rl-wdio');
@@ -81,11 +83,22 @@ async function reportingLabsComplete(options = {}) {
81
83
  startTime = Date.now();
82
84
  if (!endTime)
83
85
  endTime = Date.now();
86
+ // WDIO runs specs: each test's re-run target is its spec file, run with the config this run used
87
+ const conf = wdioConfigArg(process.argv);
88
+ for (const t of tests)
89
+ if (conf && t.file && !t.rerun)
90
+ t.rerun = [(0, reporter_1.shellArg)(t.file)];
91
+ const rerun = conf ? { pre: `npx wdio run ${(0, reporter_1.shellArg)(conf)} --spec `, sep: ' --spec ' } : undefined;
84
92
  // the partials are only needed for this report
85
- const htmlFile = await (0, write_report_1.writeReport)(tests, { startTime, endTime, runStatus, workers }, options);
93
+ const htmlFile = await (0, write_report_1.writeReport)(tests, { startTime, endTime, runStatus, workers, rerun }, options);
86
94
  try {
87
95
  fs.rmSync(partsDir, { recursive: true, force: true });
88
96
  }
89
97
  catch { /* leave them */ }
90
98
  return htmlFile;
91
99
  }
100
+ /** The config file of this wdio run, from the launcher's command line (`wdio run ./wdio.conf.ts`, or `wdio wdio.conf.js`). */
101
+ function wdioConfigArg(argv) {
102
+ const f = argv.slice(2).find(a => /\.conf(ig)?\.[mc]?[jt]s$/.test(a) || /wdio[^/\\]*\.[mc]?[jt]s$/.test(a));
103
+ return f ? path.relative(process.cwd(), path.resolve(f)).split(path.sep).join('/') : undefined;
104
+ }
@@ -1,4 +1,4 @@
1
- import type { TestData, EnvRow } from './types';
1
+ import type { ReportData, TestData, EnvRow } from './types';
2
2
  export interface WriteReportOptions {
3
3
  outputFolder?: string;
4
4
  outputFile?: string;
@@ -46,6 +46,8 @@ export interface RunInfo {
46
46
  workers: number;
47
47
  /** Rows shown first on the Environment card, e.g. the Cypress version and browser. */
48
48
  envRows?: EnvRow[];
49
+ /** How the runner's re-run command is put together (each test carries its own target in TestData.rerun). */
50
+ rerun?: ReportData['rerun'];
49
51
  }
50
52
  /** Writes the report into options.outputFolder (default reporting-labs) and returns the HTML path. */
51
53
  export declare function writeReport(tests: TestData[], run: RunInfo, options?: WriteReportOptions): Promise<string>;
@@ -102,6 +102,7 @@ async function writeReport(tests, run, options = {}) {
102
102
  runStatus,
103
103
  globalErrors: [],
104
104
  globalOutput: [],
105
+ rerun: run.rerun,
105
106
  options: {
106
107
  logo: options.logo,
107
108
  accent: options.accent,
@@ -109,7 +110,7 @@ async function writeReport(tests, run, options = {}) {
109
110
  palette: options.palette ?? 'lab',
110
111
  embedFonts: options.embedFonts ?? true,
111
112
  sections: options.sections ?? [],
112
- widgets: { runStrip: true, outcome: true, attention: true, dimensions: true, timeline: true, durations: true, tags: true, slowest: true, projects: true, flaky: true, environment: true, skipped: true },
113
+ widgets: { runStrip: true, outcome: true, attention: true, dimensions: true, timeline: true, durations: true, tags: true, slowest: true, projects: true, flaky: true, environment: true, skipped: true, changes: true },
113
114
  dimensions: dims,
114
115
  dimensionOrder: {
115
116
  priority: ['P0', 'P1', 'P2', 'P3', 'P4'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reporting-labs",
3
- "version": "0.6.18",
3
+ "version": "0.6.21",
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",