Playwright + TS · Lesson 36 of 36

0/36 done

Module 36: Reporting & Failure Diagnosis

36. Rich HTML Reporting & Root-Cause Failure Diagnosis

18 minlesson

Try it yourself

Implement calculatePassRatePercentage:

  1. Accept summary object { passed: number; failed: number; flaky: number }.
  2. Calculate total and return (passed / total) * 100 rounded to 1 decimal place. If total is 0, return 0.

The editor has a worked example. Read it, tweak it, then press Mark as complete.

Playwright HTML Reporter

Playwright comes with an interactive, zero-dependency HTML report generator:

bash
# View last test execution report:
npx playwright show-report

Features of the HTML Report:

  1. Filter by Status: Passed, Failed, Flaky, Skipped.
  2. Filter by Project: Chromium, Firefox, WebKit.
  3. Step-by-Step Breakdown: Every action with millisecond timing.
  4. Call Log: Complete actionability log showing what Playwright waited for.
  5. Direct Trace Link: Click one button to launch Trace Viewer.

Multiple Reporters in CI

Configure both visual HTML and machine-readable JUnit/JSON outputs:

typescript
export default defineConfig({
  reporter: [
    ["html", { outputFolder: "playwright-report", open: "never" }],
    ["junit", { outputFile: "results.xml" }],
    ["json", { outputFile: "results.json" }],
    ["list"],
  ],
});

Reading Actionability Call Logs

When an assertion or action fails, Playwright prints a comprehensive log:

text
locator.click: Timeout 5000ms exceeded.
Call log:
  - waiting for getByRole('button', { name: 'Save' })
  - locator resolved to <button disabled>Save</button>
  - unexpected value: element is disabled

Notice how this instantly tells you the problem: the button exists, but was disabled!

Key Takeaways & Walkthrough Summary

Congratulations on completing the entire curriculum! In this final module, we will explore Playwright's rich HTML reporting and failure diagnosis. You will learn how to analyze step-by-step actionability call logs, attach debug artifacts, and generate clean reports for your engineering team. Thank you for learning with TargetQA, and happy testing!

Part of the Playwright + TS course (Playwright with TypeScript). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.

Common Doubts & Lesson Q&A

How can I publish Playwright HTML reports on GitHub Pages or S3?

The 'playwright-report/' directory is a completely static website. Simply upload that folder as a CI artifact or deploy to GitHub Pages.

Can I attach custom screenshots or text logs to the HTML report?

Yes! Inside any test or fixture, call: await testInfo.attach('my-log', { body: 'text content', contentType: 'text/plain' });

Finished reading?

Review the worked example in the editor, then mark the lesson complete.

Back to course overview
TypeScript
Finish course