When to use: You need actionable outputs for failed and passed Cypress runs in CI. Prerequisites: ci-github-actions.md, ci-gitlab.md, test-coverage.md
cypress/screenshots(failures)cypress/videos(run recordings)- JUnit XML (
cypress/results/*.xml) for CI test dashboards - Optional HTML/Allure artifacts
Install:
npm i -D mocha-junit-reporterConfigure:
// cypress.config.ts
import { defineConfig } from 'cypress';
export default defineConfig({
reporter: 'junit',
reporterOptions: {
mochaFile: 'cypress/results/junit-[hash].xml',
toConsole: false,
},
});Install:
npm i -D mochawesome mochawesome-merge mochawesome-report-generatorConfig example:
import { defineConfig } from 'cypress';
export default defineConfig({
reporter: 'mochawesome',
reporterOptions: {
reportDir: 'cypress/results/mochawesome',
overwrite: false,
html: false,
json: true,
},
});Merge and generate:
npx mochawesome-merge cypress/results/mochawesome/*.json > cypress/results/merged.json
npx marge cypress/results/merged.json -o cypress/results/htmlInstall (plugin choice depends on your stack):
npm i -D @shelex/cypress-allure-plugin allure-commandlineThen publish allure-results/ and generated allure-report/ as artifacts.
- name: Upload screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: cypress-screenshots
path: cypress/screenshots
if-no-files-found: ignore
- name: Upload videos
if: always()
uses: actions/upload-artifact@v4
with:
name: cypress-videos
path: cypress/videos
if-no-files-found: ignore
- name: Upload junit
if: always()
uses: actions/upload-artifact@v4
with:
name: cypress-junit
path: cypress/results/*.xml
if-no-files-found: ignoreartifacts:
when: always
paths:
- cypress/screenshots/
- cypress/videos/
- cypress/results/
reports:
junit: cypress/results/*.xml- PR runs: keep 7-14 days
- main/nightly regression: keep 14-30 days
- release-candidate validation: keep longer if compliance requires it
| Anti-pattern | Problem | Better approach |
|---|---|---|
| Uploading only on success | Failing runs lose debug data | Upload failure artifacts always |
| Huge raw artifacts without structure | Hard to find useful files | Separate screenshots/videos/results paths |
| No junit output | CI UI lacks test-level visibility | Emit JUnit XML consistently |
- Verify
videoandscreenshotOnRunFailuresettings. - Confirm artifact upload steps use
if: always()orwhen: always.
- Confirm XML path matches CI pattern.
- Avoid overwriting same filename from parallel jobs unless merged intentionally.