CI Workflows

Upload strategies

When you run tests and create recordings, they are stored locally. You can choose which recordings get uploaded to Replay. All uploaded recordings become accessible in the Replay App.


While uploading just failed tests is good for saving resources, our recommendation is to upload both failed and passed tests so that you can compare them. This can be really useful for debugging purposes.

Upload all tests

To upload all test replays no matter the result, set the upload option to true.

cypress.config.js
export default defineConfig({
e2e: {
setupNodeEvents(cyOn, config) {
const on = wrapOn(cyOn)
replayPlugin(on, config, {
apiKey: process.env.REPLAY_API_KEY,
upload: true,
})
return config
},
},
})

Upload failed tests only

To upload recordings only for failed tests use statusThreshold option:

cypress.config.js
export default defineConfig({
e2e: {
setupNodeEvents(cyOn, config) {
const on = wrapOn(cyOn)
replayPlugin(on, config, {
apiKey: process.env.REPLAY_API_KEY,
upload: {
statusThreshold: 'failed',
},
})
return config
},
},
})

Upload failed and flaky tests

To upload recordings for failed and flaky tests use statusThreshold option:

cypress.config.js
export default defineConfig({
e2e: {
setupNodeEvents(cyOn, config) {
const on = wrapOn(cyOn)
replayPlugin(on, config, {
apiKey: process.env.REPLAY_API_KEY,
upload: {
statusThreshold: 'failed-and-flaky',
},
})
return config
},
},
})

Upload only for the primary branch

Many CI providers provide an environment variable that references the current branch name.

GitHub stores this value in a default variable named GITHUB_BASE_REF that can be passed along as part of a Workflow and then referenced in the test config like so:

cypress.config.js
export default defineConfig({
e2e: {
setupNodeEvents(cyOn, config) {
const on = wrapOn(cyOn)
replayPlugin(on, config, {
apiKey: process.env.REPLAY_API_KEY,
upload: process.env.BRANCH_NAME === 'main',
})
return config
},
},
})

Reducing the number of uploaded recordings

Use the advanced upload options to reduce the number of recordings that are uploaded. When this option is enabled, only one recording will be uploaded for any passing or failing test. For flaky tests, two recordings will be uploaded– the passing test and one of the failed attempts.

playwright.config.js
import { replayDevices, replayReporter } from "@replayio/playwright";
const config: PlaywrightTestConfig = {
reporter: [
replayReporter({
apiKey: process.env.REPLAY_API_KEY,
upload: {
minimizeUploads: true,
},
}),
["line"],
],
projects: [
{
name: "replay-chromium",
use: { ...replayDevices["Replay Chromium"] },
},
],
};
export default config;

Note this option is only available for tests recorded with Playwright