Advanced Usage

Full Configuration

The reporter can be configured with the following options in your playwright.config.ts:

Option Type Default Description
outputDir string 'pulse-report' The directory where all report assets will be saved.
outputFile string 'playwright-pulse-report.json' The name of the main JSON data file.
resetOnEachRun boolean true If false, the reporter will merge results from sequential runs in the same job.

CI/CD Workflow for Sharding

# .github/workflows/playwright.yml
name: Playwright Tests with Pulse Report
on: [push]
jobs:
  test:
    timeout-minutes: 60
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        shard: [1, 2, 3, 4]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 18
      - run: npm ci
      - run: npx playwright install --with-deps
      - run: npx playwright test --shard=${{ matrix.shard }}/${{ strategy.job-total }}
      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: pulse-report-shard-${{ matrix.shard }}
          path: pulse-report/
          retention-days: 1

  merge-report:
    needs: test
    if: always()
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 18
      - run: npm ci
      - uses: actions/download-artifact@v4
        with:
          path: pulse-report
          pattern: pulse-report-shard-*
          merge-multiple: true
      - run: npx merge-pulse-report
      - run: npx generate-pulse-report
      - uses: actions/upload-artifact@v4
        with:
          name: final-playwright-pulse-report
          path: pulse-report/playwright-pulse-static-report.html
          retention-days: 7

Handling Sequential Test Runs

By default, the reporter will overwrite the `playwright-pulse-report.json` file on each new test run. This is usually what we want. However, if we run tests sequentially in the same job, like this:
npx playwright test test1.spec.ts && npx playwright test test2.spec.ts
By default, In this above scenario, the report from test1 will be lost. To solve this, you can use the resetOnEachRun option.
# playwright.config.ts


import { defineConfig } from "@playwright/test";
import * as path from "path";
              
// Define where the final report JSON and HTML should go
const PULSE_REPORT_DIR = path.resolve(__dirname, "pulse-report"); // Example: a directory in your project root
              
export default defineConfig({
  reporter: [
    ["list"],
    [
      "@arghajit/playwright-pulse-report",
      {
        outputDir: PULSE_REPORT_DIR,
        // Add this option
        resetOnEachRun: false, // Default is true
      },
    ],
  ],
  // ...
});
How it works when resetOnEachRun: false:

- On the first run, it saves report-1.json to a pulse-report/pulse-results directory and creates the main playwright-pulse-report.json from it.
- On the second run, it saves report-2.json to the same directory.
- It then automatically reads both report-1.json and report-2.json, merges them, and updates the main playwright-pulse-report.json with the combined results.

This ensures your final report is always a complete summary of all sequential test runs.