diff --git a/packages/playwright/types/test.d.ts b/packages/playwright/types/test.d.ts index f7e486f76c..50e361c9df 100644 --- a/packages/playwright/types/test.d.ts +++ b/packages/playwright/types/test.d.ts @@ -586,7 +586,58 @@ interface TestProject { timeout?: number; } -export type Project = TestProject; +/** + * 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. + * + * `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 + * [configuration file](https://playwright.dev/docs/test-configuration). Note that all properties of {@link TestProject} are available in + * the top-level {@link TestConfig}, in which case they are shared between all projects. + * + * Here is an example configuration that runs every test in Chromium, Firefox and WebKit, both Desktop and Mobile + * versions. + * + * ```js + * // playwright.config.ts + * import { defineConfig, devices } from '@playwright/test'; + * + * export default defineConfig({ + * // Options shared for all projects. + * timeout: 30000, + * use: { + * ignoreHTTPSErrors: true, + * }, + * + * // Options specific to each project. + * projects: [ + * { + * name: 'chromium', + * use: devices['Desktop Chrome'], + * }, + * { + * name: 'firefox', + * use: devices['Desktop Firefox'], + * }, + * { + * name: 'webkit', + * use: devices['Desktop Safari'], + * }, + * { + * name: 'Mobile Chrome', + * use: devices['Pixel 5'], + * }, + * { + * name: 'Mobile Safari', + * use: devices['iPhone 12'], + * }, + * ], + * }); + * ``` + * + */ +export interface Project extends TestProject { +} /** * Runtime representation of the test project configuration that can be accessed in the tests via @@ -1623,7 +1674,30 @@ interface TestConfig { workers?: number|string; } -export type Config = TestConfig; +/** + * 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). + * + * 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 + * TestConfig} can also define base options shared between all projects. + * + * ```js + * // playwright.config.ts + * import { defineConfig } from '@playwright/test'; + * + * export default defineConfig({ + * timeout: 30000, + * globalTimeout: 600000, + * reporter: 'list', + * testDir: './tests', + * }); + * ``` + * + */ +export interface Config extends TestConfig { +} export type Metadata = { [key: string]: any }; diff --git a/utils/generate_types/index.js b/utils/generate_types/index.js index 5af91c2ecb..06863d9c9f 100644 --- a/utils/generate_types/index.js +++ b/utils/generate_types/index.js @@ -552,6 +552,8 @@ class TypesGenerator { ]), overridesToDocsClassMapping: new Map([ ['TestType', 'Test'], + ['Config', 'TestConfig'], + ['Project', 'TestProject'], ['PlaywrightWorkerOptions', 'TestOptions'], ['PlaywrightTestOptions', 'TestOptions'], ['PlaywrightWorkerArgs', 'Fixtures'], diff --git a/utils/generate_types/overrides-test.d.ts b/utils/generate_types/overrides-test.d.ts index 54760a3dca..2d1ba769e6 100644 --- a/utils/generate_types/overrides-test.d.ts +++ b/utils/generate_types/overrides-test.d.ts @@ -35,7 +35,8 @@ interface TestProject { use?: UseOptions; } -export type Project = TestProject; +export interface Project extends TestProject { +} export interface ProjectInWorker { use: UseOptions; @@ -50,7 +51,8 @@ interface TestConfig { webServer?: TestConfigWebServer | TestConfigWebServer[]; } -export type Config = TestConfig; +export interface Config extends TestConfig { +} export type Metadata = { [key: string]: any };