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
feat(test-runner): add --debug CLI flag (#8938)
Max Schmitt131239569d56
diff --git a/docs/src/intro-js.md b/docs/src/intro-js.mdindex c82f9b64d7..236103128f 100644--- a/docs/src/intro-js.md+++ b/docs/src/intro-js.md@@ -285,16 +285,7 @@ Following are the usual command line patterns. Learn more about the [command lin- Run in debug mode with [Playwright Inspector](./inspector.md)```bash- # Linux/macOS- PWDEBUG=1 npx playwright test-- # Windows with cmd.exe- set PWDEBUG=1- npx playwright test-- # Windows with PowerShell- $env:PWDEBUG=1- npx playwright test+ npx playwright test --debug```- Ask for helpdiff --git a/docs/src/test-cli-js.md b/docs/src/test-cli-js.mdindex 8f83014435..1fb96cd9c0 100644--- a/docs/src/test-cli-js.md+++ b/docs/src/test-cli-js.md@@ -61,16 +61,7 @@ Here are the most common options available in the command line.- Run in debug mode with [Playwright Inspector](./inspector.md)```bash- # Linux/macOS- PWDEBUG=1 npx playwright test-- # Windows with cmd.exe- set PWDEBUG=1- npx playwright test-- # Windows with PowerShell- $env:PWDEBUG=1- npx playwright test+ npx playwright test --debug```- Ask for help@@ -86,6 +77,8 @@ Complete set of Playwright Test options is available in the [configuration file]- `--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 for `PWDEBUG=1` environment variable and `--timeout=0 --maxFailures=1 --headed --workers=1` options+- `-c <file>` or `--config <file>`: Configuration file. If not passed, defaults to `playwright.config.ts` or `playwright.config.js` in the current directory.- `-c <dir>` or `--config <dir>`: Directory with the tests to run without configuration file.diff --git a/src/test/cli.ts b/src/test/cli.tsindex d3264a7d12..f4cacdb5db 100644--- a/src/test/cli.ts+++ b/src/test/cli.ts@@ -44,6 +44,7 @@ export function addTestCommand(program: commander.CommanderStatic) {command.description('Run tests with Playwright Test');command.option('--browser <browser>', `Browser to use for tests, one of "all", "chromium", "firefox" or "webkit" (default: "chromium")`);command.option('--headed', `Run tests in headed browsers (default: headless)`);+ command.option('--debug', `Run tests with Playwright Inspector. Shortcut for "PWDEBUG=1" environment variable and "--timeout=0 --maxFailures=1 --headed --workers=1" options`);command.option('-c, --config <file>', `Configuration file, or a test directory with optional "${tsConfig}"/"${jsConfig}"`);command.option('--forbid-only', `Fail if test.only is called (default: false)`);command.option('-g, --grep <grep>', `Only run tests matching this regular expression (default: ".*")`);@@ -97,8 +98,14 @@ async function createLoader(opts: { [key: string]: any }): Promise<Loader> {}const overrides = overridesFromOptions(opts);- if (opts.headed)+ if (opts.headed || opts.debug)overrides.use = { headless: false };+ if (opts.debug) {+ overrides.maxFailures = 1;+ overrides.timeout = 0;+ overrides.workers = 1;+ process.env.PWDEBUG = '1';+ }const loader = new Loader(defaultConfig, overrides);async function loadConfig(configFile: string) {