From 2074a51299a41aecd3af48c37a184850f5f8c39b Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Thu, 16 Mar 2023 12:36:34 -0700 Subject: [PATCH] docs: fix details about WorkerInfo vs TestInfo availability (#21699) Fixes #21695. --- docs/src/test-api/class-testinfo.md | 2 +- docs/src/test-api/class-workerinfo.md | 10 +--------- packages/playwright-test/types/test.d.ts | 23 +++++++---------------- 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/docs/src/test-api/class-testinfo.md b/docs/src/test-api/class-testinfo.md index 7082a18de0..cfbc9cb4be 100644 --- a/docs/src/test-api/class-testinfo.md +++ b/docs/src/test-api/class-testinfo.md @@ -2,7 +2,7 @@ * since: v1.10 * 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 import { test, expect } from '@playwright/test'; diff --git a/docs/src/test-api/class-workerinfo.md b/docs/src/test-api/class-workerinfo.md index 85efce77ef..ac8927bfc9 100644 --- a/docs/src/test-api/class-workerinfo.md +++ b/docs/src/test-api/class-workerinfo.md @@ -2,15 +2,7 @@ * since: v1.10 * 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. - -```js -import { test, expect } from '@playwright/test'; - -test.beforeAll(async ({ browserName }, workerInfo) => { - console.log(`Running ${browserName} in worker #${workerInfo.workerIndex}`); -}); -``` +`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. ## property: WorkerInfo.config * since: v1.10 diff --git a/packages/playwright-test/types/test.d.ts b/packages/playwright-test/types/test.d.ts index d629343543..581622b3e4 100644 --- a/packages/playwright-test/types/test.d.ts +++ b/packages/playwright-test/types/test.d.ts @@ -1800,19 +1800,8 @@ export interface FullConfig { export type TestStatus = 'passed' | 'failed' | 'timedOut' | 'skipped' | 'interrupted'; /** - * `WorkerInfo` contains information about the worker that is running tests. It is available to - * [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 worker-scoped - * fixtures. - * - * ```js - * import { test, expect } from '@playwright/test'; - * - * test.beforeAll(async ({ browserName }, workerInfo) => { - * console.log(`Running ${browserName} in worker #${workerInfo.workerIndex}`); - * }); - * ``` - * + * `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. */ export interface WorkerInfo { /** @@ -1844,9 +1833,11 @@ export interface WorkerInfo { } /** - * `TestInfo` contains information about currently running test. It is available to any test function, - * [test.beforeEach(hookFunction)](https://playwright.dev/docs/api/class-test#test-before-each) and - * [test.afterEach(hookFunction)](https://playwright.dev/docs/api/class-test#test-after-each) hooks and test-scoped + * `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), + * [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 * which test is currently running and whether it was retried, etc. *