Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Drive a browser from the terminal with Playwright snapshots, refs, and direct page actions.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/playwright-tests.md
1# Running Playwright Tests23To run Playwright tests, use the `npx playwright test` command, or a package manager script. To avoid opening the interactive html report, use `PLAYWRIGHT_HTML_OPEN=never` environment variable.45```bash6# Run all tests7PLAYWRIGHT_HTML_OPEN=never npx playwright test89# Run all tests through a custom npm script10PLAYWRIGHT_HTML_OPEN=never npm run special-test-command11```1213# Debugging Playwright Tests1415To debug a failing Playwright test, run it with `--debug=cli` option. This command will pause the test at the start and print the debugging instructions.1617**IMPORTANT**: run the command in the background and check the output until "Debugging Instructions" is printed. Make sure to stop the command after you have finished.1819Once instructions containing a session name are printed, use `playwright-cli` to attach the session and explore the page.2021```bash22# Run the test23PLAYWRIGHT_HTML_OPEN=never npx playwright test --debug=cli24# ...25# ... debugging instructions for "tw-abcdef" session ...26# ...2728# Attach to the test29playwright-cli attach tw-abcdef30```3132Keep the test running in the background while you explore and look for a fix.33The test is paused at the start, so you should step over or pause at a particular location34where the problem is most likely to be.3536Every action you perform with `playwright-cli` generates corresponding Playwright TypeScript code.37This code appears in the output and can be copied directly into the test. Most of the time, a specific locator or an expectation should be updated, but it could also be a bug in the app. Use your judgement.3839After fixing the test, stop the background test run. Rerun to check that test passes.40