From a71c151438fd50c72d2bfa44a18d041cdb17864b Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Mon, 4 Apr 2022 16:07:04 -0700 Subject: [PATCH] chore: introduce FullProjectInternal (#13301) This is similar to FullConfigInternal to put private stuff on. --- packages/playwright-test/src/loader.ts | 4 ++-- packages/playwright-test/src/project.ts | 6 +++--- packages/playwright-test/src/test.ts | 5 ++--- packages/playwright-test/src/types.ts | 12 +++++++++++- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/playwright-test/src/loader.ts b/packages/playwright-test/src/loader.ts index 7a51a56868..dc0c2fd9e0 100644 --- a/packages/playwright-test/src/loader.ts +++ b/packages/playwright-test/src/loader.ts @@ -15,7 +15,7 @@ */ import { installTransform, setCurrentlyLoadingTestFile } from './transform'; -import type { Config, FullProject, Project, ReporterDescription, PreserveOutput } from './types'; +import type { Config, Project, ReporterDescription, PreserveOutput, FullProjectInternal } from './types'; import type { FullConfigInternal } from './types'; import { getPackageJsonPath, mergeObjects, errorWithFile } from './util'; import { setCurrentlyLoadingFileSuite } from './globals'; @@ -219,7 +219,7 @@ export class Loader { const snapshotDir = takeFirst(this._configOverrides.snapshotDir, projectConfig.snapshotDir, config.snapshotDir, testDir); const name = takeFirst(this._configOverrides.name, projectConfig.name, config.name, ''); const screenshotsDir = takeFirst(this._configOverrides.screenshotsDir, projectConfig.screenshotsDir, config.screenshotsDir, path.join(testDir, '__screenshots__', process.platform, name)); - const fullProject: FullProject = { + const fullProject: FullProjectInternal = { fullyParallel: takeFirst(this._configOverrides.fullyParallel, projectConfig.fullyParallel, config.fullyParallel, undefined), expect: takeFirst(this._configOverrides.expect, projectConfig.expect, config.expect, undefined), grep: takeFirst(this._configOverrides.grep, projectConfig.grep, config.grep, baseFullConfig.grep), diff --git a/packages/playwright-test/src/project.ts b/packages/playwright-test/src/project.ts index 8de0b8486b..e85fda8082 100644 --- a/packages/playwright-test/src/project.ts +++ b/packages/playwright-test/src/project.ts @@ -14,19 +14,19 @@ * limitations under the License. */ -import type { FullProject, Fixtures, FixturesWithLocation } from './types'; +import type { Fixtures, FixturesWithLocation, FullProjectInternal } from './types'; import { Suite, TestCase } from './test'; import { FixturePool, isFixtureOption } from './fixtures'; import { TestTypeImpl } from './testType'; import { calculateSha1 } from 'playwright-core/lib/utils/utils'; export class ProjectImpl { - config: FullProject; + config: FullProjectInternal; private index: number; private testTypePools = new Map(); private testPools = new Map(); - constructor(project: FullProject, index: number) { + constructor(project: FullProjectInternal, index: number) { this.config = project; this.index = index; } diff --git a/packages/playwright-test/src/test.ts b/packages/playwright-test/src/test.ts index 33df726f11..935490f7d7 100644 --- a/packages/playwright-test/src/test.ts +++ b/packages/playwright-test/src/test.ts @@ -17,8 +17,7 @@ import type { FixturePool } from './fixtures'; import * as reporterTypes from '../types/testReporter'; import type { TestTypeImpl } from './testType'; -import { Annotation, FixturesWithLocation, Location } from './types'; -import { FullProject } from './types'; +import { Annotation, FixturesWithLocation, FullProject, FullProjectInternal, Location } from './types'; class Base { title: string; @@ -51,7 +50,7 @@ export class Suite extends Base implements reporterTypes.Suite { _annotations: Annotation[] = []; _modifiers: Modifier[] = []; _parallelMode: 'default' | 'serial' | 'parallel' = 'default'; - _projectConfig: FullProject | undefined; + _projectConfig: FullProjectInternal | undefined; _loadError?: reporterTypes.TestError; _addTest(test: TestCase) { diff --git a/packages/playwright-test/src/types.ts b/packages/playwright-test/src/types.ts index 2b43941b04..5b748c9955 100644 --- a/packages/playwright-test/src/types.ts +++ b/packages/playwright-test/src/types.ts @@ -16,7 +16,7 @@ import type { Fixtures, TestError } from '../types/test'; import type { Location } from '../types/testReporter'; -import type { FullConfig as FullConfigPublic } from './types'; +import type { FullConfig as FullConfigPublic, FullProject as FullProjectPublic } from './types'; export * from '../types/test'; export type { Location } from '../types/testReporter'; @@ -43,4 +43,14 @@ export interface FullConfigInternal extends FullConfigPublic { _configDir: string; _testGroupsCount: number; _attachments: { name: string, path?: string, body?: Buffer, contentType: string }[]; + + // Overrides the public field. + projects: FullProjectInternal[]; +} + +/** + * FullProjectInternal allows the plumbing of configuration details throughout the Test Runner without + * increasing the surface area of the public API type called FullProject. + */ +export interface FullProjectInternal extends FullProjectPublic { }