import type { TestInfo } from '@playwright/test' // eslint-disable-next-line import/no-extraneous-dependencies import { test } from '@playwright/test' export interface StepProps { category: string title: string apiName?: string params?: Record } type Complete = (result: { error?: any }) => void export async function step( _testInfo: TestInfo, props: StepProps, handler: (complete: Complete) => Promise> ): Promise> { let result: Awaited let reportedError: any try { await test.step(props.title, async () => { result = await handler(({ error }) => { reportedError = error if (reportedError) { throw reportedError } }) }) } catch (error) { if (error !== reportedError) { throw error } } return result! }