Playwright Console Reporter
playwright-console-reporter is a custom console reporter for Playwright tests, currently at version 1.0.2. It enhances the standard Playwright console output by capturing detailed test steps and results, then transforming them into structured, human-readable reports directly within the terminal. This provides developers with immediate, in-depth insights into test suite performance and execution flow, allowing for quick analysis of failures and bottlenecks without the need to navigate external HTML or JUnit report files. The package is actively maintained, with releases likely following Playwright's own update cadence or as features and bug fixes are introduced. Its key differentiator lies in its focus on comprehensive, structured console logging, contrasting with Playwright's built-in `list` or `dot` reporters which offer less detail, or `html`/`json` reporters which require opening separate files for detailed review. It aims to streamline debugging and daily development workflows by keeping all relevant test information visible in the terminal.
Common errors
-
Detailed reporter output is truncated or missing in the console.
cause The Playwright test runner's TTY detection is active, which can suppress detailed console output from custom reporters in non-interactive terminal environments (e.g., CI/CD, or some IDE terminals).fixSet the environment variable `PLAYWRIGHT_FORCE_TTY=false` before running your Playwright tests. For example: `PLAYWRIGHT_FORCE_TTY=false npx playwright test`.
Warnings
- gotcha Detailed console output from the reporter may not appear as expected if the `PLAYWRIGHT_FORCE_TTY` environment variable is not set correctly. Playwright's default TTY detection can sometimes prevent full console reports in CI/CD environments or certain local setups.
Install
-
npm install playwright-console-reporter -
yarn add playwright-console-reporter -
pnpm add playwright-console-reporter
Imports
- Reporter Configuration String
import { PlaywrightConsoleReporter } from 'playwright-console-reporter';reporter: [['playwright-console-reporter', {}]] - PlaywrightTestConfig
import PlaywrightTestConfig from '@playwright/test';
import { PlaywrightTestConfig } from '@playwright/test'; - ConsoleReporter (Class)
const ConsoleReporter = require('playwright-console-reporter');import { ConsoleReporter } from 'playwright-console-reporter';
Quickstart
import { PlaywrightTestConfig } from '@playwright/test';
let reporters: PlaywrightTestConfig['reporter'] = [
['junit', { outputFile: 'build/results.xml' }],
['html', { outputFolder: 'build/html-report', open: 'never' }],
['list']
];
// Add the console reporter
reporters.push(['playwright-console-reporter', {}]);
const config: PlaywrightTestConfig = {
reporter: reporters,
// other Playwright configurations...
};
export default config;
// To ensure detailed reports are printed line by line, set this environment variable before running tests:
// PLAYWRIGHT_FORCE_TTY=false