Playwright + TS · Lesson 36 of 36
Module 36: Reporting & Failure Diagnosis
Try it yourself
Implement calculatePassRatePercentage:
The editor has a worked example. Read it, tweak it, then press Mark as complete.
In this lesson
Playwright comes with an interactive, zero-dependency HTML report generator:
# View last test execution report:
npx playwright show-reportFeatures of the HTML Report:
Configure both visual HTML and machine-readable JUnit/JSON outputs:
export default defineConfig({
reporter: [
["html", { outputFolder: "playwright-report", open: "never" }],
["junit", { outputFile: "results.xml" }],
["json", { outputFile: "results.json" }],
["list"],
],
});When an assertion or action fails, Playwright prints a comprehensive log:
locator.click: Timeout 5000ms exceeded.
Call log:
- waiting for getByRole('button', { name: 'Save' })
- locator resolved to <button disabled>Save</button>
- unexpected value: element is disabledNotice how this instantly tells you the problem: the button exists, but was disabled!
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.
The 'playwright-report/' directory is a completely static website. Simply upload that folder as a CI artifact or deploy to GitHub Pages.
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.