chore: create list reporter for watch mode directly (#22614)
This commit is contained in:
parent
24478be565
commit
59678fdea7
|
|
@ -31,7 +31,7 @@ import type { BuiltInReporter, FullConfigInternal } from '../common/config';
|
||||||
import { loadReporter } from './loadUtils';
|
import { loadReporter } from './loadUtils';
|
||||||
import { BlobReporter } from '../reporters/blob';
|
import { BlobReporter } from '../reporters/blob';
|
||||||
|
|
||||||
export async function createReporter(config: FullConfigInternal, mode: 'list' | 'watch' | 'run' | 'ui', additionalReporters: Reporter[] = []): Promise<Multiplexer> {
|
export async function createReporter(config: FullConfigInternal, mode: 'list' | 'run' | 'ui', additionalReporters: Reporter[] = []): Promise<Multiplexer> {
|
||||||
const defaultReporters: {[key in BuiltInReporter]: new(arg: any) => Reporter} = {
|
const defaultReporters: {[key in BuiltInReporter]: new(arg: any) => Reporter} = {
|
||||||
dot: mode === 'list' ? ListModeReporter : DotReporter,
|
dot: mode === 'list' ? ListModeReporter : DotReporter,
|
||||||
line: mode === 'list' ? ListModeReporter : LineReporter,
|
line: mode === 'list' ? ListModeReporter : LineReporter,
|
||||||
|
|
@ -44,25 +44,21 @@ export async function createReporter(config: FullConfigInternal, mode: 'list' |
|
||||||
blob: BlobReporter,
|
blob: BlobReporter,
|
||||||
};
|
};
|
||||||
const reporters: Reporter[] = [];
|
const reporters: Reporter[] = [];
|
||||||
if (mode === 'watch') {
|
for (const r of config.config.reporter) {
|
||||||
reporters.push(new ListReporter());
|
const [name, arg] = r;
|
||||||
} else {
|
const options = { ...arg, configDir: config.configDir };
|
||||||
for (const r of config.config.reporter) {
|
if (name in defaultReporters) {
|
||||||
const [name, arg] = r;
|
reporters.push(new defaultReporters[name as keyof typeof defaultReporters](options));
|
||||||
const options = { ...arg, configDir: config.configDir };
|
} else {
|
||||||
if (name in defaultReporters) {
|
const reporterConstructor = await loadReporter(config, name);
|
||||||
reporters.push(new defaultReporters[name as keyof typeof defaultReporters](options));
|
reporters.push(new reporterConstructor(options));
|
||||||
} else {
|
|
||||||
const reporterConstructor = await loadReporter(config, name);
|
|
||||||
reporters.push(new reporterConstructor(options));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
reporters.push(...additionalReporters);
|
|
||||||
if (process.env.PW_TEST_REPORTER) {
|
|
||||||
const reporterConstructor = await loadReporter(config, process.env.PW_TEST_REPORTER);
|
|
||||||
reporters.push(new reporterConstructor());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
reporters.push(...additionalReporters);
|
||||||
|
if (process.env.PW_TEST_REPORTER) {
|
||||||
|
const reporterConstructor = await loadReporter(config, process.env.PW_TEST_REPORTER);
|
||||||
|
reporters.push(new reporterConstructor());
|
||||||
|
}
|
||||||
|
|
||||||
const someReporterPrintsToStdio = reporters.some(r => {
|
const someReporterPrintsToStdio = reporters.some(r => {
|
||||||
const prints = r.printsToStdio ? r.printsToStdio() : true;
|
const prints = r.printsToStdio ? r.printsToStdio() : true;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ import { clearCompilationCache, collectAffectedTestFiles } from '../common/compi
|
||||||
import type { FullResult } from 'packages/playwright-test/reporter';
|
import type { FullResult } from 'packages/playwright-test/reporter';
|
||||||
import { chokidar } from '../utilsBundle';
|
import { chokidar } from '../utilsBundle';
|
||||||
import type { FSWatcher as CFSWatcher } from 'chokidar';
|
import type { FSWatcher as CFSWatcher } from 'chokidar';
|
||||||
import { createReporter } from './reporters';
|
|
||||||
import { colors } from 'playwright-core/lib/utilsBundle';
|
import { colors } from 'playwright-core/lib/utilsBundle';
|
||||||
import { enquirer } from '../utilsBundle';
|
import { enquirer } from '../utilsBundle';
|
||||||
import { separator } from '../reporters/base';
|
import { separator } from '../reporters/base';
|
||||||
|
|
@ -113,7 +112,7 @@ export async function runWatchModeLoop(config: FullConfigInternal): Promise<Full
|
||||||
p.project.retries = 0;
|
p.project.retries = 0;
|
||||||
|
|
||||||
// Perform global setup.
|
// Perform global setup.
|
||||||
const reporter = await createReporter(config, 'watch');
|
const reporter = new Multiplexer([new ListReporter()]);
|
||||||
const testRun = new TestRun(config, reporter);
|
const testRun = new TestRun(config, reporter);
|
||||||
const taskRunner = createTaskRunnerForWatchSetup(config, reporter);
|
const taskRunner = createTaskRunnerForWatchSetup(config, reporter);
|
||||||
reporter.onConfigure(config);
|
reporter.onConfigure(config);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue