Cypress reporter
Install @qualflare/cypress, register its plugin and support file, and upload the qualflare-results folder with the Qualflare CLI after cypress run.
Last updated
@qualflare/cypress is the Qualflare reporter for Cypress 12 or later: its plugin and support file write each run's results, with retries, screenshots, command steps and videos, to ./qualflare-results, and qf <identifier> collect uploads the folder as one launch.
| Fact | Detail |
|---|---|
| Package | @qualflare/cypress on npm |
| Works with | Cypress 12 or later, Node.js 18 or later (Cypress 15 needs Node.js 20) |
| qf | qf ≥ 0.1.24 (requires qf 0.1.24 or later) |
| License | Apache-2.0 |
| Source | Qualflare/qualflare-cypress on GitHub |
| Without the reporter | --format cypress with Mochawesome JSON |
Before you begin
- The Qualflare CLI,
qf: Install the CLI. - A saved login:
qf login <identifier>with a project access token whose creator still holds the project role that uploads need Editor+ · project (requires the Editor role or higher in the project) (Authenticate with qf login). - The Identifier of the environment the results belong to (Environments).
Install
npm install --save-dev @qualflare/cypressConfigure
Add both files:
// cypress.config.ts
import { defineConfig } from 'cypress';
import { qualflareCypress } from '@qualflare/cypress/plugin';
export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
return qualflareCypress(on, config, {
environment: 'staging',
});
},
},
});// cypress/support/e2e.ts
import '@qualflare/cypress';| Option | Type | Default | Required | Description |
|---|---|---|---|---|
videoOnFailureOnly | boolean | true | No | Attach a spec's video only when one of its tests failed. Variable |
attachScreenshots | boolean | true | No |
|
maxVideoBytes | number | 50000000 | No | Skips a larger video before copying it. Variable |
Every reporter shares the other settings: see Reporter configuration.
Set environment to the environment's Identifier: a name such as Staging fails the upload with HTTP 400 (Environment).
Run and upload
npx cypress run
qf <identifier> collect ./qualflare-resultsScreenshots upload by default; add --upload-artifacts video for videos.
Run in CI
- name: Upload results to Qualflare
if: ${{ !cancelled() }}
env:
QF_TOKEN: ${{ secrets.QF_TOKEN }}
QF_BRANCH: ${{ github.head_ref || github.ref_name }}
QF_COMMIT: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
npm install -g @qualflare/cli
qf login ci --force
qf ci collect ./qualflare-resultsif: ${{ !cancelled() }} uploads the results when tests fail, and QF_BRANCH and QF_COMMIT record a pull request's own branch and commit (Pull request branches). For GitLab CI/CD, Jenkins and Azure Pipelines, see Run the upload when tests fail.
Sharding and retries
Cypress gives reporters no shard number. Set QUALFLARE_SHARD_INDEX from your CI matrix, for example QUALFLARE_SHARD_INDEX: ${{ matrix.shard }}; every process writes its own file to the shared folder. See Merge sharded CI jobs into one launch.
Each attempt's status, duration and error is uploaded; steps, labels, tags and attachments come from the final attempt.
What gets uploaded
- Status, with the history of each retried attempt.
- Screenshots, taken automatically when a test fails.
- Step-by-step command traces.
- Labels, links, tags and attachments.
A test sets its own metadata with the qualflare calls:
import { qualflare } from '@qualflare/cypress';
it('logs in with valid credentials', () => {
qualflare.label('epic', 'Authentication');
qualflare.tag('smoke');
qualflare.step('fill in credentials', () => {
cy.get('#email').type('user@example.com');
cy.get('#password').type('correct-horse-battery-staple');
});
});qf doesn't read the branch, commit, language or milestone from the report: set them on the upload (Branch, commit, language and milestone).
Troubleshooting
- No video on a passing spec:
videoOnFailureOnlyis on. environment "Staging" does not exist in this project: use the environment's Identifier, or pass--environmenton the upload (Environment).- Screenshots can't be downloaded:
qfis older than 0.1.24. Upgrade qf.
Related
Playwright reporter
Install @qualflare/playwright, add it to playwright.config.ts and upload its qualflare-results folder with the Qualflare CLI, sharded runs included.
Jest reporter
Install @qualflare/jest, add it to the reporters in jest.config.js and upload the qualflare-results folder with the Qualflare CLI after each run.