Live per-step domain events under @serenity-js/playwright-test — proposal for an eager-announce mode #3292
Replies: 1 comment 1 reply
|
Hi Nick, I really like where you’re going with this - especially the idea of real-time reporting and building on top of the Serenity/JS event stream. That feels like a very natural fit with the architecture, rather than layering something parallel on top. One thought I had while reading your proposal: would you be open to a slightly different solution shape? Instead of buffering events on the Playwright side, what if we registered a WebSocket reporter automatically when Playwright Test initialises the Serenity/JS reporter? Following that, the worker-level stage crew member could push events directly to the WebSocket server rather than writing to a buffer first. That would simplify things quite a bit and keep the flow aligned with how Serenity/JS is designed to work - events in, events out, no detours. A bonus is that it opens up some interesting possibilities beyond reporting alone:
Feels like this could give you the real-time behaviour you’re after while also reducing some of the moving parts. Curious how that sits with you? |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi @jan-molak and team!
Following up on discussion #2797 — where the suggested "ConsoleReporter alternative via a custom
StageCrewMember" was a great pointer, and I built NGX Ramblers'DomainEventPublisheron top of it.That
StageCrewMemberdesign worked cleanly under WebdriverIO for about a year:InteractionFinished/TaskFinishedevents reached my crew member synchronously, and I streamed each step into an admin UI over WebSocket for live progress during long-running scenarios.When we migrated to
@serenity-js/playwright-testlast week, the crew member went quiet. No errors — just no events until the browser closed, at which point every step arrived in a single burst. ReadingSerenityReporterForPlaywrightTest.tsthe reason became clear:PlaywrightEventBuffercollects everything per test and only flushes viathis.serenity.announce(...events)atonTestEnd.Architecturally that makes sense — Playwright's
TestStep.duration/step.error/step.resultare only final at step end, and buffering keeps Serenity's event construction clean. But for a consumer wanting live domain-event delivery during scenario execution, there's currently noStageCrewMember-based path under Playwright-test.What I ended up doing
A plain Playwright
Reporterregistered alongside@serenity-js/playwright-test, tappingonStepEnd(filteringcategory === "test.step") and POSTing each step out-of-band. It works, but it sits outside Serenity's event model — I had to synthesise my own payload shape and lost the semanticDomainEventtyping.Full write-up with diagrams here.
Suggestion
Would an opt-in eager announce mode on the
@serenity-js/playwright-testreporter be feasible? Something like:Semantics:
onStepEnd, ifstep.category === "test.step", synthesise theInteractionFinished/TaskFinished/ related events andthis.serenity.announce()them immediatelyonTestEnd, announce only the scene-lifecycle events that genuinely need the full result (SceneFinished, retry summaries, etc.)PlaywrightEventBufferwould still back-fill anything that the live path couldn't emit (e.g. retries, crashes, deferred after-all hooks)From a consumer's perspective this would restore the elegance of "one Serenity event pipeline, framework-agnostic" — a
StageCrewMemberlike the one in #2797 could then serve both WDIO and Playwright-test setups unchanged.I might be missing an existing hook that already offers this — if so, please point me at it and I'll happily update the article. Either way, two smaller asks:
@serenity-js/playwright-testAPI page or handbook explicitly calling out the end-of-test flush timing — I checked both and couldn't find it, which is how our silent failure went undiagnosed for an afternoon.Happy to help prototype a PR if there's appetite.
Thanks,
Nick (nbarrett/ngx-ramblers)
All reactions