#3697·artillery

Playwright engine: add version of `step` which returns the value of the inner action.

Author: danidiazCreated Feb 11, 2026Updated Feb 11, 2026

In the Playwright engine, the test.step argument received by test functions can be used to emit custom metrics that represent how long each step takes.

It has the TypeScript type:

bash
export type PlaywrightEngineTestParam = {
  step: (stepName: string, userActions: Function) => Promise<void>
};

It returns a Promise<void>. However, for some purposes, I would prefer a version that returned the result of the inner action. Something like

stepWithResult: <T> (stepName: string, userActions: fn: () => Promise<T>) => Promise<T>

The motivation is that I'm using the "page objects" pattern for my Playwright code. And it's common for some page object methods to perform a navigation and return the page object for the destination page. It becomes difficult to both measure the timing and get hold of the new page object.

Right now I'm using my own histogram-emitting function on top of the events.emit parameter, which I hope it's equivalent.

Additionally, for some steps that are prone to fail (not only take a long time) under high load, I want to set a counter that tracks how many times that particular step failed. So I would also like to have something like

stepWithResultCountErrors: <T> (stepName: string, errorCounterName: string, userActions: fn: () => Promise<T>) => Promise<T>

Or perhaps there's a better approach for tracking step failures?