chore(test runner): include projects in teleReceiver's config
This commit is contained in:
parent
201bad75d3
commit
3c62283ef6
|
|
@ -26,14 +26,14 @@ export type JsonStackFrame = { file: string, line: number, column: number };
|
|||
|
||||
export type JsonStdIOType = 'stdout' | 'stderr';
|
||||
|
||||
export type JsonConfig = Pick<reporterTypes.FullConfig, 'configFile' | 'globalTimeout' | 'maxFailures' | 'metadata' | 'rootDir' | 'version' | 'workers'>;
|
||||
export type JsonConfig = Pick<reporterTypes.FullConfig, 'configFile' | 'globalTimeout' | 'maxFailures' | 'metadata' | 'rootDir' | 'version' | 'workers'> & { projects: JsonConfigProject[] };
|
||||
|
||||
export type JsonPattern = {
|
||||
s?: string;
|
||||
r?: { source: string, flags: string };
|
||||
};
|
||||
|
||||
export type JsonProject = {
|
||||
export type JsonConfigProject = {
|
||||
grep: JsonPattern[];
|
||||
grepInvert: JsonPattern[];
|
||||
metadata: Metadata;
|
||||
|
|
@ -45,7 +45,6 @@ export type JsonProject = {
|
|||
outputDir: string;
|
||||
repeatEach: number;
|
||||
retries: number;
|
||||
suites: JsonSuite[];
|
||||
teardown?: string;
|
||||
// This is relative to root dir.
|
||||
testDir: string;
|
||||
|
|
@ -54,6 +53,10 @@ export type JsonProject = {
|
|||
timeout: number;
|
||||
};
|
||||
|
||||
export type JsonProject = JsonConfigProject & {
|
||||
suites: JsonSuite[];
|
||||
};
|
||||
|
||||
export type JsonSuite = {
|
||||
title: string;
|
||||
location?: JsonLocation;
|
||||
|
|
@ -304,10 +307,13 @@ export class TeleReporterReceiver {
|
|||
result.quiet = this._options.configOverrides.quiet;
|
||||
result.reporter = [...this._options.configOverrides.reporter];
|
||||
}
|
||||
return result;
|
||||
return {
|
||||
...result,
|
||||
projects: result.projects.map(p => this._parseProject(p)),
|
||||
};
|
||||
}
|
||||
|
||||
private _parseProject(project: JsonProject): TeleFullProject {
|
||||
private _parseProject(project: JsonConfigProject): TeleFullProject {
|
||||
return {
|
||||
metadata: project.metadata,
|
||||
name: project.name,
|
||||
|
|
|
|||
|
|
@ -255,6 +255,7 @@ function mergeConfigureEvents(configureEvents: JsonEvent[], rootDirOverride: str
|
|||
rootDir: '',
|
||||
version: '',
|
||||
workers: 0,
|
||||
projects: [],
|
||||
};
|
||||
for (const event of configureEvents)
|
||||
config = mergeConfigs(config, event.params.config);
|
||||
|
|
@ -288,6 +289,11 @@ function mergeConfigureEvents(configureEvents: JsonEvent[], rootDirOverride: str
|
|||
};
|
||||
}
|
||||
|
||||
function dedupByName<T extends { name: string }>(a: T[], b: T[]) {
|
||||
const aNames = new Set(a.map(v => v.name));
|
||||
return a.concat(b.filter(b => !aNames.has(b.name)));
|
||||
}
|
||||
|
||||
function mergeConfigs(to: JsonConfig, from: JsonConfig): JsonConfig {
|
||||
return {
|
||||
...to,
|
||||
|
|
@ -298,6 +304,7 @@ function mergeConfigs(to: JsonConfig, from: JsonConfig): JsonConfig {
|
|||
actualWorkers: (to.metadata.actualWorkers || 0) + (from.metadata.actualWorkers || 0),
|
||||
},
|
||||
workers: to.workers + from.workers,
|
||||
projects: dedupByName(to.projects, from.projects),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -161,12 +161,12 @@ export class TeleReporterEmitter implements ReporterV2 {
|
|||
rootDir: config.rootDir,
|
||||
version: config.version,
|
||||
workers: config.workers,
|
||||
projects: config.projects.map(project => this._serializeConfigProject(project)),
|
||||
};
|
||||
}
|
||||
|
||||
private _serializeProject(suite: reporterTypes.Suite): teleReceiver.JsonProject {
|
||||
const project = suite.project()!;
|
||||
const report: teleReceiver.JsonProject = {
|
||||
private _serializeConfigProject(project: reporterTypes.FullProject): teleReceiver.JsonConfigProject {
|
||||
return {
|
||||
metadata: project.metadata,
|
||||
name: project.name,
|
||||
outputDir: this._relativePath(project.outputDir),
|
||||
|
|
@ -176,16 +176,20 @@ export class TeleReporterEmitter implements ReporterV2 {
|
|||
testIgnore: serializeRegexPatterns(project.testIgnore),
|
||||
testMatch: serializeRegexPatterns(project.testMatch),
|
||||
timeout: project.timeout,
|
||||
suites: suite.suites.map(fileSuite => {
|
||||
return this._serializeSuite(fileSuite);
|
||||
}),
|
||||
grep: serializeRegexPatterns(project.grep),
|
||||
grepInvert: serializeRegexPatterns(project.grepInvert || []),
|
||||
dependencies: project.dependencies,
|
||||
snapshotDir: this._relativePath(project.snapshotDir),
|
||||
teardown: project.teardown,
|
||||
};
|
||||
return report;
|
||||
}
|
||||
|
||||
private _serializeProject(suite: reporterTypes.Suite): teleReceiver.JsonProject {
|
||||
const project = suite.project()!;
|
||||
return {
|
||||
...this._serializeConfigProject(project),
|
||||
suites: suite.suites.map(fileSuite => this._serializeSuite(fileSuite)),
|
||||
};
|
||||
}
|
||||
|
||||
private _serializeSuite(suite: reporterTypes.Suite): teleReceiver.JsonSuite {
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ export async function runWatchModeLoop(configLocation: ConfigLocation, initialOp
|
|||
type: 'multiselect',
|
||||
name: 'selectedProjects',
|
||||
message: 'Select projects',
|
||||
choices: teleSuiteUpdater.rootSuite!.suites.map(s => s.title),
|
||||
choices: teleSuiteUpdater.config!.projects.map(p => p.name),
|
||||
}).catch(() => ({ selectedProjects: null }));
|
||||
if (!selectedProjects)
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Reference in a new issue