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
, andonEnd
. - 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.
generate-pulse-report
- Purpose: Creates the primary, fully self-contained static HTML report with embedded attachments.
-
Command:
npx generate-pulse-report
-
Output:
pulse-report/playwright-pulse-static-report.html
generate-report
-
Purpose: Creates a lightweight HTML report that
loads attachments dynamically from the
attachments/
folder. - Command:
npx generate-report
-
Output:
pulse-report/playwright-pulse-report.html
merge-pulse-report
- Purpose: Merges test results from multiple shards into a single master JSON file.
-
Command:
npx merge-pulse-report
send-email
- Purpose: To generate and distribute a lightweight summary report via email.
- Command:
npx send-email
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.
- Command:
npx generate-trend
- 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.
-
Command:
npx generate-email-report