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(cli): accept install-browser --no-shell (#42871)
Yury Semikhatsky04067898a9e8
diff --git a/packages/playwright-core/src/cli/installActions.ts b/packages/playwright-core/src/cli/installActions.tsindex b2aefc2121..1c5dc75038 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.tsindex efb1040a77..cec10813fc 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.tsindex 3ac0efd041..3279731070 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<string, 'boocontinue;if ((globalOptions as readonly string[]).includes(key))continue;- if (!(key in command.flags))- unknownFlags.push(key);+ if (key in command.flags)+ continue;+ // Negated flags like '--no-shell' are parsed as { shell: false }.+ if (args[key] === false && `no-${key}` in command.flags)+ continue;+ unknownFlags.push(key);}if (unknownFlags.length)output.errorUnknownOption(unknownFlags, command.help);diff --git a/tests/mcp/cli-misc.spec.ts b/tests/mcp/cli-misc.spec.tsindex 7d825e8113..546ebae889 100644--- a/tests/mcp/cli-misc.spec.ts+++ b/tests/mcp/cli-misc.spec.ts@@ -33,6 +33,16 @@ test('install-browser', async ({ cli, server, mcpBrowser }) => {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`);