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
fix(test-runner): do not list tests to stdout when JSON reporter is used (#7730)
Max Schmittc84c5c8c9b85
diff --git a/src/test/runner.ts b/src/test/runner.tsindex ad30f78094..74b968d0cc 100644--- a/src/test/runner.ts+++ b/src/test/runner.ts@@ -62,12 +62,12 @@ export class Runner {this._loader = new Loader(defaultConfig, configOverrides);}- private async _createReporter() {+ private async _createReporter(list: boolean) {const reporters: Reporter[] = [];const defaultReporters = {- dot: DotReporter,- line: LineReporter,- list: ListReporter,+ dot: list ? ListModeReporter : DotReporter,+ line: list ? ListModeReporter : LineReporter,+ list: list ? ListModeReporter : ListReporter,json: JSONReporter,junit: JUnitReporter,null: EmptyReporter,@@ -93,7 +93,7 @@ export class Runner {}async run(list: boolean, filePatternFilters: FilePatternFilter[], projectName?: string): Promise<RunResultStatus> {- this._reporter = list ? new ListModeReporter() : await this._createReporter();+ this._reporter = await this._createReporter(list);const config = this._loader.fullConfig();const globalDeadline = config.globalTimeout ? config.globalTimeout + monotonicTime() : undefined;const { result, timedOut } = await raceAgainstDeadline(this._run(list, filePatternFilters, projectName), globalDeadline);diff --git a/tests/playwright-test/list-mode.spec.ts b/tests/playwright-test/list-mode.spec.tsindex 1c7f6435cf..6ecc3f111d 100644--- a/tests/playwright-test/list-mode.spec.ts+++ b/tests/playwright-test/list-mode.spec.ts@@ -41,3 +41,26 @@ test('should list tests', async ({ runInlineTest }) => {`Total: 4 tests in 1 file`].join('\n'));});++test('should not list tests to stdout when JSON reporter is used', async ({ runInlineTest }) => {+ const result = await runInlineTest({+ 'playwright.config.ts': `+ module.exports = { projects: [{ name: 'foo' }, {}] };+ `,+ 'a.test.js': `+ const { test } = pwt;+ test('example1', async ({}) => {+ expect(1 + 1).toBe(2);+ });+ test('example2', async ({}) => {+ expect(1 + 1).toBe(2);+ });+ `+ }, { 'list': true, 'reporter': 'json' });+ expect(result.exitCode).toBe(0);+ expect(result.output).not.toContain('Listing tests');+ expect(result.report.config.projects.length).toBe(2);+ expect(result.report.suites.length).toBe(1);+ expect(result.report.suites[0].specs.length).toBe(2);+ expect(result.report.suites[0].specs.map(spec => spec.title)).toStrictEqual(['example1', 'example2']);+});