@testpulse.run/playwright-core
v0.3.0
Published
Foundational TestPulse Playwright reporter event adapter.
Maintainers
Readme
@testpulse.run/playwright-core
Foundational Playwright reporter adapter for TestPulse reporters.
Use this package when you want to build a custom Playwright reporter on top of the same normalized lifecycle events used by the official TestPulse reporters.
Most users should install @testpulse.run/reporter instead. This package is the lower-level event adapter for advanced integrations.
Installation
npm install -D @testpulse.run/playwright-core @playwright/testBasic Usage
import { TestPulseReporterCore, type TestPulseReporterPlugin } from "@testpulse.run/playwright-core";
const plugin: TestPulseReporterPlugin = {
name: "my-reporter",
TestFinished: (event) => {
recordTestResult(event.test.title, event.result.status);
},
RunFinished: async (event) => {
await uploadSummary(event.result);
}
};
export default class MyReporter {
private readonly core = new TestPulseReporterCore({ plugins: [plugin] });
onBegin(...args: Parameters<TestPulseReporterCore["onBegin"]>) {
return this.core.onBegin(...args);
}
onEnd(...args: Parameters<TestPulseReporterCore["onEnd"]>) {
return this.core.onEnd(...args);
}
onTestEnd(...args: Parameters<TestPulseReporterCore["onTestEnd"]>) {
return this.core.onTestEnd(...args);
}
}What It Provides
- Normalized Playwright run, shard, worker, test, step, stdio, and attachment events.
- Serializable test, result, error, project, and attachment metadata.
- Plugin-based event handling for composing reporters.
- Handler error collection with optional Playwright run failure propagation.
Handler Semantics
The core mirrors Playwright's reporter lifecycle:
- Live events are synchronous and
void. - End-of-run events may be asynchronous because Playwright awaits
onEnd().
Live events:
RunStartedShardStartedWorkerStartedTestStartedTestFinishedStepStartedStepFinishedStdOutReceivedStdErrReceivedAttachmentCreatedScreenshotCreatedVideoCreatedTraceCreated
Do not use async work that must be awaited in live handlers:
const plugin = {
TestFinished: (event) => {
writeLocalState(event);
}
};Even if TypeScript accepts an async function in a void callback position, the core intentionally does not await or track promises returned from live handlers.
Async work that must complete before process exit belongs in end-of-run handlers:
const plugin = {
RunFinished: async (event) => {
await uploadFinalReport(event);
}
};Async-capable events:
WorkerFinishedShardFinishedRunFinished
When failOnHandlerError is enabled, handler errors are collected and onEnd() returns { status: "failed" } using Playwright's documented status override mechanism.
Related Packages
@testpulse.run/reporter: preconfigured HTTP reporter for TestPulse.@testpulse.run/playwright-jsonl-reporter: JSONL reporter and sink implementations.@testpulse.run/playwright-events: derived test attempt and final outcome events.
