From 476b74f7c4b6f95ec9fe2c89d3aee20bb9a277ec Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Thu, 14 Sep 2023 21:33:29 -0700 Subject: [PATCH] cherry-pick(#27103): fix: list tests only once (#27107) Fixes #27087 --- packages/playwright/src/runner/reporters.ts | 4 ++++ tests/playwright-test/list-mode.spec.ts | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/packages/playwright/src/runner/reporters.ts b/packages/playwright/src/runner/reporters.ts index f71b3d87ad8b1..31a61dcadd260 100644 --- a/packages/playwright/src/runner/reporters.ts +++ b/packages/playwright/src/runner/reporters.ts @@ -104,4 +104,8 @@ class ListModeReporter extends EmptyReporter { // eslint-disable-next-line no-console console.error('\n' + formatError(error, false).message); } + + override printsToStdio(): boolean { + return true; + } } diff --git a/tests/playwright-test/list-mode.spec.ts b/tests/playwright-test/list-mode.spec.ts index e8b8923c6cfa9..1388b38dd9e30 100644 --- a/tests/playwright-test/list-mode.spec.ts +++ b/tests/playwright-test/list-mode.spec.ts @@ -196,3 +196,21 @@ test('should report errors with location', async ({ runInlineTest }) => { column: 9, }); }); + +test('should list tests once', async ({ runInlineTest }) => { + test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/27087' }); + const result = await runInlineTest({ + 'playwright.config.ts': ` + module.exports = { }; + `, + 'a.test.js': ` + const { test, expect } = require('@playwright/test'); + test('test 1', ({}) => {}); + ` + }, { 'list': true }); + expect(result.exitCode).toBe(0); + expect(result.output).toEqual(`Listing tests: + a.test.js:3:7 › test 1 +Total: 1 test in 1 file +`); +});