DEV Community

Cinthia Barbosa da Silva
Cinthia Barbosa da Silva

Posted on

How to Publish Cypress Test Results to Azure Devops

Continuing on the integration between Cypress and Azure Devops, in this post I am going to share how to publish test results!
If you found this article helpful, please leave a comment.❤️

Let's go!🚀

First of all, make sure your tests are in a Git repository (“Repos”) in Azure DevOps.

Next, we have to install the package JUnit Reporter for Cypress as a project dependency



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


Enter fullscreen mode Exit fullscreen mode

After that, in your Cypress test code, you need to configure the settings in the "cypress.config.js" file as follows:



reporter: 'mocha-junit-reporter',
  reporterOptions: {
    mochaFile: 'results/test-results-[hash].xml',
  }


Enter fullscreen mode Exit fullscreen mode

Then, we need to include in the file .gitignore the folder "results", because every execution generates a new file with a hash code.

Now, navigate to Pipelines. If you already have a configured pipeline, locate it and click on Edit to make changes.

Image description

In your pipeline editor within Azure DevOps, navigate to Tasks and use the search bar to find the task named "Publish Test Results".

Image description

Now, you'll configure the task:

  1. Set the "Test result format" to JUnit.
  2. Set the path to publish the test files.
  3. Check the option to merge test results.

After configuring these settings, click on Add to add the task to your pipeline.

Image description

Now, the configuration has been added to the azure-pipeline.yml file.

Image description
Once you have saved the azure-pipeline.yml file, initiate the test build by clicking on "Run Pipeline" in Azure DevOps. This action will start the CI/CD pipeline and execute the defined tasks, including a new configuration for test publish results.

After running the test, navigate to the "Test" to see a summary about the test, including execution time, how many tests passed and how many failed.

Image description

A very useful feature is that when a test fails we can create a "bug" task with all the details in Azure Devops!

This is for today! If you have any questions, leave me a comment!

And you found this article helpful, please like the post.❤️

Top comments (0)