Reporters In Playwright

Introduction

In this blog, we will look at the inbuilt reporters which are supported by Playwright Test Automation Tool.

Pre-requisite

Playwright Test Automation Project setup needs to be done in visual studio code.

The list of inbuilt reporters available in playwright are

  1. HTML
  2. Line
  3. Dot
  4. List
  5. JSON
  6. Junit

Let's look each one of those on how to configure those

HTML Reporter

Using this reporter we can view the test results as a HTML file in a browser.

Add HTML value as an array object to the reporter value.

reporter: [['html']]

After running the tests just run the below command in the CLI to generate the report.

npx playwright show-report

Line Reporter

Using this reporter we can view the test results in a single line to report last finished test and prints failures when they occur.

Add line value as a array object to the reporter value.

reporter: [['line']]

while running the tests use the reporter flag and provide the value line as an argument and run it.

npx playwright test login.spec.js --reporter='line'

Dot Reporter

  • Dot reporter is very concise - it only produces a single character per successful test run.
  • It is useful where you don't want a lot of output.

Add line value as a array object to the reporter value.

reporter: [['dot']]

while running the tests use the reporter flag and provide the value dot as an argument and run it.

npx playwright test login.spec.js --reporter='dot'

List Reporter

It prints a line for each test being run.
 
Add list value as an array object to the reporter value

reporter: [['list']]

while running the tests use the reporter flag and provide the value list as an argument and run it.

npx playwright test login.spec.js --reporter='list'

JSON Reporter

JSON reporter will display an object with all the details about the test run.

We need to configure the JSON output file path while configuring this report.

The result of the test run will get stored in the resulttestrun file in a .json format.

Add JSON value as an array object to the reporter value

reporter: [['json',
{ outputFile: 'resulttestrun.json' }]]

while running the tests use the reporter flag and provide the value JSON as an argument and run it.

npx playwright test login.spec.js --reporter='json'

Junit Reporter

JUnit reporter will display a JUnit-style XML report.

we need to configure the XML output file path while configuring this report. The result of the test run will get stored in the testresult file in a .xml format.

reporter: [['junit', { outputFile: 'testresult.xml' }]],

while running the tests use the reporter flag and provide the value JSON as an argument and run it.

npx playwright test login.spec.js --reporter='junit'

Summary

Hope this blog will be helpful for generating and setting up different inbuilt reporters in Playwright Test Automation Project.

Thanks..........

Happy learning..........

Next Recommended Reading Allure Report In Playwright