This content originally appeared on DEV Community and was authored by Rodrigo Santos
In this text, I try to show you how to setup Cypress on Github Actions, but first I have one disclaimer for you.
I assume you know the basics about Github, that is commits, pull requests and branchs need to be familiar concepts.
Github Actions it's a important tool for automate and run softwares workflows in day by day. In this article I show to you when every time someone creates a pull request for a your project repository, you can automatically run a command that executes a software testing script.
But first, I need you to have any Github repository with any Cypress test.
So let's start the fun...
1 . In your Github repository create a new file in directory .github/workflows called github-actions-init.yml
2 . In this file we must add a content with steps of our workflow:
name: GitHub Actions Demo
on: [pull_request]
jobs:
cypress-run:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install node
uses: actions/setup-node@v2
with:
node:version: '14'
- name: Install dependencies
run: npm install
- name: Cypress run
uses: cypress-io/github-action@v2
In this YAML file, we have some terms that need explanation, so let's go undestand line by line:
-
name: GitHub Actions Demo
: It's basically the name of our workflow. -
on: [pull_request]
: Shows for github actions when running the workflow -
jobs
: Group all jobs in file -
cypress-run
: It's job's name -
runs-on: ubuntu-latest
: Indicates to a workflow should run in a Ubuntu Linux executor. -
steps
: All steps to run in workflow -
Checkout
: It's a step's name -
uses: actions/checkout@v2
: In this line basically our workflow checks our repository allowing you to run actions against own code -
name: Install node
: It's a step's name -
uses: actions/setup-node@v2
: This step is used for install a specified node version -
node-version
: Indicate a node version -
name: Install dependencies
: It's a step's name -
run: npm install
: Run the command install in node, to install all dependencies in project -
name: Cypress run
: It's a step's name -
uses: cypress-io/github-action@v2
: Run a Cypress command to execute all tests cases in project.
3 . After add this file in repository, it's time to create a pull request and see the magic happen.
It's all for today, but i hope this text helps you and if you have any ask text me in comments. I see you soon.
Project Repository: https://github.com/rodrigosta/e2e-toDoList
References:
- https://docs.github.com/en/actions/learn-github-actions/introduction-to-github-actions
- https://docs.cypress.io/guides/continuous-integration/github-actions
This content originally appeared on DEV Community and was authored by Rodrigo Santos
Rodrigo Santos | Sciencx (2021-09-05T23:48:59+00:00) How to setup Cypress on Github Actions. Retrieved from https://www.scien.cx/2021/09/05/how-to-setup-cypress-on-github-actions/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.