/** * Copyright (c) Microsoft Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { test, expect } from './cli-fixtures'; test('prints help', async ({ cli }) => { const { output } = await cli('--help'); expect(output).toContain('Usage: playwright-cli '); }); test('prints emulation help after storage', async ({ cli }) => { const { output } = await cli('--help'); const headings = output.split('\n').filter(line => /^[A-Z].*:$/.test(line)); expect(headings.indexOf('Emulation:')).toBe(headings.indexOf('Storage:') + 1); const emulationHelp = output.slice(output.indexOf('\nEmulation:'), output.indexOf('\nNetwork:')); expect(emulationHelp).toContain('set-color-scheme'); expect(emulationHelp).toContain('clear-color-scheme'); expect(emulationHelp).toContain('set-reduced-motion'); expect(emulationHelp).toContain('clear-reduced-motion'); expect(emulationHelp).toContain('set-forced-colors'); expect(emulationHelp).toContain('clear-forced-colors'); expect(emulationHelp).toContain('set-contrast'); expect(emulationHelp).toContain('clear-contrast'); expect(emulationHelp).toContain('set-media'); expect(emulationHelp).toContain('clear-media'); }); test('prints help by default', async ({ cli }) => { const { output } = await cli(); expect(output).toContain('Usage: playwright-cli '); }); test('prints command help', async ({ cli }) => { const { output } = await cli('click', '--help'); expect(output).toContain('playwright-cli click [button]'); }); test('prints variadic command help', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/42047' } }, async ({ cli }) => { const { output } = await cli('upload', '--help'); expect(output).toContain('playwright-cli upload '); }); test('prints agent skill path when running under a coding agent', async ({ cli }) => { const { output } = await cli('--help', { env: { CLAUDECODE: '1' } }); expect(output).toContain('Agent skill:'); });