address comments
This commit is contained in:
parent
822eef7d3f
commit
7f7dfe87df
|
|
@ -2,14 +2,14 @@
|
||||||
* since: v1.51
|
* since: v1.51
|
||||||
* langs: js
|
* langs: js
|
||||||
|
|
||||||
`TestStepInfo` contains information about currently running test step. It is pass as an argument to the step function. `TestStepInfo` provides utilities to control test step execution.
|
`TestStepInfo` contains information about currently running test step. It is passed as an argument to the step function. `TestStepInfo` provides utilities to control test step execution.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import { test, expect } from '@playwright/test';
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
test('basic test', async ({ page, browserName }, TestStepInfo) => {
|
test('basic test', async ({ page, browserName }, TestStepInfo) => {
|
||||||
await test.step('check some behavior', async step => {
|
await test.step('check some behavior', async step => {
|
||||||
await step.skip(browserName === 'webkit, 'The feature is not available in WebKit');
|
await step.skip(browserName === 'webkit', 'The feature is not available in WebKit');
|
||||||
//... rest of the step code
|
//... rest of the step code
|
||||||
await page.check('input');
|
await page.check('input');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ List of steps inside this step.
|
||||||
|
|
||||||
## property: TestStep.annotations
|
## property: TestStep.annotations
|
||||||
* since: v1.51
|
* since: v1.51
|
||||||
- type: ?<[Array]<[Object]>>
|
- type: <[Array]<[Object]>>
|
||||||
- `type` <[string]> Annotation type, for example `'skip'`.
|
- `type` <[string]> Annotation type, for example `'skip'`.
|
||||||
- `description` ?<[string]> Optional description.
|
- `description` ?<[string]> Optional description.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ export type StepEndPayload = {
|
||||||
wallTime: number; // milliseconds since unix epoch
|
wallTime: number; // milliseconds since unix epoch
|
||||||
error?: TestInfoErrorImpl;
|
error?: TestInfoErrorImpl;
|
||||||
suggestedRebaseline?: string;
|
suggestedRebaseline?: string;
|
||||||
annotations?: { type: string, description?: string }[];
|
annotations: { type: string, description?: string }[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TestEntry = {
|
export type TestEntry = {
|
||||||
|
|
|
||||||
|
|
@ -549,7 +549,7 @@ class TeleTestStep implements reporterTypes.TestStep {
|
||||||
}
|
}
|
||||||
|
|
||||||
get annotations() {
|
get annotations() {
|
||||||
return this._endPayload?.annotations;
|
return this._endPayload?.annotations ?? [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -257,7 +257,7 @@ export class TeleReporterEmitter implements ReporterV2 {
|
||||||
duration: step.duration,
|
duration: step.duration,
|
||||||
error: step.error,
|
error: step.error,
|
||||||
attachments: step.attachments.map(a => result.attachments.indexOf(a)),
|
attachments: step.attachments.map(a => result.attachments.indexOf(a)),
|
||||||
annotations: step.annotations,
|
annotations: step.annotations.length ? step.annotations : undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -321,6 +321,7 @@ class JobDispatcher {
|
||||||
duration: -1,
|
duration: -1,
|
||||||
steps: [],
|
steps: [],
|
||||||
attachments: [],
|
attachments: [],
|
||||||
|
annotations: [],
|
||||||
location: params.location,
|
location: params.location,
|
||||||
};
|
};
|
||||||
steps.set(params.stepId, step);
|
steps.set(params.stepId, step);
|
||||||
|
|
|
||||||
|
|
@ -508,16 +508,11 @@ export class TestInfoImpl implements TestInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TestStepInfoImpl implements TestStepInfo {
|
export class TestStepInfoImpl implements TestStepInfo {
|
||||||
annotations?: Annotation[];
|
annotations: Annotation[] = [];
|
||||||
|
|
||||||
private _addAnnotation(type: string, description?: string) {
|
|
||||||
this.annotations ??= [];
|
|
||||||
this.annotations.push({ type, description });
|
|
||||||
}
|
|
||||||
|
|
||||||
async _runStepBody<T>(skip: boolean, body: (step: TestStepInfo) => T | Promise<T>) {
|
async _runStepBody<T>(skip: boolean, body: (step: TestStepInfo) => T | Promise<T>) {
|
||||||
if (skip) {
|
if (skip) {
|
||||||
this._addAnnotation('skip');
|
this.annotations.push({ type: 'skip' });
|
||||||
return undefined as T;
|
return undefined as T;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
@ -535,7 +530,7 @@ export class TestStepInfoImpl implements TestStepInfo {
|
||||||
if (args.length > 0 && !args[0])
|
if (args.length > 0 && !args[0])
|
||||||
return;
|
return;
|
||||||
const description = args[1] as (string|undefined);
|
const description = args[1] as (string|undefined);
|
||||||
this._addAnnotation('skip', description);
|
this.annotations.push({ type: 'skip', description });
|
||||||
throw new SkipError(description);
|
throw new SkipError(description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
4
packages/playwright/types/test.d.ts
vendored
4
packages/playwright/types/test.d.ts
vendored
|
|
@ -9554,7 +9554,7 @@ export interface TestInfoError {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `TestStepInfo` contains information about currently running test step. It is pass as an argument to the step
|
* `TestStepInfo` contains information about currently running test step. It is passed as an argument to the step
|
||||||
* function. `TestStepInfo` provides utilities to control test step execution.
|
* function. `TestStepInfo` provides utilities to control test step execution.
|
||||||
*
|
*
|
||||||
* ```js
|
* ```js
|
||||||
|
|
@ -9562,7 +9562,7 @@ export interface TestInfoError {
|
||||||
*
|
*
|
||||||
* test('basic test', async ({ page, browserName }, TestStepInfo) => {
|
* test('basic test', async ({ page, browserName }, TestStepInfo) => {
|
||||||
* await test.step('check some behavior', async step => {
|
* await test.step('check some behavior', async step => {
|
||||||
* await step.skip(browserName === 'webkit, 'The feature is not available in WebKit');
|
* await step.skip(browserName === 'webkit', 'The feature is not available in WebKit');
|
||||||
* //... rest of the step code
|
* //... rest of the step code
|
||||||
* await page.check('input');
|
* await page.check('input');
|
||||||
* });
|
* });
|
||||||
|
|
|
||||||
2
packages/playwright/types/testReporter.d.ts
vendored
2
packages/playwright/types/testReporter.d.ts
vendored
|
|
@ -694,7 +694,7 @@ export interface TestStep {
|
||||||
/**
|
/**
|
||||||
* The list of annotations applicable to the current test step.
|
* The list of annotations applicable to the current test step.
|
||||||
*/
|
*/
|
||||||
annotations?: Array<{
|
annotations: Array<{
|
||||||
/**
|
/**
|
||||||
* Annotation type, for example `'skip'`.
|
* Annotation type, for example `'skip'`.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue