Buckets:
| export type Step = <T>(title: string, body: () => Promise<T>) => Promise<T> | |
| /** | |
| * When `@playwright/test` is installed and we're running inside the Playwright | |
| * test runner, wraps the body in a `test.step()` so it appears as a labeled | |
| * step in the Playwright UI. Otherwise just executes the body directly. | |
| */ | |
| let step: Step = (_title, body) => body() | |
| try { | |
| const pw = require('@playwright/test') as typeof import('@playwright/test') | |
| if (typeof pw.test?.step === 'function') { | |
| const playwrightStep = pw.test.step | |
| step = async (title, body) => { | |
| try { | |
| return await playwrightStep(title, body) | |
| } catch (e) { | |
| // If test.step fails because we're not inside the Playwright test | |
| // runner (e.g., running under Jest), fall back to executing the body | |
| // directly without step labels. | |
| if ( | |
| e instanceof Error && | |
| e.message.includes('can only be called from a test') | |
| ) { | |
| return body() | |
| } | |
| throw e | |
| } | |
| } | |
| } | |
| } catch {} | |
| export { step } | |
Xet Storage Details
- Size:
- 1.05 kB
- Xet hash:
- 3d9e4484ae89e0393d808bd96c74b4efaeb9c46ca4db92e6b3b47ba492c56453
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.