2021-05-27 20:30:03 -07:00
---
id: test-reporters
title: "Reporters"
---
<!-- TOC -->
## Using reporters
2021-07-18 12:07:45 +02:00
Playwright Test comes with a few built-in reporters for different needs and ability to provide custom reporters. The easiest way to try out built-in reporters is to pass `--reporter` [command line option ](./test-cli.md ).
2021-05-27 20:30:03 -07:00
2021-06-02 09:23:06 -07:00
```bash
2021-05-27 20:30:03 -07:00
npx playwright test --reporter=line
```
2021-05-31 20:17:15 -07:00
For more control, you can specify reporters programmatically in the [configuration file ](./test-configuration.md ).
2021-05-27 20:30:03 -07:00
2021-06-02 15:31:51 -07:00
```js js-flavor=js
2021-05-31 20:17:15 -07:00
// playwright.config.js
2021-06-21 19:56:30 +02:00
// @ts -check
/** @type {import('@playwright/test ').PlaywrightTestConfig} */
const config = {
2021-05-31 20:17:15 -07:00
reporter: 'line',
};
2021-06-21 19:56:30 +02:00
module.exports = config;
2021-05-31 20:17:15 -07:00
```
2021-06-02 15:31:51 -07:00
```js js-flavor=ts
2021-05-31 20:17:15 -07:00
// playwright.config.ts
2021-06-03 14:46:58 -07:00
import { PlaywrightTestConfig } from '@playwright/test ';
2021-05-27 20:30:03 -07:00
const config: PlaywrightTestConfig = {
2021-05-31 20:17:15 -07:00
reporter: 'line',
2021-05-27 20:30:03 -07:00
};
2021-05-31 20:17:15 -07:00
export default config;
```
2021-07-12 16:51:43 -07:00
### Multiple reporters
You can use multiple reporters at the same time. For example you can use`'list'` for nice terminal output and `'json'` to get a comprehensive json file with the test results.
```js js-flavor=js
// playwright.config.js
// @ts -check
/** @type {import('@playwright/test ').PlaywrightTestConfig} */
const config = {
reporter: [
['list'],
['json', { outputFile: 'test-results.json' }]
],
};
module.exports = config;
```
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test ';
const config: PlaywrightTestConfig = {
reporter: [
['list'],
['json', { outputFile: 'test-results.json' }]
],
};
export default config;
```
### Reporters on CI
You can use different reporters locally and on CI. For example, using concise `'dot'` reporter avoids too much output.
2021-05-27 20:30:03 -07:00
2021-06-02 15:31:51 -07:00
```js js-flavor=js
2021-05-31 20:17:15 -07:00
// playwright.config.js
2021-06-21 19:56:30 +02:00
// @ts -check
/** @type {import('@playwright/test ').PlaywrightTestConfig} */
const config = {
2021-07-12 16:51:43 -07:00
// Concise 'dot' for CI, default 'list' when running locally
reporter: process.env.CI ? 'dot' : 'list',
2021-05-27 20:30:03 -07:00
};
2021-06-21 19:56:30 +02:00
module.exports = config;
2021-05-31 20:17:15 -07:00
```
2021-06-02 15:31:51 -07:00
```js js-flavor=ts
2021-05-31 20:17:15 -07:00
// playwright.config.ts
2021-06-03 14:46:58 -07:00
import { PlaywrightTestConfig } from '@playwright/test ';
2021-05-27 20:30:03 -07:00
2021-05-31 20:17:15 -07:00
const config: PlaywrightTestConfig = {
2021-07-12 16:51:43 -07:00
// Concise 'dot' for CI, default 'list' when running locally
reporter: process.env.CI ? 'dot' : 'list',
2021-05-31 20:17:15 -07:00
};
2021-05-27 20:30:03 -07:00
export default config;
```
## Built-in reporters
All built-in reporters show detailed information about failures, and mostly differ in verbosity for successful runs.
### List reporter
2021-05-31 20:17:15 -07:00
List reporter is default. It prints a line for each test being run.
2021-06-02 09:23:06 -07:00
```bash
2021-05-31 20:17:15 -07:00
npx playwright test --reporter=list
```
2021-05-27 20:30:03 -07:00
2021-06-02 15:31:51 -07:00
```js js-flavor=js
2021-05-31 20:17:15 -07:00
// playwright.config.js
2021-06-21 19:56:30 +02:00
// @ts -check
/** @type {import('@playwright/test ').PlaywrightTestConfig} */
const config = {
2021-05-31 20:17:15 -07:00
reporter: 'list',
};
2021-06-21 19:56:30 +02:00
module.exports = config;
2021-05-31 20:17:15 -07:00
```
2021-06-02 15:31:51 -07:00
```js js-flavor=ts
2021-05-31 20:17:15 -07:00
// playwright.config.ts
2021-06-03 14:46:58 -07:00
import { PlaywrightTestConfig } from '@playwright/test ';
2021-05-31 20:17:15 -07:00
const config: PlaywrightTestConfig = {
2021-05-27 20:30:03 -07:00
reporter: 'list',
};
export default config;
```
Here is an example output in the middle of a test run. Failures will be listed at the end.
2021-06-02 09:23:06 -07:00
```bash
2021-05-27 20:30:03 -07:00
npx playwright test --reporter=list
Running 124 tests using 6 workers
✓ should access error in env (438ms)
✓ handle long test names (515ms)
x 1) render expected (691ms)
✓ should timeout (932ms)
should repeat each:
✓ should respect enclosing .gitignore (569ms)
should teardown env after timeout:
should respect excluded tests:
✓ should handle env beforeEach error (638ms)
should respect enclosing .gitignore:
```
### Line reporter
2021-05-31 20:17:15 -07:00
Line reporter is more concise than the list reporter. It uses a single line to report last finished test, and prints failures when they occur. Line reporter is useful for large test suites where it shows the progress but does not spam the output by listing all the tests.
2021-06-02 09:23:06 -07:00
```bash
2021-05-31 20:17:15 -07:00
npx playwright test --reporter=line
```
2021-05-27 20:30:03 -07:00
2021-06-02 15:31:51 -07:00
```js js-flavor=js
2021-05-31 20:17:15 -07:00
// playwright.config.js
2021-06-21 19:56:30 +02:00
// @ts -check
/** @type {import('@playwright/test ').PlaywrightTestConfig} */
const config = {
2021-05-31 20:17:15 -07:00
reporter: 'line',
};
2021-06-21 19:56:30 +02:00
module.exports = config;
2021-05-31 20:17:15 -07:00
```
2021-06-02 15:31:51 -07:00
```js js-flavor=ts
2021-05-31 20:17:15 -07:00
// playwright.config.ts
2021-06-03 14:46:58 -07:00
import { PlaywrightTestConfig } from '@playwright/test ';
2021-05-31 20:17:15 -07:00
const config: PlaywrightTestConfig = {
2021-05-27 20:30:03 -07:00
reporter: 'line',
};
export default config;
```
Here is an example output in the middle of a test run. Failures are reported inline.
2021-06-02 09:23:06 -07:00
```bash
2021-05-27 20:30:03 -07:00
npx playwright test --reporter=line
Running 124 tests using 6 workers
1) dot-reporter.spec.ts:20:1 › render expected ===================================================
Error: expect(received).toBe(expected) // Object.is equality
Expected: 1
Received: 0
[23/124] gitignore.spec.ts - should respect nested .gitignore
```
### Dot reporter
2021-05-31 20:17:15 -07:00
Dot reporter is very concise - it only produces a single character per successful test run. It is useful on CI where you don't want a lot of output.
2021-06-02 09:23:06 -07:00
```bash
2021-05-31 20:17:15 -07:00
npx playwright test --reporter=dot
```
2021-05-27 20:30:03 -07:00
2021-06-02 15:31:51 -07:00
```js js-flavor=js
2021-05-31 20:17:15 -07:00
// playwright.config.js
2021-06-21 19:56:30 +02:00
// @ts -check
/** @type {import('@playwright/test ').PlaywrightTestConfig} */
const config = {
2021-05-31 20:17:15 -07:00
reporter: 'dot',
};
2021-06-21 19:56:30 +02:00
module.exports = config;
2021-05-31 20:17:15 -07:00
```
2021-06-02 15:31:51 -07:00
```js js-flavor=ts
2021-05-31 20:17:15 -07:00
// playwright.config.ts
2021-06-03 14:46:58 -07:00
import { PlaywrightTestConfig } from '@playwright/test ';
2021-05-31 20:17:15 -07:00
const config: PlaywrightTestConfig = {
2021-05-27 20:30:03 -07:00
reporter: 'dot',
};
export default config;
```
Here is an example output in the middle of a test run. Failures will be listed at the end.
2021-06-02 09:23:06 -07:00
```bash
2021-05-27 20:30:03 -07:00
npx playwright test --reporter=dot
Running 124 tests using 6 workers
······F·············································
```
### JSON reporter
JSON reporter produces an object with all information about the test run. It is usually used together with some terminal reporter like `dot` or `line` .
2021-05-31 20:17:15 -07:00
Most likely you want to write the JSON to a file. When running with `--reporter=json` , use `PLAYWRIGHT_JSON_OUTPUT_NAME` environment variable:
2021-06-02 09:23:06 -07:00
```bash
2021-05-31 20:17:15 -07:00
PLAYWRIGHT_JSON_OUTPUT_NAME=results.json npx playwright test --reporter=json,dot
2021-05-27 20:30:03 -07:00
```
In configuration file, pass options directly:
2021-06-02 15:31:51 -07:00
```js js-flavor=js
2021-05-31 20:17:15 -07:00
// playwright.config.js
2021-06-21 19:56:30 +02:00
// @ts -check
/** @type {import('@playwright/test ').PlaywrightTestConfig} */
const config = {
2021-06-03 22:06:59 -07:00
reporter: [ ['json', { outputFile: 'results.json' }] ],
2021-05-31 20:17:15 -07:00
};
2021-06-21 19:56:30 +02:00
module.exports = config;
2021-05-31 20:17:15 -07:00
```
2021-06-02 15:31:51 -07:00
```js js-flavor=ts
2021-05-31 20:17:15 -07:00
// playwright.config.ts
2021-06-03 14:46:58 -07:00
import { PlaywrightTestConfig } from '@playwright/test ';
2021-05-31 20:17:15 -07:00
const config: PlaywrightTestConfig = {
2021-06-03 22:06:59 -07:00
reporter: [ ['json', { outputFile: 'results.json' }] ],
2021-05-27 20:30:03 -07:00
};
export default config;
```
### JUnit reporter
JUnit reporter produces a JUnit-style xml report. It is usually used together with some terminal reporter like `dot` or `line` .
2021-05-31 20:17:15 -07:00
Most likely you want to write the report to an xml file. When running with `--reporter=junit` , use `PLAYWRIGHT_JUNIT_OUTPUT_NAME` environment variable:
2021-06-02 09:23:06 -07:00
```bash
2021-05-31 20:17:15 -07:00
PLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml npx playwright test --reporter=junit,line
2021-05-27 20:30:03 -07:00
```
In configuration file, pass options directly:
2021-06-02 15:31:51 -07:00
```js js-flavor=js
2021-05-31 20:17:15 -07:00
// playwright.config.js
2021-06-21 19:56:30 +02:00
// @ts -check
/** @type {import('@playwright/test ').PlaywrightTestConfig} */
const config = {
2021-06-03 22:06:59 -07:00
reporter: [ ['junit', { outputFile: 'results.xml' }] ],
2021-05-31 20:17:15 -07:00
};
2021-06-21 19:56:30 +02:00
module.exports = config;
2021-05-31 20:17:15 -07:00
```
2021-06-02 15:31:51 -07:00
```js js-flavor=ts
2021-05-31 20:17:15 -07:00
// playwright.config.ts
2021-06-03 14:46:58 -07:00
import { PlaywrightTestConfig } from '@playwright/test ';
2021-05-31 20:17:15 -07:00
const config: PlaywrightTestConfig = {
2021-06-03 22:06:59 -07:00
reporter: [ ['junit', { outputFile: 'results.xml' }] ],
2021-05-27 20:30:03 -07:00
};
export default config;
2021-05-31 20:17:15 -07:00
```