@arghajit/playwright-pulse-report 0.3.3 → 0.3.5

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
@@ -10,7 +10,7 @@ _The ultimate Playwright reporter — Interactive dashboard with historical tren
10
10
 
11
11
  ## [Live Demo](https://arghajit47.github.io/playwright-pulse/demo.html)
12
12
 
13
- ## ![Features](https://ocpaxmghzmfbuhxzxzae.supabase.co/storage/v1/object/public/images/features.svg)
13
+ ## ![Features](https://ocpaxmghzmfbuhxzxzae.supabase.co/storage/v1/object/public/images/pulse-report/features.svg)
14
14
 
15
15
  ## **Documentation**: [Pulse Report](https://arghajit47.github.io/playwright-pulse/)
16
16
 
@@ -21,7 +21,7 @@ The project provides these utility commands:
21
21
  | Command | Description |
22
22
  |------------------------|-----------------------------------------------------------------------------|
23
23
  | `generate-report` | Generates playwright-pulse-report.html, Loads screenshots and images dynamically from the attachments/ directory, Produces a lighter HTML file with faster initial load, Requires attachments/ directory to be present when viewing the report |
24
- | `generate-pulse-report`| Generates `playwright-pulse-static-report.html`, Self-contained, no server required, Preserves all dashboard functionality, all the attachments are embadded in the report, no need to have attachments/ directory when viewing the report, with a dark theme and better initial load handling |
24
+ | `generate-pulse-report`| Generates `playwright-pulse-static-report.html`, Self-contained, no server required, Preserves all dashboard functionality, all the attachments are embedded in the report, no need to have attachments/ directory when viewing the report, with a dark theme and better initial load handling |
25
25
  | `merge-pulse-report` | Combines multiple parallel test json reports, basically used in sharding |
26
26
  | `generate-trend` | Analyzes historical trends in test results |
27
27
  | `generate-email-report`| Generates email-friendly report versions |
@@ -101,24 +101,7 @@ npx merge-pulse-report --outputDir {YOUR_CUSTOM_REPORT_FOLDER}
101
101
 
102
102
  **Important:** Make sure your `playwright.config.ts` custom directory matches the CLI script:
103
103
 
