diff --git a/docs/src/test-reporter-api/class-reporterconfig.md b/docs/src/test-api/class-configinworker.md similarity index 69% rename from docs/src/test-reporter-api/class-reporterconfig.md rename to docs/src/test-api/class-configinworker.md index edaa91dd7d..5832dca885 100644 --- a/docs/src/test-reporter-api/class-reporterconfig.md +++ b/docs/src/test-api/class-configinworker.md @@ -1,88 +1,88 @@ -# class: ReporterConfig +# class: ConfigInWorker * since: v1.10 * langs: js -Resolved configuration passed to [`method: Reporter.onBegin`]. +Resolved configuration available via [`property: TestInfo.config`] and [`property: WorkerInfo.config`]. -## property: ReporterConfig.configFile +## property: ConfigInWorker.configFile * since: v1.20 - type: ?<[string]> Path to the configuration file (if any) used to run the tests. -## property: ReporterConfig.forbidOnly +## property: ConfigInWorker.forbidOnly * since: v1.10 - type: <[boolean]> See [`property: TestConfig.forbidOnly`]. -## property: ReporterConfig.fullyParallel +## property: ConfigInWorker.fullyParallel * since: v1.20 - type: <[boolean]> See [`property: TestConfig.fullyParallel`]. -## property: ReporterConfig.globalSetup +## property: ConfigInWorker.globalSetup * since: v1.10 - type: <[null]|[string]> See [`property: TestConfig.globalSetup`]. -## property: ReporterConfig.globalTeardown +## property: ConfigInWorker.globalTeardown * since: v1.10 - type: <[null]|[string]> See [`property: TestConfig.globalTeardown`]. -## property: ReporterConfig.globalTimeout +## property: ConfigInWorker.globalTimeout * since: v1.10 - type: <[int]> See [`property: TestConfig.globalTimeout`]. -## property: ReporterConfig.grep +## property: ConfigInWorker.grep * since: v1.10 - type: <[RegExp]|[Array]<[RegExp]>> See [`property: TestConfig.grep`]. -## property: ReporterConfig.grepInvert +## property: ConfigInWorker.grepInvert * since: v1.10 - type: <[null]|[RegExp]|[Array]<[RegExp]>> See [`property: TestConfig.grepInvert`]. -## property: ReporterConfig.maxFailures +## property: ConfigInWorker.maxFailures * since: v1.10 - type: <[int]> See [`property: TestConfig.maxFailures`]. -## property: ReporterConfig.metadata +## property: ConfigInWorker.metadata * since: v1.10 - type: <[Metadata]> See [`property: TestConfig.metadata`]. -## property: ReporterConfig.preserveOutput +## property: ConfigInWorker.preserveOutput * since: v1.10 - type: <[PreserveOutput]<"always"|"never"|"failures-only">> See [`property: TestConfig.preserveOutput`]. -## property: ReporterConfig.projects +## property: ConfigInWorker.projects * since: v1.10 -- type: <[Array]<[ReporterProject]>> +- type: <[Array]<[ProjectInWorker]>> List of resolved projects. -## property: ReporterConfig.quiet +## property: ConfigInWorker.quiet * since: v1.10 - type: <[boolean]> See [`property: TestConfig.quiet`]. -## property: ReporterConfig.reporter +## 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 @@ -90,7 +90,7 @@ See [`property: TestConfig.quiet`]. See [`property: TestConfig.reporter`]. -## property: ReporterConfig.reportSlowTests +## property: ConfigInWorker.reportSlowTests * since: v1.10 - type: <[null]|[Object]> - `max` <[int]> The maximum number of slow test files to report. Defaults to `5`. @@ -98,11 +98,11 @@ See [`property: TestConfig.reporter`]. See [`property: TestConfig.reportSlowTests`]. -## property: ReporterConfig.rootDir +## property: ConfigInWorker.rootDir * since: v1.20 - type: <[string]> -## property: ReporterConfig.shard +## property: ConfigInWorker.shard * since: v1.10 - type: <[null]|[Object]> - `total` <[int]> The total number of shards. @@ -110,25 +110,25 @@ See [`property: TestConfig.reportSlowTests`]. See [`property: TestConfig.shard`]. -## property: ReporterConfig.updateSnapshots +## property: ConfigInWorker.updateSnapshots * since: v1.10 - type: <[UpdateSnapshots]<"all"|"none"|"missing">> See [`property: TestConfig.updateSnapshots`]. -## property: ReporterConfig.version +## property: ConfigInWorker.version * since: v1.20 - type: <[string]> Playwright version. -## property: ReporterConfig.webServer +## property: ConfigInWorker.webServer * since: v1.10 - type: <[null]|[Object]> See [`property: TestConfig.webServer`]. -## property: ReporterConfig.workers +## property: ConfigInWorker.workers * since: v1.10 - type: <[int]> diff --git a/docs/src/test-reporter-api/class-reporterproject.md b/docs/src/test-api/class-projectinworker.md similarity index 59% rename from docs/src/test-reporter-api/class-reporterproject.md rename to docs/src/test-api/class-projectinworker.md index b851e04160..c8ede102ba 100644 --- a/docs/src/test-reporter-api/class-reporterproject.md +++ b/docs/src/test-api/class-projectinworker.md @@ -1,97 +1,95 @@ -# class: ReporterProject +# class: ProjectInWorker * 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 [ReporterProject] instance from [`property: ReporterConfig.projects`] -or [`method: Suite.project`]. +Runtime representation of the test project configuration that can be accessed +in the tests via [`property: TestInfo.project`] and [`property: WorkerInfo.project`]. -## property: ReporterProject.dependencies +## property: ProjectInWorker.dependencies * since: v1.31 - type: <[Array]<[string]>> See [`property: TestProject.dependencies`]. -## property: ReporterProject.grep +## property: ProjectInWorker.grep * since: v1.10 - type: <[RegExp]|[Array]<[RegExp]>> See [`property: TestProject.grep`]. -## property: ReporterProject.grepInvert +## property: ProjectInWorker.grepInvert * since: v1.10 - type: <[null]|[RegExp]|[Array]<[RegExp]>> See [`property: TestProject.grepInvert`]. -## property: ReporterProject.metadata +## property: ProjectInWorker.metadata * since: v1.10 - type: <[Metadata]> See [`property: TestProject.metadata`]. -## property: ReporterProject.name +## property: ProjectInWorker.name * since: v1.10 - type: <[string]> See [`property: TestProject.name`]. -## property: ReporterProject.snapshotDir +## property: ProjectInWorker.snapshotDir * since: v1.10 - type: <[string]> See [`property: TestProject.snapshotDir`]. -## property: ReporterProject.outputDir +## property: ProjectInWorker.outputDir * since: v1.10 - type: <[string]> See [`property: TestProject.outputDir`]. -## property: ReporterProject.repeatEach +## property: ProjectInWorker.repeatEach * since: v1.10 - type: <[int]> See [`property: TestProject.repeatEach`]. -## property: ReporterProject.retries +## property: ProjectInWorker.retries * since: v1.10 - type: <[int]> See [`property: TestProject.retries`]. -## property: ReporterProject.teardown +## property: ProjectInWorker.teardown * since: v1.34 - type: ?<[string]> See [`property: TestProject.teardown`]. -## property: ReporterProject.testDir +## property: ProjectInWorker.testDir * since: v1.10 - type: <[string]> See [`property: TestProject.testDir`]. -## property: ReporterProject.testIgnore +## property: ProjectInWorker.testIgnore * since: v1.10 - type: <[string]|[RegExp]|[Array]<[string]|[RegExp]>> See [`property: TestProject.testIgnore`]. -## property: ReporterProject.testMatch +## property: ProjectInWorker.testMatch * since: v1.10 - type: <[string]|[RegExp]|[Array]<[string]|[RegExp]>> See [`property: TestProject.testMatch`]. -## property: ReporterProject.timeout +## property: ProjectInWorker.timeout * since: v1.10 - type: <[int]> See [`property: TestProject.timeout`]. -## property: ReporterProject.use +## property: ProjectInWorker.use * since: v1.10 - type: <[Fixtures]> diff --git a/docs/src/test-api/class-testinfo.md b/docs/src/test-api/class-testinfo.md index cbc125b3bf..096fbfcc10 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: <[FullConfig]> +- type: <[ConfigInWorker]> 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: <[FullProject]> +- type: <[ProjectInWorker]> Processed project configuration from the [configuration file](../test-configuration.md). diff --git a/docs/src/test-api/class-workerinfo.md b/docs/src/test-api/class-workerinfo.md index 5213ed96e1..e7ae892190 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: <[TestConfig]> +- type: <[ConfigInWorker]> 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: <[FullProject]> +- type: <[ProjectInWorker]> Processed project configuration from the [configuration file](../test-configuration.md). diff --git a/docs/src/test-api/class-fullconfig.md b/docs/src/test-reporter-api/class-fullconfig.md similarity index 97% rename from docs/src/test-api/class-fullconfig.md rename to docs/src/test-reporter-api/class-fullconfig.md index a60d92c610..ce4318560f 100644 --- a/docs/src/test-api/class-fullconfig.md +++ b/docs/src/test-reporter-api/class-fullconfig.md @@ -2,7 +2,7 @@ * since: v1.10 * langs: js -Resolved configuration available as [`property: TestInfo.config`]. +Resolved configuration passed to [`method: Reporter.onBegin`]. ## property: FullConfig.configFile * since: v1.20 diff --git a/docs/src/test-api/class-fullproject.md b/docs/src/test-reporter-api/class-fullproject.md similarity index 87% rename from docs/src/test-api/class-fullproject.md rename to docs/src/test-reporter-api/class-fullproject.md index 4ec6ec5ea7..9a744115df 100644 --- a/docs/src/test-api/class-fullproject.md +++ b/docs/src/test-reporter-api/class-fullproject.md @@ -2,8 +2,10 @@ * 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`]. +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`]. ## property: FullProject.dependencies * since: v1.31 diff --git a/docs/src/test-reporter-api/class-reporter.md b/docs/src/test-reporter-api/class-reporter.md index f71d492835..48ed098b7d 100644 --- a/docs/src/test-reporter-api/class-reporter.md +++ b/docs/src/test-reporter-api/class-reporter.md @@ -37,7 +37,7 @@ module.exports = MyReporter; ```js tab=js-ts title="my-awesome-reporter.ts" import type { - Reporter, ReporterConfig, Suite, TestCase, TestResult, FullResult + Reporter, FullConfig, Suite, TestCase, TestResult, FullResult } from '@playwright/test/reporter'; class MyReporter implements Reporter { @@ -45,7 +45,7 @@ class MyReporter implements Reporter { console.log(`my-awesome-reporter setup with customOption set to ${options.customOption}`); } - onBegin(config: ReporterConfig, suite: Suite) { + onBegin(config: FullConfig, suite: Suite) { console.log(`Starting the run with ${suite.allTests().length} tests`); } @@ -94,7 +94,7 @@ Called once before running tests. All tests have been already discovered and put ### param: Reporter.onBegin.config * since: v1.10 -- `config` <[ReporterConfig]> +- `config` <[FullConfig]> Resolved configuration. diff --git a/packages/playwright-ct-core/src/cliOverrides.ts b/packages/playwright-ct-core/src/cliOverrides.ts index 3ebcd09cbc..5aa0f6c640 100644 --- a/packages/playwright-ct-core/src/cliOverrides.ts +++ b/packages/playwright-ct-core/src/cliOverrides.ts @@ -20,16 +20,16 @@ import { affectedTestFiles, cacheDir } from 'playwright/lib/transform/compilatio import { buildBundle } from './vitePlugin'; import { resolveDirs } from './viteUtils'; import type { Suite } from 'playwright/lib/common/test'; -import type { FullConfig } from 'playwright/test'; +import type { ConfigInWorker } from 'playwright/test'; -export async function clearCacheCommand(config: FullConfig, configDir: string) { +export async function clearCacheCommand(config: ConfigInWorker, configDir: string) { const dirs = await resolveDirs(configDir, config); if (dirs) await removeFolder(dirs.outDir); await removeFolder(cacheDir); } -export async function findRelatedTestFilesCommand(files: string[], config: FullConfig, configDir: string, suite: Suite) { +export async function findRelatedTestFilesCommand(files: string[], config: ConfigInWorker, configDir: string, suite: Suite) { await buildBundle(config, configDir, suite); return { testFiles: affectedTestFiles(files) }; } diff --git a/packages/playwright-ct-core/src/vitePlugin.ts b/packages/playwright-ct-core/src/vitePlugin.ts index cc26fdc807..43dc0f90ca 100644 --- a/packages/playwright-ct-core/src/vitePlugin.ts +++ b/packages/playwright-ct-core/src/vitePlugin.ts @@ -22,7 +22,7 @@ import { assert, calculateSha1, getPlaywrightVersion, isURLAvailable } from 'pla import { debug } from 'playwright-core/lib/utilsBundle'; import { internalDependenciesForTestFile, setExternalDependencies } from 'playwright/lib/transform/compilationCache'; import { stoppable } from 'playwright/lib/utilsBundle'; -import type { FullConfig } from 'playwright/test'; +import type { ConfigInWorker } from 'playwright/test'; import type { Suite } from 'playwright/types/testReporter'; import type { PluginContext } from 'rollup'; import type { Plugin, ResolveFn, ResolvedConfig } from 'vite'; @@ -40,11 +40,11 @@ const playwrightVersion = getPlaywrightVersion(); export function createPlugin(): TestRunnerPlugin { let configDir: string; - let config: FullConfig; + let config: ConfigInWorker; return { name: 'playwright-vite-plugin', - setup: async (configObject: FullConfig, configDirectory: string) => { + setup: async (configObject: ConfigInWorker, configDirectory: string) => { config = configObject; configDir = configDirectory; }, @@ -88,7 +88,7 @@ type BuildInfo = { } }; -export async function buildBundle(config: FullConfig, configDir: string, suite: Suite): Promise<{ buildInfo: BuildInfo, viteConfig: Record } | null> { +export async function buildBundle(config: ConfigInWorker, configDir: string, suite: Suite): Promise<{ buildInfo: BuildInfo, viteConfig: Record } | null> { const { registerSourceFile, frameworkPluginFactory } = frameworkConfig(config); { // Detect a running dev server and use it if available. diff --git a/packages/playwright-ct-core/src/viteUtils.ts b/packages/playwright-ct-core/src/viteUtils.ts index 00da627432..840816c648 100644 --- a/packages/playwright-ct-core/src/viteUtils.ts +++ b/packages/playwright-ct-core/src/viteUtils.ts @@ -18,7 +18,7 @@ import fs from 'fs'; import path from 'path'; import { debug } from 'playwright-core/lib/utilsBundle'; import { getUserData } from 'playwright/lib/transform/compilationCache'; -import type { PlaywrightTestConfig as BasePlaywrightTestConfig, FullConfig } from 'playwright/test'; +import type { PlaywrightTestConfig as BasePlaywrightTestConfig, ConfigInWorker } from 'playwright/test'; import type { InlineConfig, Plugin, TransformResult, UserConfig } from 'vite'; import type { ImportInfo } from './tsxTransform'; import { resolveHook } from 'playwright/lib/transform/transform'; @@ -39,7 +39,7 @@ export type ComponentDirs = { templateDir: string; }; -export async function resolveDirs(configDir: string, config: FullConfig): Promise { +export async function resolveDirs(configDir: string, config: ConfigInWorker): Promise { const use = config.projects[0].use as CtConfig; // FIXME: use build plugin to determine html location to resolve this. // TemplateDir must be relative, otherwise we can't move the final index.html into its target location post-build. @@ -56,7 +56,7 @@ export async function resolveDirs(configDir: string, config: FullConfig): Promis }; } -export function resolveEndpoint(config: FullConfig) { +export function resolveEndpoint(config: ConfigInWorker) { const use = config.projects[0].use as CtConfig; const baseURL = new URL(use.baseURL || 'http://localhost'); return { @@ -66,7 +66,7 @@ export function resolveEndpoint(config: FullConfig) { }; } -export async function createConfig(dirs: ComponentDirs, config: FullConfig, frameworkPluginFactory: (() => Promise) | undefined, supportJsxInJs: boolean) { +export async function createConfig(dirs: ComponentDirs, config: ConfigInWorker, frameworkPluginFactory: (() => Promise) | undefined, supportJsxInJs: boolean) { // We are going to have 3 config files: // - the defaults that user config overrides (baseConfig) // - the user config (userConfig) @@ -193,6 +193,6 @@ export function transformIndexFile(id: string, content: string, templateDir: str }; } -export function frameworkConfig(config: FullConfig): { registerSourceFile: string, frameworkPluginFactory?: () => Promise } { +export function frameworkConfig(config: ConfigInWorker): { registerSourceFile: string, frameworkPluginFactory?: () => Promise } { return (config as any)['@playwright/experimental-ct-core']; } diff --git a/packages/playwright/src/common/config.ts b/packages/playwright/src/common/config.ts index 1f66927998..3237b71284 100644 --- a/packages/playwright/src/common/config.ts +++ b/packages/playwright/src/common/config.ts @@ -23,7 +23,7 @@ import type { TestRunnerPluginRegistration } from '../plugins'; import { getPackageJsonPath, mergeObjects } from '../util'; import type { Matcher } from '../util'; import type { ConfigCLIOverrides } from './ipc'; -import type { FullConfig, FullProject } from '../../types/test'; +import type { ConfigInWorker, ProjectInWorker } from '../../types/test'; import { setTransformConfig } from '../transform/transform'; export type ConfigLocation = { @@ -40,13 +40,13 @@ export type Annotation = { type: string, description?: string }; export const defaultTimeout = 30000; export class FullConfigInternal { - readonly config: FullConfig; + readonly config: ConfigInWorker; readonly globalOutputDir: string; readonly configDir: string; readonly configCLIOverrides: ConfigCLIOverrides; readonly ignoreSnapshots: boolean; readonly preserveOutputDir: boolean; - readonly webServers: Exclude[]; + readonly webServers: Exclude[]; readonly plugins: TestRunnerPluginRegistration[]; readonly projects: FullProjectInternal[] = []; cliArgs: string[] = []; @@ -119,7 +119,7 @@ export class FullConfigInternal { const webServers = takeFirst(userConfig.webServer, null); if (Array.isArray(webServers)) { // multiple web server mode - // Due to previous choices, this value shows up to the user in globalSetup as part of FullConfig. Arrays are not supported by the old type. + // Due to previous choices, this value shows up to the user in globalSetup as part of ConfigInWorker. Arrays are not supported by the old type. this.config.webServer = null; this.webServers = webServers; } else if (webServers) { // legacy singleton mode @@ -158,7 +158,7 @@ export class FullConfigInternal { } export class FullProjectInternal { - readonly project: FullProject; + readonly project: ProjectInWorker; readonly fullConfig: FullConfigInternal; readonly fullyParallel: boolean; readonly expect: Project['expect']; @@ -286,6 +286,6 @@ export const defaultReporter = process.env.CI ? 'dot' : 'list'; const configInternalSymbol = Symbol('configInternalSymbol'); -export function getProjectId(project: FullProject): string { +export function getProjectId(project: ProjectInWorker): string { return (project as any).__projectId!; } \ No newline at end of file diff --git a/packages/playwright/src/common/test.ts b/packages/playwright/src/common/test.ts index 50f547b6ee..21cdb55d9c 100644 --- a/packages/playwright/src/common/test.ts +++ b/packages/playwright/src/common/test.ts @@ -19,7 +19,7 @@ import type * as reporterTypes from '../../types/testReporter'; import type { TestTypeImpl } from './testType'; import { rootTestType } from './testType'; import type { Annotation, FixturesWithLocation, FullProjectInternal } from './config'; -import type { FullProject } from '../../types/test'; +import type { ProjectInWorker } from '../../types/test'; import type { Location } from '../../types/testReporter'; class Base { @@ -238,7 +238,7 @@ export class Suite extends Base { return suite; } - project(): FullProject | undefined { + project(): ProjectInWorker | undefined { return this._fullProject?.project || this.parent?.project(); } } diff --git a/packages/playwright/src/isomorphic/teleReceiver.ts b/packages/playwright/src/isomorphic/teleReceiver.ts index 879d37e010..57b1376e9b 100644 --- a/packages/playwright/src/isomorphic/teleReceiver.ts +++ b/packages/playwright/src/isomorphic/teleReceiver.ts @@ -15,7 +15,7 @@ */ import type { Annotation } from '../common/config'; -import type { FullProject, Metadata } from '../../types/test'; +import type { ProjectInWorker, Metadata } from '../../types/test'; import type * as reporterTypes from '../../types/testReporter'; import type { ReporterV2 } from '../reporters/reporterV2'; @@ -590,7 +590,7 @@ class TeleTestResult implements reporterTypes.TestResult { } } -export type TeleFullProject = FullProject; +export type TeleFullProject = ProjectInWorker; export const baseFullConfig: reporterTypes.FullConfig = { forbidOnly: false, diff --git a/packages/playwright/src/worker/testInfo.ts b/packages/playwright/src/worker/testInfo.ts index 3e0dab8b95..cb3d352f40 100644 --- a/packages/playwright/src/worker/testInfo.ts +++ b/packages/playwright/src/worker/testInfo.ts @@ -17,7 +17,7 @@ import fs from 'fs'; import path from 'path'; import { captureRawStack, monotonicTime, zones, sanitizeForFilePath, stringifyStackFrames } from 'playwright-core/lib/utils'; -import type { TestInfoError, TestInfo, TestStatus, FullProject, FullConfig } from '../../types/test'; +import type { TestInfoError, TestInfo, TestStatus, ProjectInWorker, ConfigInWorker } from '../../types/test'; import type { AttachmentPayload, StepBeginPayload, StepEndPayload, WorkerInitParams } from '../common/ipc'; import type { TestCase } from '../common/test'; import { TimeoutManager, TimeoutManagerError, kMaxDeadline } from './timeoutManager'; @@ -81,8 +81,8 @@ export class TestInfoImpl implements TestInfo { readonly retry: number; readonly workerIndex: number; readonly parallelIndex: number; - readonly project: FullProject; - readonly config: FullConfig; + readonly project: ProjectInWorker; + readonly config: ConfigInWorker; 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 84cd68032f..ae59ca6dd3 100644 --- a/packages/playwright/types/test.d.ts +++ b/packages/playwright/types/test.d.ts @@ -115,7 +115,7 @@ export interface Project extends TestProject { * [testInfo.project](https://playwright.dev/docs/api/class-testinfo#test-info-project) and * [workerInfo.project](https://playwright.dev/docs/api/class-workerinfo#worker-info-project). */ -export interface FullProject { +export interface ProjectInWorker { /** * See [testProject.grep](https://playwright.dev/docs/api/class-testproject#test-project-grep). */ @@ -1181,10 +1181,11 @@ export interface Config extends TestConfig { export type Metadata = { [key: string]: any }; /** - * Resolved configuration available as - * [testInfo.config](https://playwright.dev/docs/api/class-testinfo#test-info-config). + * Resolved configuration available via + * [testInfo.config](https://playwright.dev/docs/api/class-testinfo#test-info-config) and + * [workerInfo.config](https://playwright.dev/docs/api/class-workerinfo#worker-info-config). */ -export interface FullConfig { +export interface ConfigInWorker { /** * See [testConfig.forbidOnly](https://playwright.dev/docs/api/class-testconfig#test-config-forbid-only). */ @@ -1232,7 +1233,7 @@ export interface FullConfig { /** * List of resolved projects. */ - projects: FullProject[]; + projects: ProjectInWorker[]; /** * See [testConfig.reporter](https://playwright.dev/docs/api/class-testconfig#test-config-reporter). */ @@ -1279,11 +1280,11 @@ export interface WorkerInfo { /** * Processed configuration from the [configuration file](https://playwright.dev/docs/test-configuration). */ - config: FullConfig; + config: ConfigInWorker; /** * Processed project configuration from the [configuration file](https://playwright.dev/docs/test-configuration). */ - project: FullProject; + project: ProjectInWorker; /** * The index of the worker between `0` and `workers - 1`. It is guaranteed that workers running at the same time have * a different `parallelIndex`. When a worker is restarted, for example after a failure, the new worker process has @@ -1327,11 +1328,11 @@ export interface TestInfo { /** * Processed configuration from the [configuration file](https://playwright.dev/docs/test-configuration). */ - config: FullConfig; + config: ConfigInWorker; /** * Processed project configuration from the [configuration file](https://playwright.dev/docs/test-configuration). */ - project: FullProject; + project: ProjectInWorker; /** * Attach a value or a file from disk to the current test. Some reporters show test attachments. Either `path` or * `body` must be specified, but not both. diff --git a/packages/playwright/types/testReporter.d.ts b/packages/playwright/types/testReporter.d.ts index 8e9bdecb7d..7b5b81fa04 100644 --- a/packages/playwright/types/testReporter.d.ts +++ b/packages/playwright/types/testReporter.d.ts @@ -15,96 +15,174 @@ * limitations under the License. */ -import type { FullConfig, FullProject, TestStatus, Metadata, PlaywrightTestOptions, PlaywrightWorkerOptions } from './test'; -export type { FullConfig, TestStatus, FullProject } from './test'; +import type { TestStatus, Metadata, PlaywrightTestOptions, PlaywrightWorkerOptions, ReporterDescription } 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 { + /** + * 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: string | null; + /** + * See [testConfig.globalTeardown](https://playwright.dev/docs/api/class-testconfig#test-config-global-teardown). + */ + globalTeardown: string | null; + /** + * 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 | RegExp[]; + /** + * See [testConfig.grepInvert](https://playwright.dev/docs/api/class-testconfig#test-config-grep-invert). + */ + grepInvert: RegExp | RegExp[] | null; + /** + * 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; + /** + * Playwright version. + */ + version: string; + /** + * See [testConfig.preserveOutput](https://playwright.dev/docs/api/class-testconfig#test-config-preserve-output). + */ + preserveOutput: 'always' | 'never' | 'failures-only'; + /** + * List of resolved projects. + */ + projects: FullProject[]; + /** + * See [testConfig.reporter](https://playwright.dev/docs/api/class-testconfig#test-config-reporter). + */ + reporter: ReporterDescription[]; + /** + * See [testConfig.reportSlowTests](https://playwright.dev/docs/api/class-testconfig#test-config-report-slow-tests). + */ + reportSlowTests: { max: number, threshold: number } | null; + rootDir: string; + /** + * See [testConfig.quiet](https://playwright.dev/docs/api/class-testconfig#test-config-quiet). + */ + quiet: boolean; + /** + * See [testConfig.shard](https://playwright.dev/docs/api/class-testconfig#test-config-shard). + */ + shard: { total: number, current: number } | null; + /** + * See [testConfig.updateSnapshots](https://playwright.dev/docs/api/class-testconfig#test-config-update-snapshots). + */ + updateSnapshots: 'all' | 'none' | 'missing'; + /** + * See [testConfig.workers](https://playwright.dev/docs/api/class-testconfig#test-config-workers). + */ + workers: number; + /** + * See [testConfig.webServer](https://playwright.dev/docs/api/class-testconfig#test-config-web-server). + */ + webServer: TestConfigWebServer | null; + /** + * Path to the configuration file (if any) used to run the tests. + */ + configFile?: string; + +} + + /** * 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 ReporterProject} instance from - * [reporterConfig.projects](https://playwright.dev/docs/api/class-reporterconfig#reporter-config-projects) or + * 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 ReporterProject { - /** - * 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; - +export interface FullProject { /** * See [testProject.grep](https://playwright.dev/docs/api/class-testproject#test-project-grep). */ - grep: RegExp|Array; - + grep: RegExp | RegExp[]; /** * See [testProject.grepInvert](https://playwright.dev/docs/api/class-testproject#test-project-grep-invert). */ - grepInvert: null|RegExp|Array; - + grepInvert: RegExp | RegExp[] | null; /** * 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). + * See [testProject.dependencies](https://playwright.dev/docs/api/class-testproject#test-project-dependencies). */ - 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; - + dependencies: string[]; /** * See [testProject.snapshotDir](https://playwright.dev/docs/api/class-testproject#test-project-snapshot-dir). */ snapshotDir: 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.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; - + testIgnore: string | RegExp | (string | RegExp)[]; /** * See [testProject.testMatch](https://playwright.dev/docs/api/class-testproject#test-project-test-match). */ - testMatch: string|RegExp|Array; - + testMatch: string | RegExp | (string | RegExp)[]; /** * See [testProject.timeout](https://playwright.dev/docs/api/class-testproject#test-project-timeout). */ timeout: number; + /** + * See [testProject.use](https://playwright.dev/docs/api/class-testproject#test-project-use). + */ + use: UseOptions; + } /** * `Suite` is a group of tests. All tests in Playwright Test form the following hierarchy: - * - Root suite has a child suite for each {@link ReporterProject}. + * - Root suite has a child suite for each [ReporterProject]. * - Project suite #1. Has a child suite for each test file in the project. * - File suite #1 * - {@link TestCase} #1 @@ -453,7 +531,7 @@ export interface FullResult { * ```js * // my-awesome-reporter.ts * import type { - * Reporter, ReporterConfig, Suite, TestCase, TestResult, FullResult + * Reporter, FullConfig, Suite, TestCase, TestResult, FullResult * } from '@playwright/test/reporter'; * * class MyReporter implements Reporter { @@ -461,7 +539,7 @@ export interface FullResult { * console.log(`my-awesome-reporter setup with customOption set to ${options.customOption}`); * } * - * onBegin(config: ReporterConfig, suite: Suite) { + * onBegin(config: FullConfig, suite: Suite) { * console.log(`Starting the run with ${suite.allTests().length} tests`); * } * @@ -728,144 +806,6 @@ export interface Location { line: number; } -/** - * Resolved configuration passed to - * [reporter.onBegin(config, suite)](https://playwright.dev/docs/api/class-reporter#reporter-on-begin). - */ -export interface ReporterConfig { - /** - * 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"; - - /** - * List of resolved projects. - */ - projects: Array; - - /** - * See [testConfig.quiet](https://playwright.dev/docs/api/class-testconfig#test-config-quiet). - */ - quiet: boolean; - - /** - * See [testConfig.reporter](https://playwright.dev/docs/api/class-testconfig#test-config-reporter). - */ - reporter: string|Array<{ - /** - * Reporter name or module or file path - */ - 0: string; - - /** - * An object with reporter options if any - */ - 1: Object; - }>|"list"|"dot"|"line"|"github"|"json"|"junit"|"null"|"html"; - - /** - * 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.webServer](https://playwright.dev/docs/api/class-testconfig#test-config-web-server). - */ - webServer: null|Object; - - /** - * See [testConfig.workers](https://playwright.dev/docs/api/class-testconfig#test-config-workers). - */ - workers: number; -} - /** * Information about an error thrown during test execution. */ diff --git a/utils/generate_types/index.js b/utils/generate_types/index.js index 36e1416659..06863d9c9f 100644 --- a/utils/generate_types/index.js +++ b/utils/generate_types/index.js @@ -561,9 +561,6 @@ class TypesGenerator { ['AsymmetricMatchers', 'GenericAssertions'], ]), ignoreMissing: new Set([ - 'FullConfig.configFile', - 'FullConfig.version', - 'FullConfig.rootDir', 'SuiteFunction', 'TestFunction', 'PlaywrightWorkerOptions.defaultBrowserType', diff --git a/utils/generate_types/overrides-test.d.ts b/utils/generate_types/overrides-test.d.ts index d0de1d5cf6..860461fc61 100644 --- a/utils/generate_types/overrides-test.d.ts +++ b/utils/generate_types/overrides-test.d.ts @@ -38,7 +38,7 @@ export interface Project extends TestProject { // [internal] !!! DO NOT ADD TO THIS !!! // [internal] It is part of the public API and is computed from the user's config. // [internal] If you need new fields internally, add them to FullProjectInternal instead. -export interface FullProject { +export interface ProjectInWorker { grep: RegExp | RegExp[]; grepInvert: RegExp | RegExp[] | null; metadata: Metadata; @@ -74,7 +74,7 @@ export type Metadata = { [key: string]: any }; // [internal] !!! DO NOT ADD TO THIS !!! // [internal] It is part of the public API and is computed from the user's config. // [internal] If you need new fields internally, add them to FullConfigInternal instead. -export interface FullConfig { +export interface ConfigInWorker { forbidOnly: boolean; fullyParallel: boolean; globalSetup: string | null; @@ -86,7 +86,7 @@ export interface FullConfig { metadata: Metadata; version: string; preserveOutput: 'always' | 'never' | 'failures-only'; - projects: FullProject[]; + projects: ProjectInWorker[]; reporter: ReporterDescription[]; reportSlowTests: { max: number, threshold: number } | null; rootDir: string; @@ -102,13 +102,13 @@ export interface FullConfig { export type TestStatus = 'passed' | 'failed' | 'timedOut' | 'skipped' | 'interrupted'; export interface WorkerInfo { - config: FullConfig; - project: FullProject; + config: ConfigInWorker; + project: ProjectInWorker; } export interface TestInfo { - config: FullConfig; - project: FullProject; + config: ConfigInWorker; + project: ProjectInWorker; } type TestDetailsAnnotation = { diff --git a/utils/generate_types/overrides-testReporter.d.ts b/utils/generate_types/overrides-testReporter.d.ts index 43cd2d5708..8c6eb0a5e8 100644 --- a/utils/generate_types/overrides-testReporter.d.ts +++ b/utils/generate_types/overrides-testReporter.d.ts @@ -14,14 +14,61 @@ * limitations under the License. */ -import type { FullConfig, FullProject, TestStatus, Metadata, PlaywrightTestOptions, PlaywrightWorkerOptions } from './test'; -export type { FullConfig, TestStatus, FullProject } from './test'; +import type { TestStatus, Metadata, PlaywrightTestOptions, PlaywrightWorkerOptions, ReporterDescription } from './test'; +export type { TestStatus } from './test'; type UseOptions = Partial & Partial; -export interface ReporterProject { +// [internal] !!! DO NOT ADD TO THIS !!! +// [internal] It is part of the public API and is computed from the user's config. +// [internal] If you need new fields internally, add them to FullConfigInternal instead. +export interface FullConfig { + forbidOnly: boolean; + fullyParallel: boolean; + globalSetup: string | null; + globalTeardown: string | null; + globalTimeout: number; + grep: RegExp | RegExp[]; + grepInvert: RegExp | RegExp[] | null; + maxFailures: number; + metadata: Metadata; + version: string; + preserveOutput: 'always' | 'never' | 'failures-only'; + projects: FullProject[]; + reporter: ReporterDescription[]; + reportSlowTests: { max: number, threshold: number } | null; + rootDir: string; + quiet: boolean; + shard: { total: number, current: number } | null; + updateSnapshots: 'all' | 'none' | 'missing'; + workers: number; + webServer: TestConfigWebServer | null; + configFile?: string; +} +// [internal] !!! DO NOT ADD TO THIS !!! See prior note. + + +// [internal] !!! DO NOT ADD TO THIS !!! +// [internal] It is part of the public API and is computed from the user's config. +// [internal] If you need new fields internally, add them to FullProjectInternal instead. +export interface FullProject { + grep: RegExp | RegExp[]; + grepInvert: RegExp | RegExp[] | null; + metadata: Metadata; + name: string; + dependencies: string[]; + snapshotDir: string; + outputDir: string; + repeatEach: number; + retries: number; + teardown?: string; + testDir: string; + testIgnore: string | RegExp | (string | RegExp)[]; + testMatch: string | RegExp | (string | RegExp)[]; + timeout: number; use: UseOptions; } +// [internal] !!! DO NOT ADD TO THIS !!! See prior note. export interface Suite { type: 'root' | 'project' | 'file' | 'describe';