From 272460a982e1279cb918db1b36e31b04d26993e8 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Tue, 22 Sep 2026 15:57:31 -0700 Subject: [PATCH] fix(cli): accept install-browser --no-shell Fixes: https://github.com/microsoft/playwright/issues/42804 --- packages/playwright-core/src/cli/installActions.ts | 2 +- packages/playwright-core/src/cli/program.ts | 2 +- .../playwright-core/src/tools/cli-client/program.ts | 8 ++++++-- tests/mcp/cli-misc.spec.ts | 10 ++++++++++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/packages/playwright-core/src/cli/installActions.ts b/packages/playwright-core/src/cli/installActions.ts index b2aefc2121f4c..1c5dc75038bec 100644 --- a/packages/playwright-core/src/cli/installActions.ts +++ b/packages/playwright-core/src/cli/installActions.ts @@ -87,7 +87,7 @@ export async function markDockerImage(dockerImageNameTemplate: string) { await writeDockerVersion(dockerImageNameTemplate); } -export async function installBrowsers(args: string[], options: { withDeps?: boolean, force?: boolean, dryRun?: boolean, list?: boolean, shell?: boolean, noShell?: boolean, onlyShell?: boolean, progress?: boolean, remove?: boolean }) { +export async function installBrowsers(args: string[], options: { withDeps?: boolean, force?: boolean, dryRun?: boolean, list?: boolean, shell?: boolean, onlyShell?: boolean, progress?: boolean, remove?: boolean }) { if (options.progress === false) process.env.PLAYWRIGHT_DOWNLOAD_NO_PROGRESS = '1'; if (isLikelyNpxGlobal()) { diff --git a/packages/playwright-core/src/cli/program.ts b/packages/playwright-core/src/cli/program.ts index efb1040a77678..cec10813fc804 100644 --- a/packages/playwright-core/src/cli/program.ts +++ b/packages/playwright-core/src/cli/program.ts @@ -83,7 +83,7 @@ export function decorateProgram(program: Command) { .option('--no-shell', 'do not install chromium headless shell') .option('--no-progress', 'do not show download progress bars') .option('--no-remove', 'do not remove unused browsers') - .action(async function(args: string[], options: { withDeps?: boolean, force?: boolean, dryRun?: boolean, list?: boolean, shell?: boolean, noShell?: boolean, onlyShell?: boolean, progress?: boolean, remove?: boolean }) { + .action(async function(args: string[], options: { withDeps?: boolean, force?: boolean, dryRun?: boolean, list?: boolean, shell?: boolean, onlyShell?: boolean, progress?: boolean, remove?: boolean }) { try { await installBrowsers(args, options); } catch (e) { diff --git a/packages/playwright-core/src/tools/cli-client/program.ts b/packages/playwright-core/src/tools/cli-client/program.ts index 3ac0efd0417f4..3279731070754 100644 --- a/packages/playwright-core/src/tools/cli-client/program.ts +++ b/packages/playwright-core/src/tools/cli-client/program.ts @@ -453,8 +453,12 @@ function validateFlags(args: MinimistArgs, command: { flags: Record { expect(output).toMatch(/chromium-\d+/); }); +test('install-browser --no-shell', async ({ cli }) => { + const withShell = await cli('install-browser', 'chromium', '--dry-run'); + expect(withShell.exitCode).toBe(0); + expect(withShell.output).toContain('chromium-headless-shell'); + const noShell = await cli('install-browser', 'chromium', '--no-shell', '--dry-run'); + expect(noShell.exitCode).toBe(0); + expect(noShell.output).toMatch(/chromium v\d+/); + expect(noShell.output).not.toContain('chromium-headless-shell'); +}); + test('install workspace', async ({ cli }, testInfo) => { const { output } = await cli('install'); expect(output).toContain(`Workspace initialized at`);