Command line
#
ExamplesHere are the most common options available in the command line.
Run all the tests
npx playwright test
Run a single test file
npx playwright test tests/todo-page.spec.ts
Run a set of test files
npx playwright test tests/todo-page/ tests/landing-page/
Run files that have
my-spec
ormy-spec-2
in the file namenpx playwright test my-spec my-spec-2
Run the test with the title
npx playwright test -g "add a todo item"
Run tests in headed browsers
npx playwright test --headed
Run tests in a particular browser (config-less mode)
npx playwright test --browser=webkit
Run tests in all browsers (config-less mode)
npx playwright test --browser=all
Disable parallelization
npx playwright test --workers=1
Choose a reporter
npx playwright test --reporter=dot
Run in debug mode with Playwright Inspector
npx playwright test --debug
Ask for help
npx playwright test --help
#
ReferenceComplete set of Playwright Test options is available in the configuration file. Following options can be passed to a command line and take a priority over the configuration file:
--headed
: Run tests in headed browsers. Useful for debugging.--browser
: Run test in a specific browser. Available options are"chromium"
,"firefox"
,"webkit"
or"all"
to run tests in all three browsers at the same time.--debug
: Run tests with Playwright Inspector. Shortcut forPWDEBUG=1
environment variable and--timeout=0 --maxFailures=1 --headed --workers=1
options-c <file>
or--config <file>
: Configuration file. If not passed, defaults toplaywright.config.ts
orplaywright.config.js
in the current directory.-c <dir>
or--config <dir>
: Directory with the tests to run without configuration file.--forbid-only
: Whether to disallowtest.only
. Useful on CI.-g <grep>
or--grep <grep>
: Only run tests matching this regular expression. For example, this will run'should add to cart'
when passed-g="add to cart"
.--grep-invert <grep>
: Only run tests not matching this regular expression. The opposite of--grep
.--global-timeout <number>
: Total timeout for the whole test run in milliseconds. By default, there is no global timeout.--list
: List all the tests, but do not run them.--max-failures <N>
or-x
: Stop after the firstN
test failures. Passing-x
stops after the first failure.--output <dir>
: Directory for artifacts produced by tests, defaults totest-results
.--project <name>
: Only run tests from one of the specified projects. Defaults to running all projects defined in the configuration file.--quiet
: Whether to suppress stdout and stderr from the tests.--repeat-each <N>
: Run each testN
times, defaults to one.--reporter <reporter>
: Choose a reporter: minimalistdot
, conciseline
or detailedlist
. See reporters for more information.--retries <number>
: The maximum number of retries for flaky tests, defaults to zero (no retries).--shard <shard>
: Shard tests and execute only selected shard, specified in the formcurrent/all
, 1-based, for example3/5
.--timeout <number>
: Maximum timeout in milliseconds for each test, defaults to 30 seconds.--update-snapshots
or-u
: Whether to update snapshots with actual results instead of comparing them. Use this when snapshot expectations have changed.--workers <number>
or-j <number>
: The maximum number of concurrent worker processes that run in parallel.