address comments
This commit is contained in:
parent
822eef7d3f
commit
7f7dfe87df
|
|
@ -2,14 +2,14 @@
|
|||
* since: v1.51
|
||||
* 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
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test('basic test', async ({ page, browserName }, TestStepInfo) => {
|
||||
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
|
||||
await page.check('input');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ List of steps inside this step.
|
|||
|
||||
## property: TestStep.annotations
|
||||
* since: v1.51
|
||||
- type: ?<[Array]<[Object]>>
|
||||
- type: <[Array]<[Object]>>
|
||||
- `type` <[string]> Annotation type, for example `'skip'`.
|
||||
- `description` ?<[string]> Optional description.
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ export type StepEndPayload = {
|
|||
wallTime: number; // milliseconds since unix epoch
|
||||
error?: TestInfoErrorImpl;
|
||||
suggestedRebaseline?: string;
|
||||
annotations?: { type: string, description?: string }[];
|
||||
annotations: { type: string, description?: string }[];
|
||||
};
|
||||
|
||||
export type TestEntry = {
|
||||
|
|
|
|||
|
|
@ -549,7 +549,7 @@ class TeleTestStep implements reporterTypes.TestStep {
|
|||
}
|
||||
|
||||
get annotations() {
|
||||
return this._endPayload?.annotations;
|
||||
return this._endPayload?.annotations ?? [];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ export class TeleReporterEmitter implements ReporterV2 {
|
|||
duration: step.duration,
|
||||
error: step.error,
|
||||
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,
|
||||
steps: [],
|
||||
attachments: [],
|
||||
annotations: [],
|
||||
location: params.location,
|
||||
};
|
||||
steps.set(params.stepId, step);
|
||||
|
|
|
|||
|
|
@ -508,16 +508,11 @@ export class TestInfoImpl implements TestInfo {
|
|||
}
|
||||
|
||||
export class TestStepInfoImpl implements TestStepInfo {
|
||||
annotations?: Annotation[];
|
||||
|
||||
private _addAnnotation(type: string, description?: string) {
|
||||
this.annotations ??= [];
|
||||
this.annotations.push({ type, description });
|
||||
}
|
||||
annotations: Annotation[] = [];
|
||||
|
||||
async _runStepBody<T>(skip: boolean, body: (step: TestStepInfo) => T | Promise<T>) {
|
||||
if (skip) {
|
||||
this._addAnnotation('skip');
|
||||
this.annotations.push({ type: 'skip' });
|
||||
return undefined as T;
|
||||
}
|
||||
try {
|
||||
|
|
@ -535,7 +530,7 @@ export class TestStepInfoImpl implements TestStepInfo {
|
|||
if (args.length > 0 && !args[0])
|
||||
return;
|
||||
const description = args[1] as (string|undefined);
|
||||
this._addAnnotation('skip', description);
|
||||
this.annotations.push({ type: 'skip', 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.
|
||||
*
|
||||
* ```js
|
||||
|
|
@ -9562,7 +9562,7 @@ export interface TestInfoError {
|
|||
*
|
||||
* test('basic test', async ({ page, browserName }, TestStepInfo) => {
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
annotations?: Array<{
|
||||
annotations: Array<{
|
||||
/**
|
||||
* Annotation type, for example `'skip'`.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue