Playwright HTML Report Not Generating Fix
In this tutorial, you'll learn about Playwright HTML Report Not Generating Fix. We cover key concepts, practical examples, and best practices.
After running tests, no HTML report is generated — you can't view the visual test results with screenshots and traces.
The Problem
# WRONG — running tests without report configuration
npx playwright test
Tests: 12 passed, 12 total
# No report generated
By default, Playwright uses the list reporter which only shows results in the terminal. The HTML reporter must be explicitly configured.
Step-by-Step Fix
1. Configure HTML reporter
// RIGHT — playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
reporter: 'html',
});
2. Use multiple reporters
// RIGHT — combine reporters
export default defineConfig({
reporter: [
['html'], // HTML report for viewing
['list'], // Terminal output during run
['json', { outputFile: 'results.json' }], // JSON for CI
],
});
3. Configure report output
// RIGHT — report options
export default defineConfig({
reporter: [
['html', {
outputFolder: 'playwright-report', // Default
open: 'never', // Don't auto-open
host: '0.0.0.0', // Host for viewer
port: 9323, // Port for viewer
}],
],
});
4. View the report
# RIGHT — view HTML report
npx playwright show-report
# Specify custom folder
npx playwright show-report playwright-report
# Or open manually
open playwright-report/index.html
5. CI integration
# RIGHT — generate report in CI
npx playwright test --reporter=html
# Serve report for debugging
npx playwright show-report --host=0.0.0.0 --port=9323
Expected output:
✓ 12 tests passed (2.5s)
To open last HTML report run:
npx playwright show-report
The HTML report shows test results with pass/fail status, duration, and links to traces and videos.
Prevention Tips
- Configure
reporter: 'html'in<a href="/testing-qa/playwright/">playwright</a>.config.ts - Use multiple reporters for terminal + HTML output
- Set
open: 'never'in CI to avoid blocking - Serve the report on a port for remote viewing
- Publish report artifacts in CI
Common Mistakes with report html
- Non-exhaustive pattern matches that compile with warnings then crash at runtime
- Misunderstanding that
Stringis[Char]with poor performance for large text operations - Using
foldlinstead offoldl'causing stack overflow on large lists
These mistakes appear frequently in real-world PLAYWRIGHT code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro