How to set Playwright reporters

Playwright test output needs to fit both the terminal where a run starts and the place where results are reviewed later. A local run benefits from readable per-test progress, while automated runs often need a saved report that can be kept with the job artifacts.

Reporter settings live in the reporter option of playwright.config.ts or playwright.config.js. A single reporter can be written as a string, and multiple reporters use an array where each entry can include reporter-specific options.

Pairing list with html gives readable terminal output and a generated playwright-report directory from the same run. Use open: 'never' for the HTML reporter when the run should write the report without trying to launch a browser.

Steps to set Playwright reporters:

  1. Open playwright.config.ts in the Playwright project root.
  2. Set the reporter array in the config file.
    import { defineConfig } from '@playwright/test';
    
    export default defineConfig({
      reporter: [
        ['list'],
        ['html', { open: 'never' }]
      ],
    });

    Use a command-line override such as npx playwright test --reporter=line only for a one-time run. The config file keeps the reporter choice with the project.

  3. Run the test suite.
    $ npx playwright test
    
    Running 1 test using 1 worker
    
      ✓  1 tests/home.spec.ts:3:5 › home page shows ready state (7ms)
    
      1 passed (595ms)
  4. Check that the HTML report was written.
    $ ls playwright-report/index.html
    playwright-report/index.html