Skip to content

Playwright interactive cli prompts to select and run specs, tests or tags

License

Notifications You must be signed in to change notification settings

dennisbergevin/playwright-cli-select

Repository files navigation

🎭 Playwright cli-select

Playwright interactive cli prompts to select and run specs, tests or tags.

playwright-cli-select demo

Features

  • ❓ New interactive CLI prompts to select and run specs, tests or tags
  • 🎭 A new playwright test command to allow user to pass desired arguments

External Resources

Table of Contents


Installation

Install the following package:

npm install --save-dev playwright-cli-select
# within your Playwright repository as dev dependency

Or:

npm install -g playwright-cli-select
# global install

Run mode

Run the following command in your Playwright repository:

npx playwright-cli-select run

If you want to skip straight to selecting specs, titles and/or tags:

npx playwright-cli-select run --specs
# skips straight to spec selection
npx playwright-cli-select run --titles
# skips to test title selection
npx playwright-cli-select run --tags
# skips to tag selection
npx playwright-cli-select run --titles --tags
# skips to test title selection, followed by tag selection
# Any combination of `--specs`, `--titles` and/or `--tags` parameters is permitted.

playwright-cli-select --specs --titles --tags demo


Command line arguments

You can also include more cli arguments similar to npx playwright test:

npx playwright-cli-select run --project firefox webkit

Using last failed

Passing Playwright's --last-failed parameter filters the available selections in each prompt to the last failed tests.

Using this package, you can further drill down on specific tests within the last failed tests:

npx playwright-cli-select run --last-failed

playwright-cli-select --last-failed demo


Using only changed

Passing Playwright's --only-changed parameter filters available selections to the changed tests detected.

To specify a specific subset of changed tests rather than running entire changed test files:

npx playwright-cli-select run --only-changed

playwright-cli-select --only-changed demo


UI mode

You can append the --ui or --headed parameters to open a browser and view selected specs, test titles and/or tags:

npx playwright-cli-select run --ui

Or:

npx playwright-cli-select run --titles --headed
# Example of choosing only test titles to run headed

Keyboard controls

Keys Action
Up Move to selection above current
Down Move to selection below current
Tab Select current
Ctrl + a Select all
Backspace Remove selection
Enter Proceed
Ctrl + c Exit

Note: You can also filter choices displayed in list by typing


Help mode

To open the cli help menu, pass the --help flag:

npx playwright-cli-select run --help

playwright-cli-select help menu


Submit focused

When no other options are already selected, automatically select the currently focused option with Enter.

To enable this feature, pass the following flag:

npx playwright-cli-select run --submit-focused

Optional path to test list json

This package uses the npx playwright test --list --reporter=json command to gather information about Playwright tests.

If you prefer or already house the data from this command in a file, pass the path to the file via the --json-data-path parameter:

npx playwright-cli-select run --json-data-path data/sample-test-list.json

Using a custom playwright config file

If you want to use a custom Playwright config, pass it via the -c or --config flag:

npx playwright-cli-select run --config playwright.staging.config.js

Or:

npx playwright-cli-select run -c playwright.dev.config.js

Setting up a npm script

For convenience, you may desire to house the npx command within an npm script in your project's package.json, including any desired cli arguments:

  "scripts": {
    "pw:select": "npx playwright-cli-select run --project=firefox"
  }

Contributions

Feel free to open a pull request or drop any feature request or bug in the issues.

Please see more details in the contributing doc.

About

Playwright interactive cli prompts to select and run specs, tests or tags

Resources

License

Stars

Watchers

Forks

Packages

No packages published