Skip to content

Commit

Permalink
cherry-pick(#16421): docs: test.step return value (#16422)
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-s committed Aug 10, 2022
1 parent ecb8266 commit bbd3fd7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
27 changes: 27 additions & 0 deletions docs/src/test-api/class-test.md
Expand Up @@ -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.

Expand All @@ -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]>
Expand Down
14 changes: 14 additions & 0 deletions packages/playwright-test/types/test.d.ts
Expand Up @@ -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.
*/
Expand Down

0 comments on commit bbd3fd7

Please sign in to comment.