chore: move private fields to FullConfigInternal (#13261)
This commit is contained in:
parent
66cf82766e
commit
f6936c0461
|
|
@ -99,7 +99,7 @@ export class Loader {
|
||||||
const configUse = mergeObjects(this._defaultConfig.use, config.use);
|
const configUse = mergeObjects(this._defaultConfig.use, config.use);
|
||||||
config = mergeObjects(mergeObjects(this._defaultConfig, config), { use: configUse });
|
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.rootDir = config.testDir || this._configDir;
|
||||||
this._fullConfig.forbidOnly = takeFirst(this._configOverrides.forbidOnly, config.forbidOnly, baseFullConfig.forbidOnly);
|
this._fullConfig.forbidOnly = takeFirst(this._configOverrides.forbidOnly, config.forbidOnly, baseFullConfig.forbidOnly);
|
||||||
this._fullConfig.fullyParallel = takeFirst(this._configOverrides.fullyParallel, config.fullyParallel, baseFullConfig.fullyParallel);
|
this._fullConfig.fullyParallel = takeFirst(this._configOverrides.fullyParallel, config.fullyParallel, baseFullConfig.fullyParallel);
|
||||||
|
|
@ -474,6 +474,8 @@ const baseFullConfig: FullConfigInternal = {
|
||||||
workers: 1,
|
workers: 1,
|
||||||
webServer: null,
|
webServer: null,
|
||||||
_attachments: [],
|
_attachments: [],
|
||||||
|
_configDir: '',
|
||||||
|
_testGroupsCount: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
function resolveReporters(reporters: Config['reporter'], rootDir: string): ReporterDescription[]|undefined {
|
function resolveReporters(reporters: Config['reporter'], rootDir: string): ReporterDescription[]|undefined {
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import milliseconds from 'ms';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import StackUtils from 'stack-utils';
|
import StackUtils from 'stack-utils';
|
||||||
import { FullConfig, TestCase, Suite, TestResult, TestError, Reporter, FullResult, TestStep, Location } from '../../types/testReporter';
|
import { FullConfig, TestCase, Suite, TestResult, TestError, Reporter, FullResult, TestStep, Location } from '../../types/testReporter';
|
||||||
|
import { FullConfigInternal } from '../types';
|
||||||
|
|
||||||
const stackUtils = new StackUtils();
|
const stackUtils = new StackUtils();
|
||||||
|
|
||||||
|
|
@ -49,7 +50,7 @@ type TestSummary = {
|
||||||
|
|
||||||
export class BaseReporter implements Reporter {
|
export class BaseReporter implements Reporter {
|
||||||
duration = 0;
|
duration = 0;
|
||||||
config!: FullConfig;
|
config!: FullConfigInternal;
|
||||||
suite!: Suite;
|
suite!: Suite;
|
||||||
totalTestCount = 0;
|
totalTestCount = 0;
|
||||||
result!: FullResult;
|
result!: FullResult;
|
||||||
|
|
@ -65,7 +66,7 @@ export class BaseReporter implements Reporter {
|
||||||
|
|
||||||
onBegin(config: FullConfig, suite: Suite) {
|
onBegin(config: FullConfig, suite: Suite) {
|
||||||
this.monotonicStartTime = monotonicTime();
|
this.monotonicStartTime = monotonicTime();
|
||||||
this.config = config;
|
this.config = config as FullConfigInternal;
|
||||||
this.suite = suite;
|
this.suite = suite;
|
||||||
this.totalTestCount = suite.allTests().length;
|
this.totalTestCount = suite.allTests().length;
|
||||||
}
|
}
|
||||||
|
|
@ -117,7 +118,7 @@ export class BaseReporter implements Reporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected generateStartingMessage() {
|
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}` : '';
|
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}`;
|
return `\nRunning ${this.totalTestCount} test${this.totalTestCount > 1 ? 's' : ''} using ${jobs} worker${jobs > 1 ? 's' : ''}${shardDetails}`;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import assert from 'assert';
|
||||||
import yazl from 'yazl';
|
import yazl from 'yazl';
|
||||||
import { stripAnsiEscapes } from './base';
|
import { stripAnsiEscapes } from './base';
|
||||||
import { getPackageJsonPath } from '../util';
|
import { getPackageJsonPath } from '../util';
|
||||||
|
import { FullConfigInternal } from '../types';
|
||||||
|
|
||||||
export type Stats = {
|
export type Stats = {
|
||||||
total: number;
|
total: number;
|
||||||
|
|
@ -123,7 +124,7 @@ type HtmlReporterOptions = {
|
||||||
};
|
};
|
||||||
|
|
||||||
class HtmlReporter implements Reporter {
|
class HtmlReporter implements Reporter {
|
||||||
private config!: FullConfig;
|
private config!: FullConfigInternal;
|
||||||
private suite!: Suite;
|
private suite!: Suite;
|
||||||
private _options: HtmlReporterOptions;
|
private _options: HtmlReporterOptions;
|
||||||
|
|
||||||
|
|
@ -136,17 +137,16 @@ class HtmlReporter implements Reporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
onBegin(config: FullConfig, suite: Suite) {
|
onBegin(config: FullConfig, suite: Suite) {
|
||||||
this.config = config;
|
this.config = config as FullConfigInternal;
|
||||||
this.suite = suite;
|
this.suite = suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
_resolveOptions(): { outputFolder: string, open: HtmlReportOpenOption } {
|
_resolveOptions(): { outputFolder: string, open: HtmlReportOpenOption } {
|
||||||
let { outputFolder } = this._options;
|
let { outputFolder } = this._options;
|
||||||
const configDir: string = (this.config as any).__configDir;
|
|
||||||
if (outputFolder)
|
if (outputFolder)
|
||||||
outputFolder = path.resolve(configDir, outputFolder);
|
outputFolder = path.resolve(this.config._configDir, outputFolder);
|
||||||
return {
|
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',
|
open: process.env.PW_TEST_HTML_REPORT_OPEN as any || this._options.open || 'on-failure',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -346,7 +346,7 @@ export class Runner {
|
||||||
filterSuiteWithOnlySemantics(rootSuite, () => false, test => shardTests.has(test));
|
filterSuiteWithOnlySemantics(rootSuite, () => false, test => shardTests.has(test));
|
||||||
total = rootSuite.allTests().length;
|
total = rootSuite.allTests().length;
|
||||||
}
|
}
|
||||||
(config as any).__testGroupsCount = testGroups.length;
|
config._testGroupsCount = testGroups.length;
|
||||||
|
|
||||||
// 9. Report begin
|
// 9. Report begin
|
||||||
this._reporter.onBegin?.(config, rootSuite);
|
this._reporter.onBegin?.(config, rootSuite);
|
||||||
|
|
|
||||||
|
|
@ -40,5 +40,7 @@ export interface TestStepInternal {
|
||||||
* increasing the surface area of the public API type called FullConfig.
|
* increasing the surface area of the public API type called FullConfig.
|
||||||
*/
|
*/
|
||||||
export interface FullConfigInternal extends FullConfigPublic {
|
export interface FullConfigInternal extends FullConfigPublic {
|
||||||
|
_configDir: string;
|
||||||
|
_testGroupsCount: number;
|
||||||
_attachments: { name: string, path?: string, body?: Buffer, contentType: string }[];
|
_attachments: { name: string, path?: string, body?: Buffer, contentType: string }[];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue