reporting-labs 0.1.1 → 0.1.3

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
@@ -35,6 +35,52 @@ open reporting-labs/index.html
35
35
 
36
36
  That is all. Everything below is optional.
37
37
 
38
+ ## Keep the reporter options in their own file (recommended)
39
+
40
+ As soon as you set more than a title, put the reportingLabs options in a separate file. Your `playwright.config.ts` stays short, and all report settings live in one place.
41
+
42
+ **Step 1.** Create the file (or let the CLI do it with `npx reporting-labs init`):
43
+
44
+ ```ts
45
+ // reporting-labs.config.ts (next to playwright.config.ts)
46
+ import type { ReportingLabsOptions } from 'reporting-labs';
47
+
48
+ const config: ReportingLabsOptions = {
49
+ title: 'My app – regression',
50
+ outputFolder: 'reports/reporting-labs',
51
+ embedVideos: true,
52
+ metadata: { env: process.env.TEST_ENV ?? 'local' },
53
+ // links: { story: 'https://yourteam.atlassian.net/browse/{id}' },
54
+ };
55
+
56
+ export default config;
57
+ ```
58
+
59
+ **Step 2.** Import it in `playwright.config.ts` and add one line to your reporter list. Your other reporters keep working as before.
60
+
61
+ ```ts
62
+ import { defineConfig } from '@playwright/test';
63
+ import reportingLabs from './reporting-labs.config';
64
+
65
+ export default defineConfig({
66
+ reporter: [
67
+ ['list'],
68
+ ['html', { open: 'never' }],
69
+ ['reporting-labs', reportingLabs], // <- this line
70
+ ],
71
+ });
72
+ ```
73
+
74
+ That is it. The `ReportingLabsOptions` type gives you autocomplete for every option in your editor.
75
+
76
+ If your reporter list differs between CI and local (a common pattern), add the same line to both branches:
77
+
78
+ ```ts
79
+ reporter: process.env.CI
80
+ ? [['blob'], ['html', { open: 'never' }], ['reporting-labs', reportingLabs]]
81
+ : [['list'], ['html', { open: 'never' }], ['reporting-labs', reportingLabs]],
82
+ ```
83
+
38
84
  ## A tour of the report
39
85
 
40
86
  ### Overview: the state of the run in one screen
@@ -194,7 +240,7 @@ reporter: [['reporting-labs', {
194
240
  }]]
195
241
  ```
196
242
 
197
- `npx reporting-labs init` writes a starter `reporting-labs.config.ts`.
243
+ `npx reporting-labs init` writes a starter `reporting-labs.config.ts`; see [Keep the reporter options in their own file](#keep-the-reporter-options-in-their-own-file-recommended).
198
244
 
199
245
  ## Running in CI
200
246
 
@@ -233,6 +279,7 @@ Ready-to-copy samples: [docs/ci/github-actions.yml](https://github.com/naveenani
233
279
 
234
280
  - **Single file.** Screenshots and fonts are embedded, so `index.html` works from a mail attachment or a CI artifact. Videos and large files go to `./assets` next to it, so keep the folder together when you move or share the report.
235
281
  - **Re-running tests replaces the report.** The previous report stays intact until the new run finishes, then `index.html` and `assets/` are replaced. A report tab opened from an earlier run will lose its videos at that point; archive the folder if you need to keep it.
282
+ - **Videos on macOS.** If the report lives in Downloads, Desktop or Documents and you open it as a file, Chrome may be blocked from reading the sibling `assets/` files (the player shows a clear message). Allow Chrome under System Settings → Privacy & Security → Files and Folders, move the project elsewhere, or set `embedVideos: true` to put videos inside the HTML.
236
283
  - **Video download.** Served over http (CI artifact viewer, a local server) the download link saves the file; opened as a plain file the browser opens the video in a new tab instead, where the player's menu offers Save.
237
284
  - **Keyboard.** `j` / `k` next and previous test, `f` failed only, `/` search, `1`–`5` switch views, `Esc` close.
238
285
  - **Print.** A print stylesheet is included for PDF export.
package/dist/template.js CHANGED
@@ -1321,7 +1321,7 @@ function renderDetail(t){
1321
1321
  const plainImgs=imgs.filter(a=>!/-(expected|actual|diff)(\.\w+)?$/.test(a.name));
1322
1322
  for(const [name,set] of cmp) if(set.expected&&set.actual) body.append(h('h4',{},'Visual comparison · '+name), compare(set)); else for(const k of Object.keys(set)) plainImgs.push(set[k]);
1323
1323
  if(vids.length){ body.append(h('h4',{},vids.length>1?'Videos':'Video'), h('div',{class:'vids'}, vids.map(a=>{ const fig=h('figure',{}); const v=h('video',{src:a.src,controls:'',preload:'metadata',playsinline:''});
1324
- v.addEventListener('error',()=>{ const code=v.error&&v.error.code; const why=code===4?'The file is missing, or it is not a format this browser can play.':code===2?'The file could not be read.':'The file could not be decoded.'; v.replaceWith(h('div',{class:'att-err'}, h('b',{},'Video could not be loaded.'), ' '+why+' Expected at ', h('code',{},a.src), '. Note: re-running the tests replaces the assets folder, so a report opened from an earlier run loses its videos.')); });
1324
+ v.addEventListener('error',()=>{ const code=v.error&&v.error.code; const why=code===4?'The file is missing, or it is not a format this browser can play.':code===2?'The file could not be read.':'The file could not be decoded.'; v.replaceWith(h('div',{class:'att-err'}, h('b',{},'Video could not be loaded.'), ' '+why+' Expected at ', h('code',{},a.src), '. Common causes: on macOS, Chrome cannot read files next to a report opened from Downloads, Desktop or Documents until you allow it under System Settings → Privacy & Security → Files and Folders (or move the project elsewhere); or the assets folder was replaced by a newer run. Setting embedVideos: true in the reporter options puts videos inside the HTML and avoids both.')); });
1325
1325
  fig.append(v, h('figcaption',{}, a.name, a.size?h('span',{},' · '+kb(a.size)):null, ' · ', h('a',{href:a.src,download:'',target:'_blank',rel:'noopener',title:'Downloads when the report is served over http; opens in a new tab when opened as a file'},'download'))); return fig; }))); }
1326
1326
  if(plainImgs.length){ body.append(h('h4',{},plainImgs.length>1?'Screenshots':'Screenshot'), h('div',{class:'att'}, plainImgs.map(a=>h('figure',{}, h('img',{src:a.src,alt:a.name,loading:'lazy',onclick:()=>lightbox(a.src)}), h('figcaption',{},a.name))))); }
1327
1327
  if(traces.length){ body.append(h('h4',{},'Trace'), h('div',{class:'trace'}, traces.map(a=>h('div',{class:'trace-card'},
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "reporting-labs",
3
- "version": "0.1.1",
4
- "description": "reportingLabs \u2013 beautiful, customizable single-file HTML test reports. One line of config. Playwright adapter included, more runners on the way.",
3
+ "version": "0.1.3",
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",