docs: fix details about WorkerInfo vs TestInfo availability (#21699)

Fixes #21695.
This commit is contained in:
Dmitry Gozman 2023-03-16 12:36:34 -07:00 committed by GitHub
parent 03a0f479d2
commit 2074a51299
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 26 deletions

View File

@ -2,7 +2,7 @@
* since: v1.10 * since: v1.10
* langs: js * langs: js
`TestInfo` contains information about currently running test. It is available to any test function, [`method: Test.beforeEach`] and [`method: Test.afterEach`] hooks and test-scoped fixtures. `TestInfo` provides utilities to control test execution: attach files, update test timeout, determine which test is currently running and whether it was retried, etc. `TestInfo` contains information about currently running test. It is available to test functions, [`method: Test.beforeEach`], [`method: Test.afterEach`], [`method: Test.beforeAll`] and [`method: Test.afterAll`] hooks, and test-scoped fixtures. `TestInfo` provides utilities to control test execution: attach files, update test timeout, determine which test is currently running and whether it was retried, etc.
```js ```js
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';

View File

@ -2,15 +2,7 @@
* since: v1.10 * since: v1.10
* langs: js * langs: js
`WorkerInfo` contains information about the worker that is running tests. It is available to [`method: Test.beforeAll`] and [`method: Test.afterAll`] hooks and worker-scoped fixtures. `WorkerInfo` contains information about the worker that is running tests and is available to worker-scoped fixtures. `WorkerInfo` is a subset of [TestInfo] that is available in many other places.
```js
import { test, expect } from '@playwright/test';
test.beforeAll(async ({ browserName }, workerInfo) => {
console.log(`Running ${browserName} in worker #${workerInfo.workerIndex}`);
});
```
## property: WorkerInfo.config ## property: WorkerInfo.config
* since: v1.10 * since: v1.10

View File

@ -1800,19 +1800,8 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
export type TestStatus = 'passed' | 'failed' | 'timedOut' | 'skipped' | 'interrupted'; export type TestStatus = 'passed' | 'failed' | 'timedOut' | 'skipped' | 'interrupted';
/** /**
* `WorkerInfo` contains information about the worker that is running tests. It is available to * `WorkerInfo` contains information about the worker that is running tests and is available to worker-scoped
* [test.beforeAll(hookFunction)](https://playwright.dev/docs/api/class-test#test-before-all) and * fixtures. `WorkerInfo` is a subset of [TestInfo] that is available in many other places.
* [test.afterAll(hookFunction)](https://playwright.dev/docs/api/class-test#test-after-all) hooks and worker-scoped
* fixtures.
*
* ```js
* import { test, expect } from '@playwright/test';
*
* test.beforeAll(async ({ browserName }, workerInfo) => {
* console.log(`Running ${browserName} in worker #${workerInfo.workerIndex}`);
* });
* ```
*
*/ */
export interface WorkerInfo { export interface WorkerInfo {
/** /**
@ -1844,9 +1833,11 @@ export interface WorkerInfo {
} }
/** /**
* `TestInfo` contains information about currently running test. It is available to any test function, * `TestInfo` contains information about currently running test. It is available to test functions,
* [test.beforeEach(hookFunction)](https://playwright.dev/docs/api/class-test#test-before-each) and * [test.beforeEach(hookFunction)](https://playwright.dev/docs/api/class-test#test-before-each),
* [test.afterEach(hookFunction)](https://playwright.dev/docs/api/class-test#test-after-each) hooks and test-scoped * [test.afterEach(hookFunction)](https://playwright.dev/docs/api/class-test#test-after-each),
* [test.beforeAll(hookFunction)](https://playwright.dev/docs/api/class-test#test-before-all) and
* [test.afterAll(hookFunction)](https://playwright.dev/docs/api/class-test#test-after-all) hooks, and test-scoped
* fixtures. `TestInfo` provides utilities to control test execution: attach files, update test timeout, determine * fixtures. `TestInfo` provides utilities to control test execution: attach files, update test timeout, determine
* which test is currently running and whether it was retried, etc. * which test is currently running and whether it was retried, etc.
* *