chore: introduce FullProjectInternal (#13301)

This is similar to FullConfigInternal to put private stuff on.
This commit is contained in:
Dmitry Gozman 2022-04-04 16:07:04 -07:00 committed by GitHub
parent 786b4a55fc
commit a71c151438
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 9 deletions

View file

@ -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),

View file

@ -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<TestTypeImpl, FixturePool>();
private testPools = new Map<TestCase, FixturePool>();
constructor(project: FullProject, index: number) {
constructor(project: FullProjectInternal, index: number) {
this.config = project;
this.index = index;
}

View file

@ -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) {

View file

@ -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 {
}