From 29fbcbee69deabf9804aadb5c72b4fb43f5fd314 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Fri, 18 Aug 2023 18:26:34 +0200 Subject: [PATCH] fix: warn if PWT commands get executed without PWT (#26542) Fixes https://github.com/microsoft/playwright/issues/26541 --- packages/playwright-core/src/cli/cli.ts | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/packages/playwright-core/src/cli/cli.ts b/packages/playwright-core/src/cli/cli.ts index ac3cacff9d..7286f2f837 100755 --- a/packages/playwright-core/src/cli/cli.ts +++ b/packages/playwright-core/src/cli/cli.ts @@ -48,20 +48,16 @@ function printPlaywrightTestError(command: string) { } } -{ - const command = program.command('test').allowUnknownOption(true); - command.description('Run tests with Playwright Test. Available in @playwright/test package.'); - command.action(async () => { - printPlaywrightTestError('test'); - gracefullyProcessExitDoNotHang(1); - }); -} - -{ - const command = program.command('show-report').allowUnknownOption(true); - command.description('Show Playwright Test HTML report. Available in @playwright/test package.'); - command.action(async () => { - printPlaywrightTestError('show-report'); +const kExternalPlaywrightTestCommands = [ + ['test', 'Run tests with Playwright Test.'], + ['show-report', 'Show Playwright Test HTML report.'], + ['merge-reports', 'Merge Playwright Test Blob reports'], +]; +for (const [command, description] of kExternalPlaywrightTestCommands) { + const playwrightTest = program.command(command).allowUnknownOption(true); + playwrightTest.description(`${description} Available in @playwright/test package.`); + playwrightTest.action(async () => { + printPlaywrightTestError(command); gracefullyProcessExitDoNotHang(1); }); }