Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
docs: test.step return value (#16421)
Yury Semikhatskyd0030a74347f
diff --git a/docs/src/test-api/class-test.md b/docs/src/test-api/class-test.mdindex 93deea5d97..c0f0f8bb3e 100644--- a/docs/src/test-api/class-test.md+++ b/docs/src/test-api/class-test.md@@ -1457,6 +1457,7 @@ Optional description that will be reflected in a test report.## async method: Test.step* since: v1.10+- returns: <[any]>Declares a test step.@@ -1480,6 +1481,32 @@ test('test', async ({ page }) => {});```+The method returns value retuned by the step callback.++```js tab=js-js+const { test, expect } = require('@playwright/test');++test('test', async ({ page }) => {+ const user = await test.step('Log in', async () => {+ // ...+ return 'john';+ });+ expect(user).toBe('john');+});+```++```js tab=js-ts+import { test, expect } from '@playwright/test';++test('test', async ({ page }) => {+ const user = await test.step('Log in', async () => {+ // ...+ return 'john';+ });+ expect(user).toBe('john');+});+```+### param: Test.step.title* since: v1.10- `title` <[string]>diff --git a/packages/playwright-test/types/test.d.ts b/packages/playwright-test/types/test.d.tsindex dbdebf6645..5471fed48f 100644--- a/packages/playwright-test/types/test.d.ts+++ b/packages/playwright-test/types/test.d.ts@@ -2509,6 +2509,20 @@ export interface TestType<TestArgs extends KeyValue, WorkerArgs extends KeyValue* });* ```*+ * The method returns value retuned by the step callback.+ *+ * ```js+ * import { test, expect } from '@playwright/test';+ *+ * test('test', async ({ page }) => {+ * const user = await test.step('Log in', async () => {+ * // ...+ * return 'john';+ * });+ * expect(user).toBe('john');+ * });+ * ```+ ** @param title Step name.* @param body Step body.*/