mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
docs: test.step return value (#16421)
This commit is contained in:
parent
c84fbc2e4e
commit
d0030a7434
@ -1457,6 +1457,7 @@ Optional description that will be reflected in a test report.
|
|||||||
|
|
||||||
## async method: Test.step
|
## async method: Test.step
|
||||||
* since: v1.10
|
* since: v1.10
|
||||||
|
- returns: <[any]>
|
||||||
|
|
||||||
Declares a test step.
|
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
|
### param: Test.step.title
|
||||||
* since: v1.10
|
* since: v1.10
|
||||||
- `title` <[string]>
|
- `title` <[string]>
|
||||||
|
|||||||
14
packages/playwright-test/types/test.d.ts
vendored
14
packages/playwright-test/types/test.d.ts
vendored
@ -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 title Step name.
|
||||||
* @param body Step body.
|
* @param body Step body.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user