- NodeJS on your machine
- A Github repo to run the actions in
- Install Cypress
- Open the repo locally and in it run
npm init()
with default settings - Run
npm install cypress --save-dev
to install cypress in node project - You can now run
npx cypress open
to open the local tool (useful for writing and debugging tests)
- Open the repo locally and in it run
- Write a Test Spec and Push everything except node_modules, cypress/videos, cypress/screenshots
- Create a GitHub Action using the Simple workflow template
- Add the following code to the *.yml:
name: Cypress Tests using Cypress Docker Image
on: [push]
jobs:
cypress-run:
runs-on: ubuntu-latest
container: cypress/browsers:node12.18.3-chrome87-ff82
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cypress run
uses: cypress-io/github-action@v2
with:
# Specify Browser since container image is compile with Firefox
browser: chrome
record: true
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- Login to the Cypress Dashboard and follow the steps to get your Record Key
- Create a GitHub Secret named CYPRESS_RECORD_KEY
- Add the ProjectID from the Cypress Dashboard to cypress.json
Now you should see the GitHub action running the tests on every push to the repo and in the Dashboard you can checkout the results + videos/screenshots and analytics