Update Playwright Tests to Output in JUnit XML Format for Import Into Testery

In this article, we'll guide you through the process of updating your Playwright tests to output results in JUnit XML format, allowing you to seamlessly integrate them into your CI/CD pipeline. Prere


Before you begin, make sure you have the following prerequisites in place:

  1. Playwright Installed: Ensure that you have Playwright installed in your project. You can install it using npm:

    npm install playwright --save-dev
  2. Node.js: Make sure you have Node.js installed on your machine.

  3. A Playwright Test Suite: You should have a Playwright test suite already set up and running.

  4. Testery CLI: You will need the Testery CLI to upload your JUnit XML files to Testery. If you don't have it installed, you can do so using pip:

    pip install testery

Step 1: Install Playwright JUnit Reporter

To generate JUnit XML reports for your Playwright tests, you'll need to install the playwright-junit-reporter package. This package provides a custom reporter for Playwright that converts test results into JUnit XML format.

Open your project's terminal and run the following command to install the package:

npm install playwright-junit-reporter --save-dev

Step 2: Update Your Playwright Configuration

Now that you have the JUnit reporter installed, you need to update your Playwright configuration to use it.

  1. Open your Playwright configuration file, which is usually named playwright.config.js.

  2. Add a "reporter" option to specify the reporter you want to use. Set it to "junit":

module.exports = {
  reporter: 'junit',
  // Other configuration options...
  1. Optionally, you can configure the reporter with additional options. For instance, you can specify the output folder for the JUnit XML files:

module.exports = {
  reporter: 'junit',
  reporterOptions: {
    outputFile: 'playwright/reports/junit/test-results.xml',
  // Other configuration options...

This configuration will save the JUnit XML reports in a playwright/reports/junit folder with a filename of test-results.xml.

Step 3: Run Your Playwright Tests

With your Playwright configuration updated, you can now run your tests as usual. Playwright will automatically use the JUnit reporter to generate XML reports.

To run your tests, use the following command:

npx playwright test

After running the tests, you should see JUnit XML files generated in the specified output folder.

Step 4: Upload Your Test Results to Testery

The final step is to upload the generated JUnit XML files to Testery for further analysis. The exact steps for this may vary depending on your CI/CD platform. Here's a general outline of what you'll need to do:

testery upload-results \
  --environment develop \
  --project name \
  --file playwright/reports/junit/test-results.xml

Replace environment with your specific environment, project with your project name, and adjust the file path accordingly. This step ensures that your Playwright test results are accessible and can be used for monitoring and debugging within Testery.


By updating your Playwright tests to output results in JUnit XML format, you streamline the integration of your tests into your CI/CD pipeline. This standardized format enables you to easily monitor test results, track failures, and ensure the reliability of your web applications across different environments.

Last updated