Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: create list reporter for watch mode directly (#22614)
Yury Semikhatsky59678fdea763
diff --git a/packages/playwright-test/src/runner/reporters.ts b/packages/playwright-test/src/runner/reporters.tsindex b33575090d..578a98cbc1 100644--- a/packages/playwright-test/src/runner/reporters.ts+++ b/packages/playwright-test/src/runner/reporters.ts@@ -31,7 +31,7 @@ import type { BuiltInReporter, FullConfigInternal } from '../common/config';import { loadReporter } from './loadUtils';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} = {dot: mode === 'list' ? ListModeReporter : DotReporter,line: mode === 'list' ? ListModeReporter : LineReporter,@@ -44,25 +44,21 @@ export async function createReporter(config: FullConfigInternal, mode: 'list' |blob: BlobReporter,};const reporters: Reporter[] = [];- if (mode === 'watch') {- reporters.push(new ListReporter());- } else {- for (const r of config.config.reporter) {- const [name, arg] = r;- const options = { ...arg, configDir: config.configDir };- if (name in defaultReporters) {- reporters.push(new defaultReporters[name as keyof typeof defaultReporters](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());+ for (const r of config.config.reporter) {+ const [name, arg] = r;+ const options = { ...arg, configDir: config.configDir };+ if (name in defaultReporters) {+ reporters.push(new defaultReporters[name as keyof typeof defaultReporters](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());+ }const someReporterPrintsToStdio = reporters.some(r => {const prints = r.printsToStdio ? r.printsToStdio() : true;diff --git a/packages/playwright-test/src/runner/watchMode.ts b/packages/playwright-test/src/runner/watchMode.tsindex 830f47a35b..fe595de7d5 100644--- a/packages/playwright-test/src/runner/watchMode.ts+++ b/packages/playwright-test/src/runner/watchMode.ts@@ -26,7 +26,6 @@ import { clearCompilationCache, collectAffectedTestFiles } from '../common/compiimport type { FullResult } from 'packages/playwright-test/reporter';import { chokidar } from '../utilsBundle';import type { FSWatcher as CFSWatcher } from 'chokidar';-import { createReporter } from './reporters';import { colors } from 'playwright-core/lib/utilsBundle';import { enquirer } from '../utilsBundle';import { separator } from '../reporters/base';@@ -113,7 +112,7 @@ export async function runWatchModeLoop(config: FullConfigInternal): Promise<Fullp.project.retries = 0;// Perform global setup.- const reporter = await createReporter(config, 'watch');+ const reporter = new Multiplexer([new ListReporter()]);const testRun = new TestRun(config, reporter);const taskRunner = createTaskRunnerForWatchSetup(config, reporter);reporter.onConfigure(config);