Menu

1 / 2

How I built an AI reporter for Playwright that explains test failures

DEV Community·Santiago Echavarria·6 months ago
#dNxe6bDN
Reading 0:00
15s threshold

After 6 years doing QA automation in Fintech, I got tired of the same cycle:

Test fails in CI

Download the report

Spend 20 minutes reading stack traces

Realize it was a one-line selector issue

So I built a custom Playwright reporter that does the debugging for you.

What it does

When a test fails, the reporter automatically:

Captures the test name, error message, and stack trace

Sends it to an AI with a structured prompt

Gets back a root cause, a TypeScript fix, and a prevention tip

Saves everything to test-results/ai-diagnosis.md

Here's what the output looks like:

❌ Login › locked out user sees lock message

🔍 Analyzing failure: "locked out user sees lock message"

❌ locked out user sees lock message

1. Root cause

The selector [data-test="error"] matched but the assertion

expected different text than what Sauce Demo returned.

2. Fix

await expect ( loginPage . errorMessage ). toContainText ( ' Epic sadface: Sorry, this user has been locked out.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.