DEV Community

TestDino
TestDino

Posted on

Mistake 14/14: Not using the tools Playwright already gives you

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
Enter fullscreen mode Exit fullscreen mode

UI Mode

Run tests in an interactive mode and watch them execute with time-travel debugging.

npx playwright test --ui
Enter fullscreen mode Exit fullscreen mode

Codegen

Generate locators and actions by recording browser interactions.

npx playwright codegen https://your-app.com
Enter fullscreen mode Exit fullscreen mode

Last failed

Re-run only the tests that failed, not the whole suite.

npx playwright test --last-failed
Enter fullscreen mode Exit fullscreen mode

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"
  }
}
Enter fullscreen mode Exit fullscreen mode

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)