Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: remove internal dep on FullConfig (#13074)
Ross Wollmanae365dda3be2
diff --git a/packages/playwright-test/src/loader.ts b/packages/playwright-test/src/loader.tsindex b2564a188e..4d73224cfd 100644--- a/packages/playwright-test/src/loader.ts+++ b/packages/playwright-test/src/loader.ts@@ -15,7 +15,8 @@*/import { installTransform, setCurrentlyLoadingTestFile } from './transform';-import type { FullConfig, Config, FullProject, Project, ReporterDescription, PreserveOutput } from './types';+import type { Config, FullProject, Project, ReporterDescription, PreserveOutput } from './types';+import type { FullConfigInternal } from './types';import { mergeObjects, errorWithFile } from './util';import { setCurrentlyLoadingFileSuite } from './globals';import { Suite } from './test';@@ -36,7 +37,7 @@ const cachedFileSuites = new Map<string, Suite>();export class Loader {private _defaultConfig: Config;private _configOverrides: Config;- private _fullConfig: FullConfig;+ private _fullConfig: FullConfigInternal;private _configDir: string = '';private _configFile: string | undefined;private _projects: ProjectImpl[] = [];@@ -166,7 +167,7 @@ export class Loader {return suite;}- async loadGlobalHook(file: string, name: string): Promise<(config: FullConfig) => any> {+ async loadGlobalHook(file: string, name: string): Promise<(config: FullConfigInternal) => any> {let hook = await this._requireOrImport(file);if (hook && typeof hook === 'object' && ('default' in hook))hook = hook['default'];@@ -184,7 +185,7 @@ export class Loader {return func;}- fullConfig(): FullConfig {+ fullConfig(): FullConfigInternal {return this._fullConfig;}@@ -451,7 +452,7 @@ function validateProject(file: string, project: Project, title: string) {}}-const baseFullConfig: FullConfig = {+const baseFullConfig: FullConfigInternal = {forbidOnly: false,fullyParallel: false,globalSetup: null,@@ -528,4 +529,3 @@ export function folderIsModule(folder: string): boolean {// Rely on `require` internal caching logic.return require(packageJsonPath).type === 'module';}-diff --git a/packages/playwright-test/src/runner.ts b/packages/playwright-test/src/runner.tsindex 51af2d9d1d..1fa5e0313c 100644--- a/packages/playwright-test/src/runner.ts+++ b/packages/playwright-test/src/runner.ts@@ -36,7 +36,8 @@ import EmptyReporter from './reporters/empty';import HtmlReporter from './reporters/html';import { ProjectImpl } from './project';import { Minimatch } from 'minimatch';-import { Config, FullConfig } from './types';+import { Config } from './types';+import type { FullConfigInternal } from './types';import { WebServer } from './webServer';import { raceAgainstTimeout } from 'playwright-core/lib/utils/async';import { SigIntWatcher } from 'playwright-core/lib/utils/utils';@@ -419,7 +420,7 @@ export class Runner {return result;}- private async _performGlobalSetup(config: FullConfig): Promise<(() => Promise<void>) | undefined> {+ private async _performGlobalSetup(config: FullConfigInternal): Promise<(() => Promise<void>) | undefined> {const result: FullResult = { status: 'passed' };const internalGlobalTeardowns: (() => Promise<void>)[] = [];let globalSetupResult: any;@@ -685,9 +686,9 @@ function createTestGroups(rootSuite: Suite): TestGroup[] {}class ListModeReporter implements Reporter {- private config!: FullConfig;+ private config!: FullConfigInternal;- onBegin(config: FullConfig, suite: Suite): void {+ onBegin(config: FullConfigInternal, suite: Suite): void {this.config = config;// eslint-disable-next-line no-consoleconsole.log(`Listing tests:`);@@ -712,7 +713,7 @@ class ListModeReporter implements Reporter {}}-function createForbidOnlyError(config: FullConfig, onlyTestsAndSuites: (TestCase | Suite)[]): TestError {+function createForbidOnlyError(config: FullConfigInternal, onlyTestsAndSuites: (TestCase | Suite)[]): TestError {const errorMessage = ['=====================================',' --forbid-only found a focused test.',@@ -726,7 +727,7 @@ function createForbidOnlyError(config: FullConfig, onlyTestsAndSuites: (TestCasereturn createStacklessError(errorMessage.join('\n'));}-function createDuplicateTitlesError(config: FullConfig, clashingTests: Map<string, TestCase[]>): TestError {+function createDuplicateTitlesError(config: FullConfigInternal, clashingTests: Map<string, TestCase[]>): TestError {const errorMessage = ['========================================',' duplicate test titles are not allowed.',diff --git a/packages/playwright-test/src/testInfo.ts b/packages/playwright-test/src/testInfo.tsindex 73839717ad..70f668e726 100644--- a/packages/playwright-test/src/testInfo.ts+++ b/packages/playwright-test/src/testInfo.ts@@ -18,7 +18,8 @@ import fs from 'fs';import * as mime from 'mime';import path from 'path';import { calculateSha1 } from 'playwright-core/lib/utils/utils';-import type { FullConfig, FullProject, TestError, TestInfo, TestStatus } from '../types/test';+import type { FullProject, TestError, TestInfo, TestStatus } from '../types/test';+import type { FullConfigInternal } from './types';import { WorkerInitParams } from './ipc';import { Loader } from './loader';import { ProjectImpl } from './project';@@ -43,7 +44,7 @@ export class TestInfoImpl implements TestInfo {readonly workerIndex: number;readonly parallelIndex: number;readonly project: FullProject;- config: FullConfig;+ config: FullConfigInternal;readonly title: string;readonly titlePath: string[];readonly file: string;@@ -298,4 +299,3 @@ export class TestInfoImpl implements TestInfo {class SkipError extends Error {}-diff --git a/packages/playwright-test/src/types.ts b/packages/playwright-test/src/types.tsindex 0e1838fa5a..057f298851 100644--- a/packages/playwright-test/src/types.ts+++ b/packages/playwright-test/src/types.ts@@ -16,6 +16,7 @@import type { Fixtures, TestError } from '../types/test';import type { Location } from '../types/testReporter';+import type { FullConfig as FullConfigPublic } from './types';export * from '../types/test';export { Location } from '../types/testReporter';@@ -33,3 +34,10 @@ export interface TestStepInternal {forceNoParent: boolean;location?: Location;}++/**+ * FullConfigInternal allows the plumbing of configuration details throughout the Test Runner without+ * increasing the surface area of the public API type called FullConfig.+ */+export interface FullConfigInternal extends FullConfigPublic {+}diff --git a/utils/generate_types/index.js b/utils/generate_types/index.jsindex 889d311001..dafdb71523 100644--- a/utils/generate_types/index.js+++ b/utils/generate_types/index.js@@ -81,7 +81,7 @@ class TypesGenerator {const handledClasses = new Set();- const overrides = await parseOverrides(overridesFile, className => {+ let overrides = await parseOverrides(overridesFile, className => {const docClass = this.docClassForName(className, docsOnlyClassMapping);if (!docClass)return '';@@ -116,6 +116,7 @@ class TypesGenerator {playwright.membersArray = playwright.membersArray.filter(member => !['errors', 'devices'].includes(member.name));playwright.index();}+ overrides = overrides.split('\n').filter(l => !l.toLowerCase().includes('[internal]')).join('\n');return [`// This file is generated by ${__filename.substring(path.join(__dirname, '..', '..').length).split(path.sep).join(path.posix.sep)}`,overrides,diff --git a/utils/generate_types/overrides-test.d.ts b/utils/generate_types/overrides-test.d.tsindex 5efff3fff4..4a359e414a 100644--- a/utils/generate_types/overrides-test.d.ts+++ b/utils/generate_types/overrides-test.d.ts@@ -195,6 +195,9 @@ export interface Config<TestArgs = {}, WorkerArgs = {}> extends TestConfig {use?: UseOptions<TestArgs, WorkerArgs>;}+// [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<TestArgs = {}, WorkerArgs = {}> {forbidOnly: boolean;fullyParallel: boolean;@@ -216,6 +219,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {workers: number;webServer: WebServerConfig | null;attachments: { name: string, path?: string, body?: Buffer, contentType: string }[];+ // [internal] !!! DO NOT ADD TO THIS !!! See prior note.}export type TestStatus = 'passed' | 'failed' | 'timedOut' | 'skipped';