Skip to content

Blob report no top level fields #30270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/src/test-reporter-api/class-fullconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Resolved configuration passed to [`method: Reporter.onBegin`].

## property: FullConfig.configFile
* since: v1.20
* deprecated: Use [`property: FullProject.configFile`] instead.
- type: ?<[string]>

Path to the configuration file (if any) used to run the tests.
Expand Down Expand Up @@ -36,6 +37,7 @@ See [`property: TestConfig.globalTeardown`].

## property: FullConfig.globalTimeout
* since: v1.10
* deprecated: Use [`property: FullProject.globalTimeout`] instead.
- type: <[int]>

See [`property: TestConfig.globalTimeout`].
Expand All @@ -54,6 +56,7 @@ See [`property: TestConfig.grepInvert`].

## property: FullConfig.maxFailures
* since: v1.10
* deprecated: Use [`property: FullProject.maxFailures`] instead.
- type: <[int]>

See [`property: TestConfig.maxFailures`].
Expand Down Expand Up @@ -130,6 +133,7 @@ See [`property: TestConfig.webServer`].

## property: FullConfig.workers
* since: v1.10
* deprecated: Use [`property: FullProject.workers`] instead.
- type: <[int]>

See [`property: TestConfig.workers`].
24 changes: 24 additions & 0 deletions docs/src/test-reporter-api/class-fullproject.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,24 @@ to [Reporter]. It exposes some of the resolved fields declared in
[TestProject]. You can get [FullProject] instance from [`property: FullConfig.projects`]
or [`method: Suite.project`].

## property: FullProject.configFile
* since: v1.44
- type: ?<[string]>

Path to the configuration file (if any) used to run the tests.

## property: FullProject.dependencies
* since: v1.31
- type: <[Array]<[string]>>

See [`property: TestProject.dependencies`].

## property: FullProject.globalTimeout
* since: v1.44
- type: <[int]>

See [`property: TestConfig.globalTimeout`].

## property: FullProject.grep
* since: v1.10
- type: <[RegExp]|[Array]<[RegExp]>>
Expand Down Expand Up @@ -43,6 +55,12 @@ See [`property: TestProject.name`].

See [`property: TestProject.snapshotDir`].

## property: FullProject.maxFailures
* since: v1.44
- type: <[int]>

See [`property: TestConfig.maxFailures`].

## property: FullProject.outputDir
* since: v1.10
- type: <[string]>
Expand Down Expand Up @@ -96,3 +114,9 @@ See [`property: TestProject.timeout`].
- type: <[Fixtures]>

See [`property: TestProject.use`].

## property: FullProject.workers
* since: v1.44
- type: <[int]>

