Testery Docs
TesteryFeaturesPricingRelease Notes
  • Testery Documentation
  • Release Notes
  • Get Started
    • Getting Started Guide
      • Create a Testery Account
      • Configure Your Project
      • Run Your Tests
      • Configure Slack Alerts
      • Schedule Your Test Runs
      • Invite Your Team
      • Get More From Testery
  • Get to Know Testery
    • Dashboard
    • Test Runs
      • Test Selection Rules
    • Projects
    • Test Triggers
    • Environments
    • Alerts
    • Settings
    • Test Plans
    • Test Stacks
      • Python
      • Node.js 16 End of Life
      • Default Chrome Version Change
      • Python 3.8 End of Life
    • Deployments
    • System Variables
    • Tags
    • Screenshots
    • Uploading Test Artifacts to Testery
    • Setting Test Execution Priority
    • Setting the Number of Parallel Tests
  • Integrate with Testery
    • Built-In Integrations with Testery
      • Jira
      • Slack
    • CI/CD Integration Guides
      • Azure Devops Pipelines
      • Set Up CircleCI to Run Testery Tests
      • Jenkins
      • GitHub Actions
      • Octopus Deploy
      • TugboatQA
    • Testery CLI
    • Testery REST API
      • Testery REST API Resources
    • Microsoft Teams
  • Framework-specific Guidance
    • Supported Testing Frameworks
    • Cypress
      • Updating Cypress Tests to Output in JUnit XML Format
    • Playwright
      • Update Playwright Tests to Output in JUnit XML Format for Import Into Testery
    • PyTest
      • Update Pytest to Generate JUnit XML for Import into Testery
    • TestNG
      • Updating TestNG Tests to Output in JUnit XML Format
  • How-To
    • Enable or Disable Automatic Rerunning of Tests
    • Run Cypress Tests without Connecting Repository
    • How to Store Sensitive Data Like Username and Password For a Cypress Test
    • Connect to a Private npm Repository
    • Running Scripts Before the Tests
    • Upload Test Run for Analysis
  • MISC
    • Troubleshooting Steps
  • Fixing Tests
    • Fix Common Selenium Exceptions
      • Fix a ChromeDriver Version Exception
      • Fix a NoSuchElement Exception
      • Fix a TimeoutException
      • Fix an ElementNotVisibleException
      • Fix a StaleElementReferenceException
      • Fix a WebDriverException
      • Fix an InvalidArgumentException
      • Fix a NoSuchWindowException
      • Fix an UnhandledAlertException
      • Fix an InvalidSelectorException
Powered by GitBook
On this page
  • Prerequisites
  • Step 1: Install Cypress JUnit Reporter
  • Step 2: Update Your Cypress Configuration
  • Step 3: Run Your Cypress Tests
  • Step 4: Upload Your Test Results to Testery

Was this helpful?

  1. Framework-specific Guidance
  2. Cypress

Updating Cypress Tests to Output in JUnit XML Format

In this article, we'll walk through the steps to update your Cypress tests to output in JUnit XML format and how to upload them to Testery for automated analysis.

Prerequisites

Before we get started, ensure you have the following prerequisites in place:

  1. Cypress Installed: You should have Cypress installed in your project. If it's not already installed, you can do so by running npm install cypress --save-dev.

  2. Node.js: Make sure you have Node.js installed on your machine.

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

  4. Testery CLI. You should have the Testery CLI installed. If you don't have it already, run pip install testery.

Step 1: Install Cypress JUnit Reporter

To generate JUnit XML reports, we'll need to install the cypress-junit-reporter package. This package provides a custom reporter for Cypress that converts test results into JUnit XML format.

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

npm install cypress-junit-reporter --save-dev

Step 2: Update Your Cypress Configuration

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

  1. Open your Cypress configuration file, usually named cypress.json.

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

{
  "reporter": "junit"
}
  1. Optionally, you can also configure the reporter with additional options. For example, you can specify the output folder for the JUnit XML files:

{
  "reporter": "junit",
  "reporterOptions": {
    "mochaFile": "cypress/reports/junit/test-results.xml"
  }
}

This configuration will save the JUnit XML reports in a cypress/reports/junit folder with filenames that include a hash to ensure uniqueness.

Step 3: Run Your Cypress Tests

Now that your Cypress configuration is updated, you can run your Cypress tests as usual. Cypress will automatically use the JUnit reporter to generate XML reports.

To run your tests, use the following command:

npx cypress run

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 into your CI/CD pipeline. The specific steps for doing this will depend 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 cypress/reports/junit/test-results.xml
PreviousCypressNextPlaywright

Last updated 1 year ago

Was this helpful?