From f1f3929a675f4fb6467595721e88692619dbbe52 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Wed, 24 Apr 2024 14:14:05 -0700 Subject: [PATCH] chore: get rid of ConfigInWorker, use FullConfig instead (#30517) Addressing API review feedback. --- docs/src/test-api/class-configinworker.md | 135 ----------- .../class-fullconfig.md | 6 +- .../class-fullproject.md | 5 +- docs/src/test-api/class-projectinworker.md | 96 -------- docs/src/test-api/class-testconfig.md | 4 +- docs/src/test-api/class-testinfo.md | 4 +- docs/src/test-api/class-testproject.md | 2 +- docs/src/test-api/class-workerinfo.md | 4 +- packages/playwright/src/worker/testInfo.ts | 8 +- packages/playwright/types/test.d.ts | 40 ++-- packages/playwright/types/testReporter.d.ts | 213 +----------------- tests/playwright-test/global-setup.spec.ts | 4 +- utils/generate_types/overrides-test.d.ts | 6 +- .../overrides-testReporter.d.ts | 16 +- 14 files changed, 49 insertions(+), 494 deletions(-) delete mode 100644 docs/src/test-api/class-configinworker.md rename docs/src/{test-reporter-api => test-api}/class-fullconfig.md (88%) rename docs/src/{test-reporter-api => test-api}/class-fullproject.md (85%) delete mode 100644 docs/src/test-api/class-projectinworker.md diff --git a/docs/src/test-api/class-configinworker.md b/docs/src/test-api/class-configinworker.md deleted file mode 100644 index 5832dca885..0000000000 --- a/docs/src/test-api/class-configinworker.md +++ /dev/null @@ -1,135 +0,0 @@ -# class: ConfigInWorker -* since: v1.10 -* langs: js - -Resolved configuration available via [`property: TestInfo.config`] and [`property: WorkerInfo.config`]. - -## property: ConfigInWorker.configFile -* since: v1.20 -- type: ?<[string]> - -Path to the configuration file (if any) used to run the tests. - -## property: ConfigInWorker.forbidOnly -* since: v1.10 -- type: <[boolean]> - -See [`property: TestConfig.forbidOnly`]. - -## property: ConfigInWorker.fullyParallel -* since: v1.20 -- type: <[boolean]> - -See [`property: TestConfig.fullyParallel`]. - -## property: ConfigInWorker.globalSetup -* since: v1.10 -- type: <[null]|[string]> - -See [`property: TestConfig.globalSetup`]. - -## property: ConfigInWorker.globalTeardown -* since: v1.10 -- type: <[null]|[string]> - -See [`property: TestConfig.globalTeardown`]. - -## property: ConfigInWorker.globalTimeout -* since: v1.10 -- type: <[int]> - -See [`property: TestConfig.globalTimeout`]. - -## property: ConfigInWorker.grep -* since: v1.10 -- type: <[RegExp]|[Array]<[RegExp]>> - -See [`property: TestConfig.grep`]. - -## property: ConfigInWorker.grepInvert -* since: v1.10 -- type: <[null]|[RegExp]|[Array]<[RegExp]>> - -See [`property: TestConfig.grepInvert`]. - -## property: ConfigInWorker.maxFailures -* since: v1.10 -- type: <[int]> - -See [`property: TestConfig.maxFailures`]. - -## property: ConfigInWorker.metadata -* since: v1.10 -- type: <[Metadata]> - -See [`property: TestConfig.metadata`]. - -## property: ConfigInWorker.preserveOutput -* since: v1.10 -- type: <[PreserveOutput]<"always"|"never"|"failures-only">> - -See [`property: TestConfig.preserveOutput`]. - -## property: ConfigInWorker.projects -* since: v1.10 -- type: <[Array]<[ProjectInWorker]>> - -List of resolved projects. - -## property: ConfigInWorker.quiet -* since: v1.10 -- type: <[boolean]> - -See [`property: TestConfig.quiet`]. - -## property: ConfigInWorker.reporter -* since: v1.10 -- type: <[string]|[Array]<[Object]>|[BuiltInReporter]<"list"|"dot"|"line"|"github"|"json"|"junit"|"null"|"html">> - - `0` <[string]> Reporter name or module or file path - - `1` <[Object]> An object with reporter options if any - -See [`property: TestConfig.reporter`]. - -## property: ConfigInWorker.reportSlowTests -* since: v1.10 -- type: <[null]|[Object]> - - `max` <[int]> The maximum number of slow test files to report. Defaults to `5`. - - `threshold` <[float]> Test duration in milliseconds that is considered slow. Defaults to 15 seconds. - -See [`property: TestConfig.reportSlowTests`]. - -## property: ConfigInWorker.rootDir -* since: v1.20 -- type: <[string]> - -## property: ConfigInWorker.shard -* since: v1.10 -- type: <[null]|[Object]> - - `total` <[int]> The total number of shards. - - `current` <[int]> The index of the shard to execute, one-based. - -See [`property: TestConfig.shard`]. - -## property: ConfigInWorker.updateSnapshots -* since: v1.10 -- type: <[UpdateSnapshots]<"all"|"none"|"missing">> - -See [`property: TestConfig.updateSnapshots`]. - -## property: ConfigInWorker.version -* since: v1.20 -- type: <[string]> - -Playwright version. - -## property: ConfigInWorker.webServer -* since: v1.10 -- type: <[null]|[Object]> - -See [`property: TestConfig.webServer`]. - -## property: ConfigInWorker.workers -* since: v1.10 -- type: <[int]> - -See [`property: TestConfig.workers`]. diff --git a/docs/src/test-reporter-api/class-fullconfig.md b/docs/src/test-api/class-fullconfig.md similarity index 88% rename from docs/src/test-reporter-api/class-fullconfig.md rename to docs/src/test-api/class-fullconfig.md index ce4318560f..e6437ab314 100644 --- a/docs/src/test-reporter-api/class-fullconfig.md +++ b/docs/src/test-api/class-fullconfig.md @@ -2,13 +2,13 @@ * since: v1.10 * langs: js -Resolved configuration passed to [`method: Reporter.onBegin`]. +Resolved configuration which is accessible via [`property: TestInfo.config`] and is passed to the test reporters. To see the format of Playwright configuration file, please see [TestConfig] instead. ## property: FullConfig.configFile * since: v1.20 - type: ?<[string]> -Path to the configuration file (if any) used to run the tests. +Path to the configuration file used to run the tests. The value is an empty string if no config file was used. ## property: FullConfig.forbidOnly * since: v1.10 @@ -102,6 +102,8 @@ See [`property: TestConfig.reportSlowTests`]. * since: v1.20 - type: <[string]> +Base directory for all relative paths used in the reporters. + ## property: FullConfig.shard * since: v1.10 - type: <[null]|[Object]> diff --git a/docs/src/test-reporter-api/class-fullproject.md b/docs/src/test-api/class-fullproject.md similarity index 85% rename from docs/src/test-reporter-api/class-fullproject.md rename to docs/src/test-api/class-fullproject.md index 9a744115df..682f9bb672 100644 --- a/docs/src/test-reporter-api/class-fullproject.md +++ b/docs/src/test-api/class-fullproject.md @@ -2,10 +2,7 @@ * since: v1.10 * langs: js -Runtime representation of the test project configuration that is passed -to [Reporter]. It exposes some of the resolved fields declared in -[TestProject]. You can get [FullProject] instance from [`property: FullConfig.projects`] -or [`method: Suite.project`]. +Runtime representation of the test project configuration. It is accessible in the tests via [`property: TestInfo.project`] and [`property: WorkerInfo.project`] and is passed to the test reporters. To see the format of the project in the Playwright configuration file please see [TestProject] instead. ## property: FullProject.dependencies * since: v1.31 diff --git a/docs/src/test-api/class-projectinworker.md b/docs/src/test-api/class-projectinworker.md deleted file mode 100644 index c8ede102ba..0000000000 --- a/docs/src/test-api/class-projectinworker.md +++ /dev/null @@ -1,96 +0,0 @@ -# class: ProjectInWorker -* since: v1.10 -* langs: js - -Runtime representation of the test project configuration that can be accessed -in the tests via [`property: TestInfo.project`] and [`property: WorkerInfo.project`]. - -## property: ProjectInWorker.dependencies -* since: v1.31 -- type: <[Array]<[string]>> - -See [`property: TestProject.dependencies`]. - -## property: ProjectInWorker.grep -* since: v1.10 -- type: <[RegExp]|[Array]<[RegExp]>> - -See [`property: TestProject.grep`]. - -## property: ProjectInWorker.grepInvert -* since: v1.10 -- type: <[null]|[RegExp]|[Array]<[RegExp]>> - -See [`property: TestProject.grepInvert`]. - -## property: ProjectInWorker.metadata -* since: v1.10 -- type: <[Metadata]> - -See [`property: TestProject.metadata`]. - -## property: ProjectInWorker.name -* since: v1.10 -- type: <[string]> - -See [`property: TestProject.name`]. - -## property: ProjectInWorker.snapshotDir -* since: v1.10 -- type: <[string]> - -See [`property: TestProject.snapshotDir`]. - -## property: ProjectInWorker.outputDir -* since: v1.10 -- type: <[string]> - -See [`property: TestProject.outputDir`]. - -## property: ProjectInWorker.repeatEach -* since: v1.10 -- type: <[int]> - -See [`property: TestProject.repeatEach`]. - -## property: ProjectInWorker.retries -* since: v1.10 -- type: <[int]> - -See [`property: TestProject.retries`]. - -## property: ProjectInWorker.teardown -* since: v1.34 -- type: ?<[string]> - -See [`property: TestProject.teardown`]. - -## property: ProjectInWorker.testDir -* since: v1.10 -- type: <[string]> - -See [`property: TestProject.testDir`]. - -## property: ProjectInWorker.testIgnore -* since: v1.10 -- type: <[string]|[RegExp]|[Array]<[string]|[RegExp]>> - -See [`property: TestProject.testIgnore`]. - -## property: ProjectInWorker.testMatch -* since: v1.10 -- type: <[string]|[RegExp]|[Array]<[string]|[RegExp]>> - -See [`property: TestProject.testMatch`]. - -## property: ProjectInWorker.timeout -* since: v1.10 -- type: <[int]> - -See [`property: TestProject.timeout`]. - -## property: ProjectInWorker.use -* since: v1.10 -- type: <[Fixtures]> - -See [`property: TestProject.use`]. diff --git a/docs/src/test-api/class-testconfig.md b/docs/src/test-api/class-testconfig.md index a89236cbf0..e19a11f815 100644 --- a/docs/src/test-api/class-testconfig.md +++ b/docs/src/test-api/class-testconfig.md @@ -2,7 +2,7 @@ * since: v1.10 * langs: js -Playwright Test provides many options to configure how your tests are collected and executed, for example `timeout` or `testDir`. These options are described in the [TestConfig] object in the [configuration file](../test-configuration.md). +Playwright Test provides many options to configure how your tests are collected and executed, for example `timeout` or `testDir`. These options are described in the [TestConfig] object in the [configuration file](../test-configuration.md). This type describes format of the configuration file, to access resolved configuration parameters at run time use [FullConfig]. Playwright Test supports running multiple test projects at the same time. Project-specific options should be put to [`property: TestConfig.projects`], but top-level [TestConfig] can also define base options shared between all projects. @@ -112,7 +112,7 @@ export default defineConfig({ * since: v1.10 - type: ?<[string]> -Path to the global setup file. This file will be required and run before all the tests. It must export a single function that takes a [`TestConfig`] argument. +Path to the global setup file. This file will be required and run before all the tests. It must export a single function that takes a [FullConfig] argument. Learn more about [global setup and teardown](../test-global-setup-teardown.md). diff --git a/docs/src/test-api/class-testinfo.md b/docs/src/test-api/class-testinfo.md index 096fbfcc10..cbc125b3bf 100644 --- a/docs/src/test-api/class-testinfo.md +++ b/docs/src/test-api/class-testinfo.md @@ -106,7 +106,7 @@ Column number where the currently running test is declared. ## property: TestInfo.config * since: v1.10 -- type: <[ConfigInWorker]> +- type: <[FullConfig]> Processed configuration from the [configuration file](../test-configuration.md). @@ -279,7 +279,7 @@ Also available as `process.env.TEST_PARALLEL_INDEX`. Learn more about [paralleli ## property: TestInfo.project * since: v1.10 -- type: <[ProjectInWorker]> +- type: <[FullProject]> Processed project configuration from the [configuration file](../test-configuration.md). diff --git a/docs/src/test-api/class-testproject.md b/docs/src/test-api/class-testproject.md index 2ed68de275..7477a3a88d 100644 --- a/docs/src/test-api/class-testproject.md +++ b/docs/src/test-api/class-testproject.md @@ -2,7 +2,7 @@ * since: v1.10 * langs: js -Playwright Test supports running multiple test projects at the same time. This is useful for running tests in multiple configurations. For example, consider running tests against multiple browsers. +Playwright Test supports running multiple test projects at the same time. This is useful for running tests in multiple configurations. For example, consider running tests against multiple browsers. This type describes format of a project in the configuration file, to access resolved configuration parameters at run time use [FullProject]. `TestProject` encapsulates configuration specific to a single project. Projects are configured in [`property: TestConfig.projects`] specified in the [configuration file](../test-configuration.md). Note that all properties of [TestProject] are available in the top-level [TestConfig], in which case they are shared between all projects. diff --git a/docs/src/test-api/class-workerinfo.md b/docs/src/test-api/class-workerinfo.md index e7ae892190..3ae9a3bd21 100644 --- a/docs/src/test-api/class-workerinfo.md +++ b/docs/src/test-api/class-workerinfo.md @@ -6,7 +6,7 @@ ## property: WorkerInfo.config * since: v1.10 -- type: <[ConfigInWorker]> +- type: <[FullConfig]> Processed configuration from the [configuration file](../test-configuration.md). @@ -22,7 +22,7 @@ Also available as `process.env.TEST_PARALLEL_INDEX`. Learn more about [paralleli ## property: WorkerInfo.project * since: v1.10 -- type: <[ProjectInWorker]> +- type: <[FullProject]> Processed project configuration from the [configuration file](../test-configuration.md). diff --git a/packages/playwright/src/worker/testInfo.ts b/packages/playwright/src/worker/testInfo.ts index 5204ade21e..6e55f68dac 100644 --- a/packages/playwright/src/worker/testInfo.ts +++ b/packages/playwright/src/worker/testInfo.ts @@ -17,13 +17,13 @@ import fs from 'fs'; import path from 'path'; import { captureRawStack, monotonicTime, zones, sanitizeForFilePath, stringifyStackFrames } from 'playwright-core/lib/utils'; -import type { TestInfoError, TestInfo, TestStatus, ProjectInWorker, ConfigInWorker } from '../../types/test'; +import type { TestInfoError, TestInfo, TestStatus, FullProject } from '../../types/test'; import type { AttachmentPayload, StepBeginPayload, StepEndPayload, WorkerInitParams } from '../common/ipc'; import type { TestCase } from '../common/test'; import { TimeoutManager, TimeoutManagerError, kMaxDeadline } from './timeoutManager'; import type { RunnableDescription } from './timeoutManager'; import type { Annotation, FullConfigInternal, FullProjectInternal } from '../common/config'; -import type { Location } from '../../types/testReporter'; +import type { FullConfig, Location } from '../../types/testReporter'; import { debugTest, filteredStackTrace, formatLocation, getContainedPath, normalizeAndSaveAttachment, serializeError, trimLongString, windowsFilesystemFriendlyLength } from '../util'; import { TestTracing } from './testTracing'; import type { Attachment } from './testTracing'; @@ -81,8 +81,8 @@ export class TestInfoImpl implements TestInfo { readonly retry: number; readonly workerIndex: number; readonly parallelIndex: number; - readonly project: ProjectInWorker; - readonly config: ConfigInWorker; + readonly project: FullProject; + readonly config: FullConfig; readonly title: string; readonly titlePath: string[]; readonly file: string; diff --git a/packages/playwright/types/test.d.ts b/packages/playwright/types/test.d.ts index 01470c2bba..1a31c166b9 100644 --- a/packages/playwright/types/test.d.ts +++ b/packages/playwright/types/test.d.ts @@ -35,7 +35,9 @@ type UseOptions = Partial & Partial; /** * Playwright Test supports running multiple test projects at the same time. This is useful for running tests in - * multiple configurations. For example, consider running tests against multiple browsers. + * multiple configurations. For example, consider running tests against multiple browsers. This type describes format + * of a project in the configuration file, to access resolved configuration parameters at run time use {@link + * FullProject}. * * `TestProject` encapsulates configuration specific to a single project. Projects are configured in * [testConfig.projects](https://playwright.dev/docs/api/class-testconfig#test-config-projects) specified in the @@ -626,11 +628,13 @@ export interface Project extends TestProject { +export interface FullProject { /** * See [testProject.use](https://playwright.dev/docs/api/class-testproject#test-project-use). */ @@ -711,7 +715,8 @@ type LiteralUnion = T | (U & { zz_IGNORE_ME?: never }); /** * Playwright Test provides many options to configure how your tests are collected and executed, for example `timeout` * or `testDir`. These options are described in the {@link TestConfig} object in the - * [configuration file](https://playwright.dev/docs/test-configuration). + * [configuration file](https://playwright.dev/docs/test-configuration). This type describes format of the configuration file, to access + * resolved configuration parameters at run time use {@link FullConfig}. * * Playwright Test supports running multiple test projects at the same time. Project-specific options should be put to * [testConfig.projects](https://playwright.dev/docs/api/class-testconfig#test-config-projects), but top-level {@link @@ -1055,7 +1060,7 @@ interface TestConfig { /** * Path to the global setup file. This file will be required and run before all the tests. It must export a single - * function that takes a [`TestConfig`] argument. + * function that takes a {@link FullConfig} argument. * * Learn more about [global setup and teardown](https://playwright.dev/docs/test-global-setup-teardown). * @@ -1667,15 +1672,15 @@ export interface Config extends TestConfig { +export interface FullConfig { /** * List of resolved projects. */ - projects: ProjectInWorker[]; + projects: FullProject[]; /** * See [testConfig.reporter](https://playwright.dev/docs/api/class-testconfig#test-config-reporter). */ @@ -1685,7 +1690,7 @@ export interface ConfigInWorker { */ webServer: TestConfigWebServer | null; /** - * Path to the configuration file (if any) used to run the tests. + * Path to the configuration file used to run the tests. The value is an empty string if no config file was used. */ configFile?: string; @@ -1759,6 +1764,9 @@ export interface ConfigInWorker { threshold: number; }; + /** + * Base directory for all relative paths used in the reporters. + */ rootDir: string; /** @@ -8129,7 +8137,7 @@ export interface TestInfo { /** * Processed configuration from the [configuration file](https://playwright.dev/docs/test-configuration). */ - config: ConfigInWorker; + config: FullConfig; /** * The number of milliseconds the test took to finish. Always zero before the test finishes, either successfully or @@ -8205,7 +8213,7 @@ export interface TestInfo { /** * Processed project configuration from the [configuration file](https://playwright.dev/docs/test-configuration). */ - project: ProjectInWorker; + project: FullProject; /** * Specifies a unique repeat index when running in "repeat each" mode. This mode is enabled by passing `--repeat-each` @@ -8359,7 +8367,7 @@ export interface WorkerInfo { /** * Processed configuration from the [configuration file](https://playwright.dev/docs/test-configuration). */ - config: ConfigInWorker; + config: FullConfig; /** * The index of the worker between `0` and `workers - 1`. It is guaranteed that workers running at the same time have @@ -8374,7 +8382,7 @@ export interface WorkerInfo { /** * Processed project configuration from the [configuration file](https://playwright.dev/docs/test-configuration). */ - project: ProjectInWorker; + project: FullProject; /** * The unique index of the worker process that is running the test. When a worker is restarted, for example after a diff --git a/packages/playwright/types/testReporter.d.ts b/packages/playwright/types/testReporter.d.ts index 694ba65961..06e762006e 100644 --- a/packages/playwright/types/testReporter.d.ts +++ b/packages/playwright/types/testReporter.d.ts @@ -15,217 +15,8 @@ * limitations under the License. */ -import type { TestStatus, Metadata, PlaywrightTestOptions, PlaywrightWorkerOptions, ReporterDescription, ConfigInWorker } from './test'; -export type { TestStatus } from './test'; - -type UseOptions = Partial & Partial; - -/** - * Resolved configuration passed to - * [reporter.onBegin(config, suite)](https://playwright.dev/docs/api/class-reporter#reporter-on-begin). - */ -export interface FullConfig { - /** - * List of resolved projects. - */ - projects: FullProject[]; - /** - * See [testConfig.reporter](https://playwright.dev/docs/api/class-testconfig#test-config-reporter). - */ - reporter: ReporterDescription[]; - /** - * See [testConfig.webServer](https://playwright.dev/docs/api/class-testconfig#test-config-web-server). - */ - webServer: ConfigInWorker['webServer']; - /** - * Path to the configuration file (if any) used to run the tests. - */ - configFile?: string; - - /** - * See [testConfig.forbidOnly](https://playwright.dev/docs/api/class-testconfig#test-config-forbid-only). - */ - forbidOnly: boolean; - - /** - * See [testConfig.fullyParallel](https://playwright.dev/docs/api/class-testconfig#test-config-fully-parallel). - */ - fullyParallel: boolean; - - /** - * See [testConfig.globalSetup](https://playwright.dev/docs/api/class-testconfig#test-config-global-setup). - */ - globalSetup: null|string; - - /** - * See [testConfig.globalTeardown](https://playwright.dev/docs/api/class-testconfig#test-config-global-teardown). - */ - globalTeardown: null|string; - - /** - * See [testConfig.globalTimeout](https://playwright.dev/docs/api/class-testconfig#test-config-global-timeout). - */ - globalTimeout: number; - - /** - * See [testConfig.grep](https://playwright.dev/docs/api/class-testconfig#test-config-grep). - */ - grep: RegExp|Array; - - /** - * See [testConfig.grepInvert](https://playwright.dev/docs/api/class-testconfig#test-config-grep-invert). - */ - grepInvert: null|RegExp|Array; - - /** - * See [testConfig.maxFailures](https://playwright.dev/docs/api/class-testconfig#test-config-max-failures). - */ - maxFailures: number; - - /** - * See [testConfig.metadata](https://playwright.dev/docs/api/class-testconfig#test-config-metadata). - */ - metadata: Metadata; - - /** - * See [testConfig.preserveOutput](https://playwright.dev/docs/api/class-testconfig#test-config-preserve-output). - */ - preserveOutput: "always"|"never"|"failures-only"; - - /** - * See [testConfig.quiet](https://playwright.dev/docs/api/class-testconfig#test-config-quiet). - */ - quiet: boolean; - - /** - * See [testConfig.reportSlowTests](https://playwright.dev/docs/api/class-testconfig#test-config-report-slow-tests). - */ - reportSlowTests: null|{ - /** - * The maximum number of slow test files to report. Defaults to `5`. - */ - max: number; - - /** - * Test duration in milliseconds that is considered slow. Defaults to 15 seconds. - */ - threshold: number; - }; - - rootDir: string; - - /** - * See [testConfig.shard](https://playwright.dev/docs/api/class-testconfig#test-config-shard). - */ - shard: null|{ - /** - * The total number of shards. - */ - total: number; - - /** - * The index of the shard to execute, one-based. - */ - current: number; - }; - - /** - * See [testConfig.updateSnapshots](https://playwright.dev/docs/api/class-testconfig#test-config-update-snapshots). - */ - updateSnapshots: "all"|"none"|"missing"; - - /** - * Playwright version. - */ - version: string; - - /** - * See [testConfig.workers](https://playwright.dev/docs/api/class-testconfig#test-config-workers). - */ - workers: number; -} - -/** - * Runtime representation of the test project configuration that is passed to {@link Reporter}. It exposes some of the - * resolved fields declared in {@link TestProject}. You can get {@link FullProject} instance from - * [fullConfig.projects](https://playwright.dev/docs/api/class-fullconfig#full-config-projects) or - * [suite.project()](https://playwright.dev/docs/api/class-suite#suite-project). - */ -export interface FullProject { - /** - * See [testProject.use](https://playwright.dev/docs/api/class-testproject#test-project-use). - */ - use: UseOptions; - /** - * See [testProject.dependencies](https://playwright.dev/docs/api/class-testproject#test-project-dependencies). - */ - dependencies: Array; - - /** - * See [testProject.grep](https://playwright.dev/docs/api/class-testproject#test-project-grep). - */ - grep: RegExp|Array; - - /** - * See [testProject.grepInvert](https://playwright.dev/docs/api/class-testproject#test-project-grep-invert). - */ - grepInvert: null|RegExp|Array; - - /** - * See [testProject.metadata](https://playwright.dev/docs/api/class-testproject#test-project-metadata). - */ - metadata: Metadata; - - /** - * See [testProject.name](https://playwright.dev/docs/api/class-testproject#test-project-name). - */ - name: string; - - /** - * See [testProject.outputDir](https://playwright.dev/docs/api/class-testproject#test-project-output-dir). - */ - outputDir: string; - - /** - * See [testProject.repeatEach](https://playwright.dev/docs/api/class-testproject#test-project-repeat-each). - */ - repeatEach: number; - - /** - * See [testProject.retries](https://playwright.dev/docs/api/class-testproject#test-project-retries). - */ - retries: number; - - /** - * See [testProject.snapshotDir](https://playwright.dev/docs/api/class-testproject#test-project-snapshot-dir). - */ - snapshotDir: string; - - /** - * See [testProject.teardown](https://playwright.dev/docs/api/class-testproject#test-project-teardown). - */ - teardown?: string; - - /** - * See [testProject.testDir](https://playwright.dev/docs/api/class-testproject#test-project-test-dir). - */ - testDir: string; - - /** - * See [testProject.testIgnore](https://playwright.dev/docs/api/class-testproject#test-project-test-ignore). - */ - testIgnore: string|RegExp|Array; - - /** - * See [testProject.testMatch](https://playwright.dev/docs/api/class-testproject#test-project-test-match). - */ - testMatch: string|RegExp|Array; - - /** - * See [testProject.timeout](https://playwright.dev/docs/api/class-testproject#test-project-timeout). - */ - timeout: number; -} +import type { TestStatus, Metadata, PlaywrightTestOptions, PlaywrightWorkerOptions, ReporterDescription, FullConfig, FullProject } from './test'; +export type { FullConfig, FullProject, TestStatus } from './test'; /** * Result of the full test run. diff --git a/tests/playwright-test/global-setup.spec.ts b/tests/playwright-test/global-setup.spec.ts index bcb9013387..3d28be82cd 100644 --- a/tests/playwright-test/global-setup.spec.ts +++ b/tests/playwright-test/global-setup.spec.ts @@ -280,8 +280,8 @@ const authFiles = { export default config; `, 'auth.ts': ` - import { chromium, ConfigInWorker } from '@playwright/test'; - async function globalSetup(config: ConfigInWorker) { + import { chromium, FullConfig } from '@playwright/test'; + async function globalSetup(config: FullConfig) { const { baseURL, storageState } = config.projects[0].use; const browser = await chromium.launch(); const page = await browser.newPage(); diff --git a/utils/generate_types/overrides-test.d.ts b/utils/generate_types/overrides-test.d.ts index 9d58db13fe..4907995f3e 100644 --- a/utils/generate_types/overrides-test.d.ts +++ b/utils/generate_types/overrides-test.d.ts @@ -39,7 +39,7 @@ interface TestProject { export interface Project extends TestProject { } -export interface ProjectInWorker { +export interface FullProject { use: UseOptions; } @@ -57,8 +57,8 @@ export interface Config extends TestConfig { - projects: ProjectInWorker[]; +export interface FullConfig { + projects: FullProject[]; reporter: ReporterDescription[]; webServer: TestConfigWebServer | null; } diff --git a/utils/generate_types/overrides-testReporter.d.ts b/utils/generate_types/overrides-testReporter.d.ts index e5bf37cdc8..51eab7e370 100644 --- a/utils/generate_types/overrides-testReporter.d.ts +++ b/utils/generate_types/overrides-testReporter.d.ts @@ -14,20 +14,8 @@ * limitations under the License. */ -import type { TestStatus, Metadata, PlaywrightTestOptions, PlaywrightWorkerOptions, ReporterDescription, ConfigInWorker } from './test'; -export type { TestStatus } from './test'; - -type UseOptions = Partial & Partial; - -export interface FullConfig { - projects: FullProject[]; - reporter: ReporterDescription[]; - webServer: ConfigInWorker['webServer']; -} - -export interface FullProject { - use: UseOptions; -} +import type { TestStatus, Metadata, PlaywrightTestOptions, PlaywrightWorkerOptions, ReporterDescription, FullConfig, FullProject } from './test'; +export type { FullConfig, FullProject, TestStatus } from './test'; /** * Result of the full test run.