Number of test workers that ran tests from this project. See [`property: TestConfig.workers`].
1 change: 1 addition & 0 deletions packages/playwright/src/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export class FullProjectInternal {
this.snapshotPathTemplate = takeFirst(projectConfig.snapshotPathTemplate, config.snapshotPathTemplate, defaultSnapshotPathTemplate);

this.project = {
globalTimeout: fullConfig.config.globalTimeout,
grep: takeFirst(projectConfig.grep, config.grep, defaultGrep),
grepInvert: takeFirst(projectConfig.grepInvert, config.grepInvert, null),
outputDir: takeFirst(configCLIOverrides.outputDir, pathResolve(configDir, projectConfig.outputDir), pathResolve(configDir, config.outputDir), path.join(throwawayArtifactsPath, 'test-results')),
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright/src/common/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export type EnvProducedPayload = [string, string | null][];

export function serializeConfig(config: FullConfigInternal, passCompilationCache: boolean): SerializedConfig {
const result: SerializedConfig = {
location: { configDir: config.configDir, resolvedConfigFile: config.config.configFile },
location: { configDir: config.configDir, resolvedConfigFile: config.config.projects[0]?.configFile },
configCLIOverrides: config.configCLIOverrides,
compilationCache: passCompilationCache ? serializeCompilationCache() : undefined,
};
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright/src/reporters/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class BaseReporter implements ReporterV2 {
}

protected generateStartingMessage() {
const jobs = this.config.metadata.actualWorkers ?? this.config.workers;
const jobs = this.config.metadata.actualWorkers ?? this.config.projects[0].workers;
const shardDetails = this.config.shard ? `, shard ${this.config.shard.current} of ${this.config.shard.total}` : '';
if (!this.totalTestCount)
return '';
Expand Down Expand Up @@ -195,7 +195,7 @@ export class BaseReporter implements ReporterV2 {
if (expected)
tokens.push(colors.green(` ${expected} passed`) + colors.dim(` (${milliseconds(this.result.duration)})`));
if (this.result.status === 'timedout')
tokens.push(colors.red(` Timed out waiting ${this.config.globalTimeout / 1000}s for the entire test run`));
tokens.push(colors.red(` Timed out waiting ${this.config.projects[0].globalTimeout / 1000}s for the entire test run`));
if (fatalErrors.length && expected + unexpected.length + interrupted.length + flaky.length > 0)
tokens.push(colors.red(` ${fatalErrors.length === 1 ? '1 error was not a part of any test' : fatalErrors.length + ' errors were not a part of any test'}, see above for details`));

Expand Down
4 changes: 2 additions & 2 deletions packages/playwright/src/reporters/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ class JSONReporter extends EmptyReporter {
async function outputReport(report: JSONReport, config: FullConfig, outputFile: string | undefined) {
const reportString = JSON.stringify(report, undefined, 2);
if (outputFile) {
assert(config.configFile || path.isAbsolute(outputFile), 'Expected fully resolved path if not using config file.');
outputFile = config.configFile ? path.resolve(path.dirname(config.configFile), outputFile) : outputFile;
assert(config.projects[0]?.configFile || path.isAbsolute(outputFile), 'Expected fully resolved path if not using config file.');
outputFile = config.projects[0]?.configFile ? path.resolve(path.dirname(config.projects[0]?.configFile), outputFile) : outputFile;
await fs.promises.mkdir(path.dirname(outputFile), { recursive: true });
await fs.promises.writeFile(outputFile, reportString);
} else {
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright/src/reporters/junit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class JUnitReporter extends EmptyReporter {
this.timestamp = new Date();
this.startTime = monotonicTime();
if (this.outputFile) {
assert(this.config.configFile || path.isAbsolute(this.outputFile), 'Expected fully resolved path if not using config file.');
this.resolvedOutputFile = this.config.configFile ? path.resolve(path.dirname(this.config.configFile), this.outputFile) : this.outputFile;
assert(this.config.projects[0]?.configFile || path.isAbsolute(this.outputFile), 'Expected fully resolved path if not using config file.');
this.resolvedOutputFile = this.config.projects[0]?.configFile ? path.resolve(path.dirname(this.config.projects[0]?.configFile), this.outputFile) : this.outputFile;
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/playwright/src/runner/loadUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export async function createRootSuite(testRun: TestRun, errors: TestError[], sho
if (config.config.forbidOnly) {
const onlyTestsAndSuites = rootSuite._getOnlyItems();
if (onlyTestsAndSuites.length > 0) {
const configFilePath = config.config.configFile ? path.relative(config.config.rootDir, config.config.configFile) : undefined;
const configFilePath = config.config.projects[0]?.configFile ? path.relative(config.config.rootDir, config.config.projects[0]?.configFile) : undefined;
errors.push(...createForbidOnlyErrors(onlyTestsAndSuites, config.configCLIOverrides.forbidOnly, configFilePath));
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright/src/runner/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class Runner {
async runAllTests(): Promise<FullResult['status']> {
const config = this._config;
const listOnly = config.cliListOnly;
const deadline = config.config.globalTimeout ? monotonicTime() + config.config.globalTimeout : 0;
const deadline = config.config.projects[0].globalTimeout ? monotonicTime() + config.config.projects[0].globalTimeout : 0;

// Legacy webServer support.
webServerPluginsForConfig(config).forEach(p => config.plugins.push({ factory: p }));
Expand Down
8 changes: 4 additions & 4 deletions packages/playwright/src/runner/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class TestRun {
}

export function createTaskRunner(config: FullConfigInternal, reporter: ReporterV2): TaskRunner<TestRun> {
const taskRunner = new TaskRunner<TestRun>(reporter, config.config.globalTimeout);
const taskRunner = new TaskRunner<TestRun>(reporter, config.config.projects[0].globalTimeout);
addGlobalSetupTasks(taskRunner, config);
taskRunner.addTask('load tests', createLoadTask('in-process', { filterOnly: true, failOnLoadErrors: true }));
addRunTasks(taskRunner, config);
Expand Down Expand Up @@ -109,14 +109,14 @@ function addRunTasks(taskRunner: TaskRunner<TestRun>, config: FullConfigInternal
}

export function createTaskRunnerForList(config: FullConfigInternal, reporter: ReporterV2, mode: 'in-process' | 'out-of-process', options: { failOnLoadErrors: boolean }): TaskRunner<TestRun> {
const taskRunner = new TaskRunner<TestRun>(reporter, config.config.globalTimeout);
const taskRunner = new TaskRunner<TestRun>(reporter, config.config.projects[0].globalTimeout);
taskRunner.addTask('load tests', createLoadTask(mode, { ...options, filterOnly: false }));
taskRunner.addTask('report begin', createReportBeginTask());
return taskRunner;
}

export function createTaskRunnerForListFiles(config: FullConfigInternal, reporter: ReporterV2): TaskRunner<TestRun> {
const taskRunner = new TaskRunner<TestRun>(reporter, config.config.globalTimeout);
const taskRunner = new TaskRunner<TestRun>(reporter, config.config.projects[0].globalTimeout);
taskRunner.addTask('load tests', createListFilesTask());
taskRunner.addTask('report begin', createReportBeginTask());
return taskRunner;
Expand Down Expand Up @@ -283,7 +283,7 @@ function createPhasesTask(): Task<TestRun> {
testRun.phases.push(phase);
for (const project of phaseProjects) {
const projectSuite = projectToSuite.get(project)!;
const testGroups = createTestGroups(projectSuite, testRun.config.config.workers);
const testGroups = createTestGroups(projectSuite, project.project.workers);
phase.projects.push({ project, projectSuite, testGroups });
testGroupsInPhase += testGroups.length;
}
Expand Down
26 changes: 26 additions & 0 deletions packages/playwright/types/testReporter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
webServer: ConfigInWorker['webServer'];
/**
* Path to the configuration file (if any) used to run the tests.
* @deprecated Use [fullProject.configFile](https://playwright.dev/docs/api/class-fullproject#full-project-config-file) instead.
*/
configFile?: string;

Expand All @@ -64,6 +65,8 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {

/**
* See [testConfig.globalTimeout](https://playwright.dev/docs/api/class-testconfig#test-config-global-timeout).
* @deprecated Use [fullProject.globalTimeout](https://playwright.dev/docs/api/class-fullproject#full-project-global-timeout)
* instead.
*/
globalTimeout: number;

Expand All @@ -79,6 +82,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {

/**
* See [testConfig.maxFailures](https://playwright.dev/docs/api/class-testconfig#test-config-max-failures).
* @deprecated Use [fullProject.maxFailures](https://playwright.dev/docs/api/class-fullproject#full-project-max-failures) instead.
*/
maxFailures: number;

Expand Down Expand Up @@ -141,6 +145,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {

/**
* See [testConfig.workers](https://playwright.dev/docs/api/class-testconfig#test-config-workers).
* @deprecated Use [fullProject.workers](https://playwright.dev/docs/api/class-fullproject#full-project-workers) instead.
*/
workers: number;
}
Expand All @@ -156,11 +161,21 @@ export interface FullProject<TestArgs = {}, WorkerArgs = {}> {
* See [testProject.use](https://playwright.dev/docs/api/class-testproject#test-project-use).
*/
use: UseOptions<PlaywrightTestOptions & TestArgs, PlaywrightWorkerOptions & WorkerArgs>;
/**
* Path to the configuration file (if any) used to run the tests.
*/
configFile?: string;

/**
* See [testProject.dependencies](https://playwright.dev/docs/api/class-testproject#test-project-dependencies).
*/
dependencies: Array<string>;

/**
* See [testConfig.globalTimeout](https://playwright.dev/docs/api/class-testconfig#test-config-global-timeout).
*/
globalTimeout: number;

/**
* See [testProject.grep](https://playwright.dev/docs/api/class-testproject#test-project-grep).
*/
Expand All @@ -171,6 +186,11 @@ export interface FullProject<TestArgs = {}, WorkerArgs = {}> {
*/
grepInvert: null|RegExp|Array<RegExp>;

/**
* See [testConfig.maxFailures](https://playwright.dev/docs/api/class-testconfig#test-config-max-failures).
*/
maxFailures: number;

/**
* See [testProject.metadata](https://playwright.dev/docs/api/class-testproject#test-project-metadata).
*/
Expand Down Expand Up @@ -225,6 +245,12 @@ export interface FullProject<TestArgs = {}, WorkerArgs = {}> {
* See [testProject.timeout](https://playwright.dev/docs/api/class-testproject#test-project-timeout).
*/
timeout: number;

/**
* Number of test workers that ran tests from this project. See
* [testConfig.workers](https://playwright.dev/docs/api/class-testconfig#test-config-workers).
*/
workers: number;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/trace-viewer/src/ui/uiModeFiltersView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const FiltersView: React.FC<{
const copy = new Map(projectFilters);
copy.set(projectName, !copy.get(projectName));
setProjectFilters(copy);
const configFile = testModel?.config?.configFile;
const configFile = testModel?.config?.projects[0]?.configFile;
if (configFile)
settings.setObject(configFile + ':projects', [...copy.entries()].filter(([_, v]) => v).map(([k]) => k));
}}/>
Expand Down
2 changes: 1 addition & 1 deletion packages/trace-viewer/src/ui/uiModeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export const UIModeView: React.FC<{}> = ({
return;

const { config, rootSuite } = testModel;
const selectedProjects = config.configFile ? settings.getObject<string[] | undefined>(config.configFile + ':projects', undefined) : undefined;
const selectedProjects = config.projects[0]?.configFile ? settings.getObject<string[] | undefined>(config.projects[0]?.configFile + ':projects', undefined) : undefined;
const newFilter = new Map(projectFilters);
for (const projectName of newFilter.keys()) {
if (!rootSuite.suites.find(s => s.title === projectName))
Expand Down