GitHub actions
Cypress team has created its official GitHub Action. The action provides dependency installation, built-in caching, and multiple options for advanced workflow configuration.
Using this GitHub Action is optional and some teams prefer their own custom setup. Replay integrates well with both workflows, as shown in examples below
These instructions assume that you have already installed @replayio/cypress
plugin into your project. Follow the instructions on this page to learn how to install the plugin.
Using GitHub Actions with cypress-io/github-action
When using the Cypress GitHub Action, the CI setup requires just a couple of lines of code. For the Cypress run itself, the replay-chromium
browser needs to be passed in to create recordings.
After test run finishes, an additional step needs to be added to upload all the recordings using @replayio/action-upload
action.
.github/workflows/e2e.yml
1name: End-to-end tests2on: push3jobs:4 cypress-run:5 runs-on: ubuntu-22.046 steps:7 - name: Checkout8 uses: actions/checkout@v49 - name: Install Replay Chromium10 run: npx replayio install11 - name: Cypress run12 uses: cypress-io/github-action@v613 with:14 browser: replay-chromium15 env:16 REPLAY_API_KEY: ${{ secrets.REPLAY_API_KEY }}17 - name: Upload replays18 if: always()19 uses: replayio/action-upload@v0.5.120 with:21 api-key: ${{ secrets.REPLAY_API_KEY }}
Using GitHub Actions without cypress-io/github-action
Without using GitHub Actions and running your Cypress tests by calling a script, the main principles stay the same:
- you need to make sure to pass
REPLAY_API_KEY
to your test run - add step to your pipeline to upload your replays
There are a couple of different ways to achieve this. For example, you can update your package.json
file with a custom script that runs your Cypress tests with Replay Browser
package.json
"scripts": {"cy:run": "cypress run", // original test script"cy:run:replay": "cypress run --browser=replay-chromium" // new test script}
Use that new test script instead in your current workflow file, and add the environment variable(s):
.github/workflows/e2e.yml (partial)
1- name: Cypress run2 run: npm run cy:run:replay3 env:4 REPLAY_API_KEY: ${{ secrets.REPLAY_API_KEY }}
Add a new step to run after your Cypress tests for uploading the replays:
.github/workflows/e2e.yml (partial)
1- name: Upload replays2 if: always()3 uses: replayio/action-upload@v0.5.14 with:5 api-key: ${{ secrets.REPLAY_API_KEY }}
Upload strategies
There are different strategies for uploading your replays. For example you can use Replay only when retrying a failed test, or choose to upload recordings from failed tests only. See docs on upload strategies to learn more.