Reporters & Scripts

The package is composed of a core reporter and a set of CLI scripts for processing the collected data.

The Core Reporter

The main logic resides in playwright-pulse-reporter.ts, which implements Playwright's Reporter interface.

How it Works

  • Event-Driven: It hooks into Playwright's test execution lifecycle using methods like onBegin, onTestEnd, and onEnd.
  • Data Collection: It captures comprehensive data for each test, including status, duration, retries, steps, errors, console output, and tags.
  • Attachment Handling: When a test completes, the reporter automatically processes its attachments. It copies screenshots, videos, and trace files into a structured pulse-report/attachments/ directory.
  • Sharding Awareness: The reporter is aware of sharding. When run in a sharded environment, it saves its results to a temporary file (e.g., .pulse-shard-results-0.json) instead of writing the final report.
  • JSON Output: At the end of a non-sharded run (or after merging shards), it generates the master playwright-pulse-report.json file.

Command-Line Scripts

These scripts transform the raw JSON data into viewable reports. They are designed to be run after npx playwright test has completed.

✨ New in v0.3.0: All CLI scripts now support custom output directories!
🔹 Automatic Detection: Scripts automatically read outputDir from your playwright.config file
🔹 Manual Override: Use --outputDir <path> or -o <path> to override the config
🔹 Default Fallback: Falls back to pulse-report if not configured

Example Config:
reporter: [
  ['@arghajit/playwright-pulse-report', { 
    outputDir: '{YOUR_CUSTOM_REPORT_FOLDER}' 
  }]
]
Now simply run npx generate-pulse-report - no need for -o argument!

generate-pulse-report

  • Purpose: Creates the primary, fully self-contained static HTML report with embedded attachments.
  • Basic Command: npx generate-pulse-report
    (Auto-detects outputDir from config)
  • Manual Override: npx generate-pulse-report --outputDir {YOUR_CUSTOM_REPORT_FOLDER}
    (Overrides config setting)
  • Output: [outputDir]/playwright-pulse-static-report.html

generate-report

  • Purpose: Creates a lightweight HTML report that loads attachments dynamically from the attachments/ folder.
  • Basic Command: npx generate-report
    (Auto-detects outputDir from config)
  • Manual Override: npx generate-report -o {YOUR_CUSTOM_REPORT_FOLDER}
    (Overrides config setting)
  • Output: [outputDir]/playwright-pulse-report.html

merge-pulse-report

  • Purpose: Merges test results from multiple shards into a single master JSON file.
  • Basic Command: npx merge-pulse-report
    (Auto-detects outputDir from config)
  • Manual Override: npx merge-pulse-report --outputDir {YOUR_CUSTOM_REPORT_FOLDER}
    (Overrides config setting)

send-email

  • Purpose: To generate and distribute a lightweight summary report via email.
  • Basic Command: npx send-email
    (Auto-detects outputDir from config)
  • Manual Override: npx send-email --outputDir {YOUR_CUSTOM_REPORT_FOLDER}
    (Overrides config setting)
For advanced use cases, the send-email script also supports custom SMTP settings. Refer to the email report section for details.

Optional CLI Scripts

These scripts are integrated into the main scripts but can be run standalone for specific purposes.

generate-trend

  • Purpose: Archives the current test run's data to enable historical trend analysis.
  • Basic Command: npx generate-trend
    (Auto-detects outputDir from config)
  • Manual Override: npx generate-trend --outputDir {YOUR_CUSTOM_REPORT_FOLDER}
    (Overrides config setting)
  • Details: The main report generation scripts call this automatically. You would run this manually if you only need to update historical data without generating a full HTML report.

generate-email-report

  • Purpose: Generates the lightweight email summary without sending it.
  • Basic Command: npx generate-email-report
    (Auto-detects outputDir from config)
  • Manual Override: npx generate-email-report -o {YOUR_CUSTOM_REPORT_FOLDER}
    (Overrides config setting)