Benefits of using Cypress in GitHub actions
Tags: engineeringmonday, cypress, testing, javascript
Published: 2020-10-12 15:40:42

---
title: Benefits of using Cypress in GitHub actions 
published: true
description: Running Cypress tests in GitHub actions can be valuable for the development teams in terms of software stability and easier onboarding of new members.
tags: engineeringmonday, cypress, testing, javascript
//cover_image: https://direct_url_to_image.jpg
---

If you work with anything related to frontend and you haven’t tried Cypress yet, I highly suggest you give it a try. 
But, if you use Cypress and don’t have a CI/CD pipeline set up yet, read forward for the reasons why using GitHub actions for it might be valuable.

# GitHub actions
The [docs](https://docs.github.com/en/free-pro-team@latest/actions) say:
> Automate, customize, and execute your software development workflows right in your repository with GitHub Actions.

### Cypress GitHub action - installation
Read these:
- [GitHub actions basic quickstart](https://docs.github.com/en/free-pro-team@latest/actions/quickstart)
- [Cypress github action repository](https://github.com/cypress-io/github-action)

# Benefits of integration
### Prevention of merging broken code into the target branch
* by leveraging code status checks of GitHub, there is the potential to list run Cypress checks and block PR merge if all [checks are not passing](https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/enabling-required-status-checks)

![status checks](https://dev-to-uploads.s3.amazonaws.com/i/s7s57i3nhrjrwa45wzvs.png)
*[Image source: cypress docs](https://docs.cypress.io/guides/dashboard/github-integration.html#Status-checks)*


### Software stability
- as the status checks prevent merging broken code, there is potentially greater awareness across the development team towards software quality and stability
- another potential outcome is that the team write more (and meaningful) tests because they see how much their code and tests have an impact on the complete codebase

### Tracking code coverage
- although code coverage can be misused, it can be a valuable metric in determining which code flows are hit or missed
- plugin: https://github.com/cypress-io/code-coverage

### Easier onboarding of new developers to project standards
- if a new team member has not used Cypress before, he/she will potentially see the value of tests sooner if they're visible in the CI and they're not required to be run manually
 
### Developer’s ownership of CI/CD
- In some organizations, CI/CD pipelines are the responsibility of the DevOps team
- Delegating some complex pipelines or asking help from the DevOps team is great for collaboration, but it's also really valuable skill knowing setting up the basic CI/CD flows
- I personally think this is really important because the developer can then tweak the CI/CD pipeline to the project's needs and potentially easily experiment with new features of relevant technologies on the projects (e.g. Cypress GitHub actions)


# Summary
This post focuses (on very high level) on the integration of Cypress and GitHub actions, but can easily be applied to other testing frameworks such as Jest and other CI/CD services such as CircleCI or TravisCI. 

I personally found it very convenient to use it with GitHub actions because it's *baked in* the GitHub itself, but you can freely use other services that support this kind of automated flows.

Happy testing!