reporting-labs 0.4.3 → 0.5.0
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 +5 -1
- package/bin/config-template.txt +2 -0
- package/dist/reporter.d.ts +4 -0
- package/dist/reporter.js +39 -1
- package/dist/types.d.ts +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,9 +46,10 @@ Your other reporters (list, html, blob...) keep working as before.
|
|
|
46
46
|
|
|
47
47
|
```bash
|
|
48
48
|
npx playwright test
|
|
49
|
-
open reporting-labs/index.html
|
|
50
49
|
```
|
|
51
50
|
|
|
51
|
+
The report opens in your browser when something failed (`open: 'always'` to open every time, `'never'` to stay quiet). It is at `reporting-labs/index.html`.
|
|
52
|
+
|
|
52
53
|
Done. Everything below is optional.
|
|
53
54
|
|
|
54
55
|
> **In a hurry?** Skip the config file and pass options inline: `reporter: [['reporting-labs', { title: 'My app' }]]`.
|
|
@@ -84,6 +85,7 @@ One line per test. With this the report can rank failures by priority, group the
|
|
|
84
85
|
- Known keys: `priority`, `severity`, `owner`, `feature`, `epic`, `story`, `issue`, `component`, `team`. Any other key you pass is shown too.
|
|
85
86
|
- Your Playwright tags like `@sanity` or `@regression` stay as they are and still show on the test.
|
|
86
87
|
- To make story and epic keys clickable, set `links` in the config: `links: { story: 'https://yourteam.atlassian.net/browse/{id}' }`.
|
|
88
|
+
- Forgot one? After every run the console lists the tests that have no `meta()`, with file and line. Turn it off with `warnMissingMeta: false`.
|
|
87
89
|
- `priority`, `severity`, `feature` and `owner` each get a tab in the Breakdown chart and a filter on the Tests page. Want the same for your own key, say `meta({ team: 'web' })`? Add it to `dimensions` in the config: `dimensions: ['priority', 'severity', 'feature', 'owner', 'team']`.
|
|
88
90
|
|
|
89
91
|
### `log()`: a line in the report
|
|
@@ -298,6 +300,8 @@ Every option is optional. `npx reporting-labs init` writes them all, with commen
|
|
|
298
300
|
| `embedVideos` | `false` | Videos inside the HTML too (bigger file, no folder issues) |
|
|
299
301
|
| `embedFonts` | `true` | Bundle the fonts (~140 KB) so it looks the same offline |
|
|
300
302
|
| `announce` | `true` | Print the report path after the run |
|
|
303
|
+
| `open` | `'on-failure'` | Open the report in the browser after the run: `'on-failure'`, `'always'` or `'never'`. Never opens in CI |
|
|
304
|
+
| `warnMissingMeta` | `true` | After the run, list the tests that have no `meta()` in the console, so nobody on the team forgets |
|
|
301
305
|
|
|
302
306
|
If your reporter list differs between CI and local, add the same line to both:
|
|
303
307
|
|
package/bin/config-template.txt
CHANGED
|
@@ -35,6 +35,8 @@ const config: ReportingLabsOptions = {
|
|
|
35
35
|
// embedLimit: 2 * 1024 * 1024, // attachments bigger than this (bytes) are copied as files
|
|
36
36
|
// embedVideos: false, // true = videos inside the HTML too (bigger file, no folder issues)
|
|
37
37
|
// announce: true, // print the report path after the run
|
|
38
|
+
// open: 'on-failure', // open the report in the browser: 'on-failure' | 'always' | 'never'; never in CI
|
|
39
|
+
// warnMissingMeta: true, // after the run, list tests that have no meta() in the console
|
|
38
40
|
|
|
39
41
|
// ── Test details ─────────────────────────────────────────────────────────────
|
|
40
42
|
// Values come from meta({ priority, severity, owner, feature, epic, story, ... }) in your tests.
|
package/dist/reporter.d.ts
CHANGED
|
@@ -20,6 +20,10 @@ export default class ReportingLabsReporter implements Reporter {
|
|
|
20
20
|
private pushOutput;
|
|
21
21
|
onBegin(config: FullConfig, suite: Suite): void;
|
|
22
22
|
onEnd(result: FullResult): Promise<void>;
|
|
23
|
+
/** One short list of tests that carry no meta() at all, so the whole team keeps the report useful. */
|
|
24
|
+
private printMissingMeta;
|
|
25
|
+
/** Open the report in the default browser, like Playwright's HTML reporter. Never in CI. */
|
|
26
|
+
private maybeOpen;
|
|
23
27
|
/** Videos and traces are finalized asynchronously by the runner; wait until every file-backed attachment stops growing. */
|
|
24
28
|
private settleAttachmentFiles;
|
|
25
29
|
/** Runtime facts for the Environment card: Playwright, Node, OS, browsers, CI job, git commit. */
|
package/dist/reporter.js
CHANGED
|
@@ -204,8 +204,46 @@ class ReportingLabsReporter {
|
|
|
204
204
|
fs.writeFileSync(file, (0, template_1.renderHtml)(data), 'utf8');
|
|
205
205
|
if (this.options.announce !== false) {
|
|
206
206
|
const rel = path.relative(process.cwd(), file);
|
|
207
|
-
console.log(`\n reporting-labs: report written to ${rel}
|
|
207
|
+
console.log(`\n reporting-labs: report written to ${rel}`);
|
|
208
|
+
this.printMissingMeta(tests);
|
|
209
|
+
console.log('');
|
|
208
210
|
}
|
|
211
|
+
this.maybeOpen(file, result);
|
|
212
|
+
}
|
|
213
|
+
/** One short list of tests that carry no meta() at all, so the whole team keeps the report useful. */
|
|
214
|
+
printMissingMeta(tests) {
|
|
215
|
+
if (this.options.warnMissingMeta === false)
|
|
216
|
+
return;
|
|
217
|
+
const seen = new Set();
|
|
218
|
+
const missing = tests.filter(t => Object.keys(t.meta).length === 0 && !seen.has(t.file + ':' + t.line) && seen.add(t.file + ':' + t.line));
|
|
219
|
+
if (!missing.length)
|
|
220
|
+
return;
|
|
221
|
+
const total = new Set(tests.map(t => t.file + ':' + t.line)).size;
|
|
222
|
+
console.log(` reporting-labs: ${missing.length} of ${total} tests have no meta()`);
|
|
223
|
+
const show = missing.slice(0, 15);
|
|
224
|
+
const w = Math.max(...show.map(t => (t.file + ':' + t.line).length));
|
|
225
|
+
for (const t of show)
|
|
226
|
+
console.log(` ${(t.file + ':' + t.line).padEnd(w)} ${t.title}`);
|
|
227
|
+
if (missing.length > show.length)
|
|
228
|
+
console.log(` … and ${missing.length - show.length} more`);
|
|
229
|
+
console.log(" Add meta({ priority: 'P1', owner: 'name', feature: 'area' }) at the top of the test. Set warnMissingMeta: false to hide this.");
|
|
230
|
+
}
|
|
231
|
+
/** Open the report in the default browser, like Playwright's HTML reporter. Never in CI. */
|
|
232
|
+
maybeOpen(file, result) {
|
|
233
|
+
const mode = this.options.open ?? 'on-failure';
|
|
234
|
+
if (mode === 'never' || process.env.CI)
|
|
235
|
+
return;
|
|
236
|
+
if (mode === 'on-failure' && result.status === 'passed')
|
|
237
|
+
return;
|
|
238
|
+
try {
|
|
239
|
+
const cmd = process.platform === 'darwin' ? ['open', [file]]
|
|
240
|
+
: process.platform === 'win32' ? ['cmd', ['/c', 'start', '', file]]
|
|
241
|
+
: ['xdg-open', [file]];
|
|
242
|
+
const child = (0, child_process_1.spawn)(cmd[0], [...cmd[1]], { detached: true, stdio: 'ignore' });
|
|
243
|
+
child.on('error', () => { });
|
|
244
|
+
child.unref();
|
|
245
|
+
}
|
|
246
|
+
catch { /* ignore */ }
|
|
209
247
|
}
|
|
210
248
|
// ---- helpers -------------------------------------------------------------
|
|
211
249
|
/** Videos and traces are finalized asynchronously by the runner; wait until every file-backed attachment stops growing. */
|
package/dist/types.d.ts
CHANGED
|
@@ -58,6 +58,10 @@ export interface ReportingLabsOptions {
|
|
|
58
58
|
embedFonts?: boolean;
|
|
59
59
|
/** Print report path to the console after the run. Default: true */
|
|
60
60
|
announce?: boolean;
|
|
61
|
+
/** After the run, list the tests that have no meta() in the console. Default: true */
|
|
62
|
+
warnMissingMeta?: boolean;
|
|
63
|
+
/** Open the report in the browser after the run: 'on-failure' (default), 'always' or 'never'. Never opens in CI. */
|
|
64
|
+
open?: 'on-failure' | 'always' | 'never';
|
|
61
65
|
/** Company / project block in the header. */
|
|
62
66
|
project?: {
|
|
63
67
|
name?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reporting-labs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
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",
|