Self-Healing Tests with Playwright Trace | Bondar Academy
Course: Claude Code for Playwright
Module: Playwright Workflows with Claude Code
Instructor: Artem Bondar
Lesson Summary
PlayWrite CLI offers a powerful feature for reading trace reports , which can be utilized for dynamic debugging of tests. This allows agents to access crucial information when a test fails, including: Action commands Logs All screenshots Network activities By analyzing this data, agents can automatically fix tests after execution failures. This process is related to the step debug skill previously discussed, but can also be performed separately. Debugging Process To illustrate the debugging process, the video demonstrates intentionally failing a test that validates the visibility of a header title. The test is designed to check the h1 tag, but changing it to h2 causes a failure. Steps to Debug Run the test with trace enabled to generate a report. Use the Playwright CLI trace reporter to read the trace. Analyze the trace actions, snapshots, console logs, and errors. Close the trace and attempt to fix the test. The agent is prompted to select the test for debugging, and upon execution, it generates a trace report. The agent analyzes the details of the failed test, identifies that the source code renders the title in h1 instead of h2 , and updates the test accordingly. This feature of PlayWrite CLI significantly aids in understanding test failures and provides solutions to fix them efficiently, enhancing the debugging experience.