feat(test-runner): add --debug CLI flag (#8938)

This commit is contained in:
Max Schmitt 2021-09-15 21:19:31 +02:00 committed by GitHub
parent 96355b3a7a
commit 131239569d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 21 deletions

View File

@ -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 help

View File

@ -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.

View File

@ -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) {