chore: remove internal dep on FullConfig (#13074)

Resolves #13058.

This blocks adding #8206 since we don't want the new launch configs
publicly available on FullConfig.
This commit is contained in:
Ross Wollman 2022-03-28 15:53:42 -07:00 committed by GitHub
parent 01a39e5b4c
commit ae365dda3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 16 deletions

View File

@ -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';
}

View File

@ -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-console
console.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: (TestCase
return 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.',

View File

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

View File

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

View File

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

View File

@ -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';