This is the final mistake in the series.
A lot of teams still debug failed tests the hard way:
- read the error
- add a console log
- re-run the suite
- repeat
That works, but it is slow.
Playwright already ships with tools that make debugging much easier:
Trace Viewer
Replay a failed run step by step and inspect DOM state, actions, network calls, and timing.
npx playwright show-trace trace.zip
UI Mode
Run tests in an interactive mode and watch them execute with time-travel debugging.
npx playwright test --ui
Codegen
Generate locators and actions by recording browser interactions.
npx playwright codegen https://your-app.com
Last failed
Re-run only the tests that failed, not the whole suite.
npx playwright test --last-failed
Use scripts
You can also add these to package.json so the team actually uses them regularly.
{
"scripts": {
"test": "npx playwright test",
"test:ui": "npx playwright test --ui",
"test:failed": "npx playwright test --last-failed",
"test:trace": "npx playwright show-trace trace.zip",
"codegen": "npx playwright codegen"
}
}
The biggest lesson from this series is simple: Most debugging pain is not caused by missing tools. It is caused by not using the tools you already have.
Top comments (0)