104
- ```typescript
105
- import { defineConfig } from "@playwright/test";
106
- import * as path from "path";
107
-
108
- const CUSTOM_REPORT_DIR = path.resolve(__dirname, "{YOUR_CUSTOM_REPORT_FOLDER}");
109
-
110
- export default defineConfig({
111
- reporter: [
112
- ["list"],
113
- [
114
- "@arghajit/playwright-pulse-report",
115
- {
116
- outputDir: CUSTOM_REPORT_DIR, // Must match CLI --outputDir
117
- },
118
- ],
119
- ],
120
- });
121
- ```
104
+ ![Custom Output Directory](https://ocpaxmghzmfbuhxzxzae.supabase.co/storage/v1/object/public/images/pulse-report/custom-output-directory-config.png)
122
105
 
123
106
  ## 📊 Report Options
124
107
 
@@ -240,76 +223,102 @@ Under the hood, this will:
240
223
  ### Basic Workflow
241
224
 
242
225
  ```yaml
243
- # Upload Pulse report from each shard (per matrix.config.type)
244
- - name: Upload Pulse Report results
245
- if: success() || failure()
246
- uses: actions/upload-artifact@v4
247
- with:
248
- name: pulse-report
249
- path: pulse-report/
250
-
251
- # Download all pulse-report-* artifacts after all shards complete
252
- - name: Download Pulse Report artifacts
253
- uses: actions/download-artifact@v4
254
- with:
255
- pattern: pulse-report
256
- path: downloaded-artifacts
257
-
258
- # Merge all sharded JSON reports into one final output
259
- - name: Generate Pulse Report
260
- run: |
261
- npm run script merge-report
262
- npm run generate-report [or, npm run generate-pulse-report]
263
-
264
- # Upload final merged report as CI artifact
265
- - name: Upload Pulse report
266
- uses: actions/upload-artifact@v4
267
- with:
268
- name: pulse-report
226
+ # .github/workflows/playwright.yml
227
+ name: Playwright Tests
228
+ on:
229
+ push:
230
+ branches: [ main, master ]
231
+ pull_request:
232
+ branches: [ main, master ]
233
+ jobs:
234
+ test:
235
+ timeout-minutes: 60
236
+ runs-on: ubuntu-latest
237
+ steps:
238
+ - uses: actions/checkout@v4
239
+ - uses: actions/setup-node@v4
240
+ with:
241
+ node-version: lts/*
242
+ - name: Install dependencies
243
+ run: npm ci
244
+ - name: Install Playwright Browsers
245
+ run: npx playwright install --with-deps
246
+ - name: Run Playwright tests
247
+ run: npm run test
248
+ - name: Generate Pulse Report
249
+ run: npx generate-report
250
+ - uses: actions/upload-artifact@v4
251
+ if: always()
252
+ with:
253
+ name: pulse-report
254
+ path: pulse-report/
255
+ retention-days: 30
269
256
  ```
270
257
 
258
+ For more details, please refer to the [Pulse Report Basic CI/CD Integration](https://arghajit47.github.io/playwright-pulse/advanced-usage.html).
259
+
271
260
  ### Sharded Workflow
272
261
 
273
262
  ```yaml
274
- # Upload Pulse report from each shard (per matrix.config.type)
275
- - name: Upload Pulse Report results
276
- if: success() || failure()
277
- uses: actions/upload-artifact@v4
278
- with:
279
- name: pulse-report-${{ matrix.config.type }}
280
- path: pulse-report/
281
-
282
- # Download all pulse-report-* artifacts after all shards complete
283
- - name: Download Pulse Report artifacts
284
- uses: actions/download-artifact@v4
285
- with:
286
- pattern: pulse-report-*
287
- path: downloaded-artifacts
288
-
289
- # Organize reports into a single folder and rename for merging
290
- - name: Organize Pulse Report
291
- run: |
292
- mkdir -p pulse-report
293
- for dir in downloaded-artifacts/pulse-report-*; do
294
- config_type=$(basename "$dir" | sed 's/pulse-report-//')
295
- cp -r "$dir/attachments" "pulse-report/attachments"
296
- cp "$dir/playwright-pulse-report.json" "pulse-report/playwright-pulse-report-${config_type}.json"
297
- done
298
-
299
- # Merge all sharded JSON reports into one final output
300
- - name: Generate Pulse Report
301
- run: |
302
- npm run merge-report
303
- npm run generate-report [or, npm run generate-pulse-report]
304
-
305
- # Upload final merged report as CI artifact
306
- - name: Upload Pulse report
307
- uses: actions/upload-artifact@v4
308
- with:
309
- name: pulse-report
310
- path: pulse-report/
263
+ # .github/workflows/playwright.yml
264
+ name: Playwright Tests with Pulse Report
265
+ on: [push]
266
+ jobs:
267
+ test:
268
+ timeout-minutes: 60
269
+ runs-on: ubuntu-latest
270
+ strategy:
271
+ fail-fast: false
272
+ matrix:
273
+ shard: [1, 2, 3, 4]
274
+ steps:
275
+ - uses: actions/checkout@v4
276
+ - uses: actions/setup-node@v4
277
+ with:
278
+ node-version: 18
279
+ - run: npm ci
280
+ - run: npx playwright install --with-deps
281
+ - run: npx playwright test --shard=${{ matrix.shard }}/${{ strategy.job-total }}
282
+ - uses: actions/upload-artifact@v4
283
+ if: always()
284
+ with:
285
+ name: pulse-report-shard-${{ matrix.shard }}
286
+ path: pulse-report/
287
+ retention-days: 1
288
+
289
+ merge-report:
290
+ needs: test
291
+ if: always()
292
+ runs-on: ubuntu-latest
293
+ steps:
294
+ - uses: actions/checkout@v4
295
+ - uses: actions/setup-node@v4
296
+ with:
297
+ node-version: 18
298
+ - run: npm ci
299
+
300
+ # Download all shard artifacts to a single directory
301
+ - uses: actions/download-artifact@v4
302
+ with:
303
+ path: all-reports
304
+ pattern: pulse-report-shard-*
305
+
306
+ # Merge all shard reports into a single report
307
+ - run: npx merge-pulse-report -o all-reports
308
+
309
+ # Generate the final HTML report
310
+ - run: npx generate-pulse-report -o all-reports
311
+
312
+ # Upload the final merged report
313
+ - uses: actions/upload-artifact@v4
314
+ with:
315
+ name: final-playwright-pulse-report
316
+ path: all-reports/
317
+ retention-days: 7
311
318
  ```
312
319
 
320
+ For more details, please refer to the [Pulse Report Sharded CI/CD Integration](https://arghajit47.github.io/playwright-pulse/sharding.html).
321
+
313
322
  ## 🧠 Notes
314
323
 
315
324
  - <strong>`npm run generate-report` generates a HTML report ( screenshots/images will be taken in realtime from 'attachments/' directory ).</strong>
@@ -319,13 +328,14 @@ Under the hood, this will:
319
328
  - After the test matrix completes, reports are downloaded, renamed, and merged.
320
329
  - merge-report is a custom Node.js script that combines all JSON files into one.
321
330
 
322
- ## ![Features](https://ocpaxmghzmfbuhxzxzae.supabase.co/storage/v1/object/public/images//pulse-folder-structures.svg)
331
+ ## ![Folder-Structure](https://ocpaxmghzmfbuhxzxzae.supabase.co/storage/v1/object/public/images/pulse-report/pulse-folder-structures.svg)
323
332
 
324
333
  ### 🚀 **Upgrade Now**
325
334
 
326
335
  ```bash
327
336
  npm install @arghajit/playwright-pulse-report@latest
328
337
  ```
338
+
329
339
  ---
330
340
 
331
341
  ## ⚙️ Advanced Configuration
@@ -340,7 +350,7 @@ npx playwright test test1.spec.ts && npx playwright test test2.spec.ts
340
350
 
341
351
  By default, In this above scenario, the report from test1 will be lost. To solve this, you can use the resetOnEachRun option.
342
352
 
343
- ```bash
353
+ ```javascript
344
354
  // playwright.config.ts
345
355
  import { defineConfig } from "@playwright/test";
346
356
  import * as path from "path";
@@ -4,5 +4,7 @@ export interface PlaywrightPulseReport {
4
4
  results: TestResult[];
5
5
  metadata: {
6
6
  generatedAt: string;
7
+ reportDescription?: string;
8
+ logo?: string;
7
9
  };
8
10
  }
@@ -4,11 +4,13 @@ export declare class PlaywrightPulseReporter implements Reporter {
4
4
  private config;
5
5
  private suite;
6
6
  private results;
7
+ private _pendingTestEnds;
7
8
  private runStartTime;
8
9
  private options;
9
10
  private outputDir;
10
11
  private attachmentsDir;
11
12
  private baseOutputFile;
13
+ private individualReportsSubDir;
12
14
  private isSharded;
13
15
  private shardIndex;
14
16
  private resetOnEachRun;
@@ -17,17 +19,32 @@ export declare class PlaywrightPulseReporter implements Reporter {
17
19
  onBegin(config: FullConfig, suite: Suite): void;
18
20
  onTestBegin(test: TestCase): void;
19
21
  private _getSeverity;
22
+ private extractCodeSnippet;
20
23
  private getBrowserDetails;
21
24
  private processStep;
22
25
  onTestEnd(test: TestCase, result: PwTestResult): Promise<void>;
26
+ private _processTestEnd;
23
27
  private _getFinalizedResults;
24
28
  onError(error: any): void;
25
29
  private _getEnvDetails;
26
30
  private _writeShardResults;
27
31
  private _mergeShardResults;
28
32
  private _cleanupTemporaryFiles;
33
+ /**
34
+ * Removes all individual run JSON files from the `pulse-results/` directory
35
+ * that were left over from previous test sessions.
36
+ *
37
+ * When `resetOnEachRun: false`, each run writes its own timestamped JSON to
38
+ * `pulse-results/` and then `_mergeAllRunReports()` merges them all. However,
39
+ * if files from *older* sessions accumulate there (e.g. because a previous run
40
+ * was interrupted before the post-merge cleanup, or because the user ran tests
41
+ * on a previous day), `_getFinalizedResults()` de-duplicates by `test.id` and
42
+ * collapses results from both sessions into a single entry — producing a
43
+ * `totalTests` count lower than the actual number of tests that ran.
44
+ *
45
+ * Cleaning up at `onBegin` time guarantees each run starts with a fresh slate.
46
+ */
29
47
  private _ensureDirExists;
30
48
  onEnd(result: FullResult): Promise<void>;
31
- private _mergeAllRunReports;
32
49
  }
33
50
  export default PlaywrightPulseReporter;