DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Enterprise AI Trend Report: Gain insights on ethical AI, MLOps, generative AI, large language models, and much more.

2024 Cloud survey: Share your insights on microservices, containers, K8s, CI/CD, and DevOps (+ enter a $750 raffle!) for our Trend Reports.

PostgreSQL: Learn about the open-source RDBMS' advanced capabilities, core components, common commands and functions, and general DBA tasks.

AI Automation Essentials. Check out the latest Refcard on all things AI automation, including model training, data security, and more.

Related

  • How To Run OWASP ZAP Security Tests in Azure DevOps Pipeline
  • Set Up a CI/CD Pipeline for An Angular 7 Application From Azure DevOps to AWS S3
  • DevOps Nirvana: Mastering the Azure Pipeline To Unleash Agility
  • CI/CD Metrics You Should Be Monitoring

Trending

  • Sprint Anti-Patterns
  • Initializing Services in Node.js Application
  • How To Optimize Your Agile Process With Project Management Software
  • Understanding Escape Analysis in Go
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. DevOps and CI/CD
  4. Setup Cypress Tests in Azure DevOps Pipeline

Setup Cypress Tests in Azure DevOps Pipeline

Step by step guide to configure and run Cypress tests in Azure DevOps pipeline and publish Cypress test results in Azure DevOps.

By 
Ganesh Hegde user avatar
Ganesh Hegde
DZone Core CORE ·
Aug. 17, 21 · Tutorial
Like (7)
Save
Tweet
Share
34.7K Views

Join the DZone community and get the full member experience.

Join For Free

This tutorial helps to integrate and run your Cypress tests with the Azure DevOps pipeline in an Easy Way

Pre-Requisite:

  1. You need to have already cypress framework up and running on your local machine
  2. Cypress Project should be checked into the repository
  3. Your framework should generate a JUnit XML file at the end of the execution of the test. If you are not sure how to do that refer to Generating JUnit XML article.

Step by Step Guide To Run / Set-Up Cypress Tests in Azure DevOps or TFS Pipeline CI/CD

This tutorial explains the easy way to configure and run Cypress Test Automation Framework into Azure DevOps. 

Step 1: Create a New Pipeline

Since we are starting from scratch, let's start with creating a new pipeline in Azure DevOps

Create your new pipeline. Navigate to Azure DevOps > From your Azure DevOps home page, Hover on Pipelines and Click on Pipelines

pipelines

Step 2: Click on New Pipeline

Click on the new pipeline as shown in the below image

Click on new pipeline

Step 3: Click on Use the Classic Editor

Click on Use the classic editor as shown in the below image

Classic Editor

Step 4: Choose the Correct Repository and Project

Source: Azure Repos Git
Team Project: Your Project Name
Repository: Your repository name where you have pushed Cypress Tests or code
Default branch: master (recommended) or any if you wish
Click on Continue

Select a source

Step 5: Select Template

Choose Empty Job As shown in the below image.

Select template

Step 6: Choose Pipeline Options

Click on the pipeline, On the right side of your screen specify desired options


Choose pipeline options

Name: Cypress Pipeline
Agent pool: Choose Agent pool (This will be as per your organization set up)
Agent Specification: Choose correct Specification (This will be as per your organization set up)

Step 7: Click on Agent Job1 From the Left Side and Choose Desired Options.

Display Name: Cypress or anything you wish
Agent pool: Choose Agent pool (This will be as per your organization set up)
Agent Specification: Choose correct Specification (This will be as per your organization set up)

Cypress pipelines

Step 8: Click on Plus Icon (+) And Add the Node Install Task

Click on the (+) icon on the left side the list of tasks opens up
Search for Npm install or Install Packages
Click on Add

Add tasks

Step 9: Configure Install Packages Task

In the added Task fill the correct options
Display Name
: Install Packages
Command: install
The working folder that contains package.json: Choose the correct working folder from the list (If you click on (…) it will show a list of folders in your repository, choose the correct one)

Install packages task

Step 10: Search and Add Powershell Task in Azure DevOps To Run Cypress Tests

Click on the (+) icon on the left side the list of tasks opens up
Search for Powershell
Click on Add

Powershell

Step 11: Configure Powershell Task To Run Cypress Test in Azure DevOps

Display name: Run Tests
Type: Inline
Script: add this command ./node_modules/cypress/bin/cypress run
Error Action Preference: Continue
Advanced Tab Options
Working Directory: Choose the correct directory (Where your package.json is located)
Continue Options
Enabled: Check this checkbox
Continue On Error: Check this check box


Run cypress tests

Step 12: Add Publish Cypress Test Results in Azure DevOps

Click on the (+) icon, Tasklist opens up
In the Search box type Publish Test Results
Click on Add to add the task


Publish cypress test results

Step 13: Configure Publish Cypress Test Results Task in Azure DevOps

Test Result Format: JUnit

Test Result Format: 
This is important, If you give the wrong path it will pick the Junit XML and the result will not be displayed. If you follow my Generating JUnit XML article, it will be generated inside the cypress/reports folder.

Control options

Enabled: Check this check box
Continue on Error: Check this check box
Run this task: From the drop-down choose the “Even if a previous task has failed unless the build was canceled” option

Step 14: Run Cypress End to End Test Automation Pipeline in Azure DevOps

Once you are done with adding all tasks click on Save & Queue

Save and Queue

Step 15: View Cypress Test Results in Azure DevOps

If you have configured everything correctly, then build will pass and test results link find in Publish Cypress Test Result Task

Publish test results

Test Results looks like this

test results

test results


Congrats!, You have successfully Integrated Cypress Tests with the Azure DevOps pipeline

Encourage me to write more articles by buying a coffee for me.

If you are looking for any help, support, guidance contact me on LinkedIn|https://www.linkedin.com/in/ganeshsirsi

Testing azure Pipeline (software) DevOps Task (computing)

Opinions expressed by DZone contributors are their own.

Related

  • How To Run OWASP ZAP Security Tests in Azure DevOps Pipeline
  • Set Up a CI/CD Pipeline for An Angular 7 Application From Azure DevOps to AWS S3
  • DevOps Nirvana: Mastering the Azure Pipeline To Unleash Agility
  • CI/CD Metrics You Should Be Monitoring

Partner Resources


Comments

ABOUT US

  • About DZone
  • Send feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: