Download next.js/packages/next/src/experimental/testmode/playwright/step.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 883 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/experimental/testmode/playwright/step.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/next/src/experimental/testmode/playwright/step.ts
-
curl -L -o step.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/experimental/testmode/playwright/step.ts
883 Bytes
| 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<string, string | number | boolean | null | undefined> | |
| } | |
| type Complete = (result: { error?: any }) => void | |
| export async function step<T>( | |
| _testInfo: TestInfo, | |
| props: StepProps, | |
| handler: (complete: Complete) => Promise<Awaited<T>> | |
| ): Promise<Awaited<T>> { | |
| let result: Awaited<T> | |
| 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! | |
| } | |