Use of GitHub Actions is not required to enable Pull Request Comments in GitHub.
Using the Replay action-cypress
Using Replayβs
action-cypress
in your GitHub Actions workflow is the easiest way to get started recording your Cypress tests in CI. It handles all the aspects of running and recording your tests, including executing the run command.The action:
- Runs your tests with the browser specified
- Uploads replays from the test run to the team for the given API key
If your workflow does not have a step to install project dependencies, youβll need to add a step to install
@replayio/cypress
before using action-cypress
.This action should not be used in combination with other actions that execute a test run command, such as
@cypress-io/github-action
.Using Replay with the Cypress GitHub Action
Cypress provides
@cypress-io/github-action
for running tests in CI. If you prefer to use this action, a few changes are required to configure Replay to record your tests.If your workflow does not have a step to install project dependencies, youβll need to add a step to install
@replayio/cypress
before @cypress-io/github-action
.- Pass
βReplay Chromiumβ
(recommended) orβReplay Firefoxβ
to thebrowser
option
- Set required environment variables using
env
- Add a step to upload replays using
@replayio/action-upload
yaml- name: Run tests with Cypress uses: cypress-io/github-action@v4.2.0 with: browser: "Replay Chromium" start: npm run start wait-on: 'http://localhost:3000' env: RECORD_ALL_CONTENT: 1 RECORD_REPLAY_METADATA_FILE: /tmp/replay-metadata - name: Upload replays if: ${{ always() }} uses: replayio/action-upload@v0.4.7 with: api-key: ${{ secrets.RECORD_REPLAY_API_KEY }}
You can also use the
@replayio/replay
CLI to upload replays. See instructions here.Using other GitHub Actions
If youβd like to use a different action or workflow step to execute your tests, you can still configure GitHub Actions to record and upload replays.
If your workflow does not have a step to install project dependencies, youβll need to add a step to install
@replayio/cypress
before the step that runs your tests.Recording replays
The existing test run command (for example,
npx cypress run
) must be updated to include the name of a Replay Browser and required environment variables to record.You should make this update wherever your run command is defined, typically in
package.json
or directly in the workflow file.Pass the following with your run command to record with Replay:
RECORD_REPLAY_METADATA_FILE=$(mktemp)
RECORD_ALL_CONTENT=1
if using βReplay Firefoxβ
--browser "Browser Name"
(either βReplay Chromiumβ or βReplay Firefoxβ)
For example, to record with βReplay Firefoxβ, use the following command:
yamlRECORD_ALL_CONTENT=1 RECORD_REPLAY_METADATA_FILE=$(mktemp) npx cypress run --browser "Replay Chromium"
If you donβt specify a browser, the Cypress default Electron will be used.
Uploading replays
Use
replayio/action-upload
to upload replays generated during the test run.bash- name: Upload replays if: ${{ always() }} uses: replayio/action-upload@v0.2.7 with: api-key: ${{ secrets.RECORD_REPLAY_API_KEY }}
You can also use the
@replayio/replay
CLI to upload replays. See instructions here.