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: move private fields to FullConfigInternal (#13261)
Dmitry Gozmanf6936c046111
diff --git a/packages/playwright-test/src/loader.ts b/packages/playwright-test/src/loader.tsindex 2786903c33..7a51a56868 100644--- a/packages/playwright-test/src/loader.ts+++ b/packages/playwright-test/src/loader.ts@@ -99,7 +99,7 @@ export class Loader {const configUse = mergeObjects(this._defaultConfig.use, config.use);config = mergeObjects(mergeObjects(this._defaultConfig, config), { use: configUse });- (this._fullConfig as any).__configDir = configDir;+ this._fullConfig._configDir = configDir;this._fullConfig.rootDir = config.testDir || this._configDir;this._fullConfig.forbidOnly = takeFirst(this._configOverrides.forbidOnly, config.forbidOnly, baseFullConfig.forbidOnly);this._fullConfig.fullyParallel = takeFirst(this._configOverrides.fullyParallel, config.fullyParallel, baseFullConfig.fullyParallel);@@ -474,6 +474,8 @@ const baseFullConfig: FullConfigInternal = {workers: 1,webServer: null,_attachments: [],+ _configDir: '',+ _testGroupsCount: 0,};function resolveReporters(reporters: Config['reporter'], rootDir: string): ReporterDescription[]|undefined {diff --git a/packages/playwright-test/src/reporters/base.ts b/packages/playwright-test/src/reporters/base.tsindex cf6b38793e..9da073fe2e 100644--- a/packages/playwright-test/src/reporters/base.ts+++ b/packages/playwright-test/src/reporters/base.ts@@ -21,6 +21,7 @@ import milliseconds from 'ms';import path from 'path';import StackUtils from 'stack-utils';import { FullConfig, TestCase, Suite, TestResult, TestError, Reporter, FullResult, TestStep, Location } from '../../types/testReporter';+import { FullConfigInternal } from '../types';const stackUtils = new StackUtils();@@ -49,7 +50,7 @@ type TestSummary = {export class BaseReporter implements Reporter {duration = 0;- config!: FullConfig;+ config!: FullConfigInternal;suite!: Suite;totalTestCount = 0;result!: FullResult;@@ -65,7 +66,7 @@ export class BaseReporter implements Reporter {onBegin(config: FullConfig, suite: Suite) {this.monotonicStartTime = monotonicTime();- this.config = config;+ this.config = config as FullConfigInternal;this.suite = suite;this.totalTestCount = suite.allTests().length;}@@ -117,7 +118,7 @@ export class BaseReporter implements Reporter {}protected generateStartingMessage() {- const jobs = Math.min(this.config.workers, (this.config as any).__testGroupsCount);+ const jobs = Math.min(this.config.workers, this.config._testGroupsCount);const shardDetails = this.config.shard ? `, shard ${this.config.shard.current} of ${this.config.shard.total}` : '';return `\nRunning ${this.totalTestCount} test${this.totalTestCount > 1 ? 's' : ''} using ${jobs} worker${jobs > 1 ? 's' : ''}${shardDetails}`;}diff --git a/packages/playwright-test/src/reporters/html.ts b/packages/playwright-test/src/reporters/html.tsindex 3e9cae1067..55a625a526 100644--- a/packages/playwright-test/src/reporters/html.ts+++ b/packages/playwright-test/src/reporters/html.ts@@ -27,6 +27,7 @@ import assert from 'assert';import yazl from 'yazl';import { stripAnsiEscapes } from './base';import { getPackageJsonPath } from '../util';+import { FullConfigInternal } from '../types';export type Stats = {total: number;@@ -123,7 +124,7 @@ type HtmlReporterOptions = {};class HtmlReporter implements Reporter {- private config!: FullConfig;+ private config!: FullConfigInternal;private suite!: Suite;private _options: HtmlReporterOptions;@@ -136,17 +137,16 @@ class HtmlReporter implements Reporter {}onBegin(config: FullConfig, suite: Suite) {- this.config = config;+ this.config = config as FullConfigInternal;this.suite = suite;}_resolveOptions(): { outputFolder: string, open: HtmlReportOpenOption } {let { outputFolder } = this._options;- const configDir: string = (this.config as any).__configDir;if (outputFolder)- outputFolder = path.resolve(configDir, outputFolder);+ outputFolder = path.resolve(this.config._configDir, outputFolder);return {- outputFolder: reportFolderFromEnv() ?? outputFolder ?? defaultReportFolder(configDir),+ outputFolder: reportFolderFromEnv() ?? outputFolder ?? defaultReportFolder(this.config._configDir),open: process.env.PW_TEST_HTML_REPORT_OPEN as any || this._options.open || 'on-failure',};}diff --git a/packages/playwright-test/src/runner.ts b/packages/playwright-test/src/runner.tsindex eb287e8ffb..0ecaa94c2f 100644--- a/packages/playwright-test/src/runner.ts+++ b/packages/playwright-test/src/runner.ts@@ -346,7 +346,7 @@ export class Runner {filterSuiteWithOnlySemantics(rootSuite, () => false, test => shardTests.has(test));total = rootSuite.allTests().length;}- (config as any).__testGroupsCount = testGroups.length;+ config._testGroupsCount = testGroups.length;// 9. Report beginthis._reporter.onBegin?.(config, rootSuite);diff --git a/packages/playwright-test/src/types.ts b/packages/playwright-test/src/types.tsindex 035829757d..2b43941b04 100644--- a/packages/playwright-test/src/types.ts+++ b/packages/playwright-test/src/types.ts@@ -40,5 +40,7 @@ export interface TestStepInternal {* increasing the surface area of the public API type called FullConfig.*/export interface FullConfigInternal extends FullConfigPublic {+ _configDir: string;+ _testGroupsCount: number;_attachments: { name: string, path?: string, body?: Buffer, contentType: string }[];}