@probara/cypress-reporter
v0.4.0
Published
Cypress reporter that sends every test result to Probara.
Maintainers
Readme
A Cypress reporter that sends every test result of a run to
Probara: each attempt with its status, duration and error, linked to its
Probara test case, with the steps, attachments and links your tests add. Cases that are missing get
created, and the run is closed once everything is in. Built on
@probara/core.
Features
- Three registrations, each with its own job: the reporter (
reporterandreporterOptions) turns Cypress' own events into results, the plugin (setupNodeEvents, from@probara/cypress-reporter/setup) owns the run, registers theprobaratask, and collects the screenshots and the video, and the support file (import '@probara/cypress-reporter/support') turns on theprobara.*helpers. Registered together, a spec reports every attempt with everything it recorded (registration). - One result per attempt,
retriesincluded, with Cypress' own verdict:it.skipandthis.skip()are skipped, the attempt aretrystands for is failed, and every test a failing hook kept from running is skipped (statuses, retries). - The same keys as
probara import juniton the JUnit XML of Cypress'sjunitreporter or of cypress-junit, so switching from the JUnit import keeps every case and its history (same cases as the JUnit import). - Screenshots attached to the exact attempt Cypress took them for, plus the video of a spec for
its failed results (
attachVideos) (attachments). - Visual testing with
cy.probaraSnap(name): screenshots compared between commits in Probara Snap (Probara Snap). - Linking by a case id in a title or a
describe(SHOP-12 adds an item) orprobara.id(), and the browser Cypress runs as abrowsercontext value of every result: shown on it, never a parameter of a new case, never in the key (linking, projects). - Browser helpers that run where the test runs:
probara.step()(nested, with expected results and data),probara.attach(),probara.link(),probara.issue(),probara.parameters(), and the title, suite, tags and fields of a new case (metadata, steps). - Console output of each test attached with
captureOutput(attachments), and run selection: only the tests of a Probara run, withrunCasesOnly(run selection). - Runs by name, with an environment, milestone, test plan, configurations and tags
(run options); one run for every shard of a sharded CI job
(sharding); failures assigned with
assignFailedTo(assign failed). - Never breaks your test run: a reporting problem is logged, never thrown, and
cypress runstill ends with the number of its own failed tests. What could not be sent can be kept in a file and sent later withprobara import results 'probara-results*.json'.
Not supported in this version
| What | Why, and what to use |
| ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| cypress open (interactive mode) | Cypress builds the reporter only in cypress run: run the specs you work on with cypress run --spec (interactive mode) |
| Cypress commands as steps | The support file could follow Cypress's command events in the browser (Cypress.on('command:start'), or log:added as Allure's does); this version does not, since every command would multiply the steps of a result (Probara keeps 200 per result). Use probara.step() (steps) |
| Gherkin steps of a Cucumber preprocessor (@badeball/cypress-cucumber-preprocessor) | Not turned into steps of the result |
| Network profiling (Qase's cy.intercept recorder) | A task per request: more noise and cost than value |
| Result fields | Probara has no result fields |
Also not ported from the reporters this one takes over from, each with its reason: updating existing
cases (a report never changes a case), a key override (externalId, historyId, automation_id),
a case owner, masked parameters, categories and known issues, and defects or public links
(coming from other tools).
Requirements
- Node.js 22.12 or later.
- Cypress 15.10.0 or later: the first version with
Cypress.expose(), which carries the plugin's settings to the browser (Cypress versions). - A Probara app token, created from the Cypress card in Integrations
(get a token), and the code of the project to report into
(such as
SHOP). Reporting from CI needs a paid plan.
Install
npm install --save-dev @probara/cypress-reporterQuick start
In Probara, open Workspace › Integrations, pick the Cypress card and create a token (get a token). Store it as a CI secret named
PROBARA_API_TOKEN: the reporter reads it from the environment, never from the config.Register the reporter and its plugin in the Cypress config:
// cypress.config.js const { defineConfig } = require('cypress'); const { probaraNodeEvents } = require('@probara/cypress-reporter/setup'); module.exports = defineConfig({ e2e: { reporter: '@probara/cypress-reporter', reporterOptions: { projectId: 'SHOP' }, setupNodeEvents(on, config) { return probaraNodeEvents(on, config); }, }, });Load the browser helpers in the support file, so a spec can use
probara.*:// cypress/support/e2e.js import '@probara/cypress-reporter/support';Run your tests with the token in the environment. In GitHub Actions:
- name: Run Cypress tests run: npx cypress run env: PROBARA_API_TOKEN: ${{ secrets.PROBARA_API_TOKEN }} PROBARA_PROJECT: SHOP
Without a token and a project the reporter stays off and quiet, so local runs send nothing. In CI
it logs on stdout, in [probara] lines, and ends with the link to the run:
$ npx cypress run --spec cypress/e2e/cart.cy.js
[probara] Sending 5 results of 4 tests (3 passed, 2 failed, 0 skipped, 0 blocked)
[probara] Recorded 5 results (2 new cases, 0 unmatched) in R-1 (closed): https://app.probara.net/projects/SHOP/runs/R-1What gets reported
| Cypress | In Probara |
| ----------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| A test | A test case, matched by its automation key or linked by a case id |
| Each attempt (retries too) | A result in the run, with its status, duration, start time and error |
| it.skip, this.skip(), a test a failing hook kept from running | A skipped result |
| A failing beforeEach/before | One failed result named as Cypress names it, plus the tests it stopped |
| probara.step() calls | The steps of the result, nested, with their status, duration and error |
| probara.attach(), captureOutput, the screenshots of a failure | Files of the result, or of the step they were attached in |
| probara.link(), probara.issue() | Links of the result |
| Other probara.* calls in the test | The title, suite, tags, fields and steps of a new case; result parameters |
| A spec Cypress cannot run (a syntax error), one that throws as it loads | One failed result, as Cypress names it, so it never shows green |
| The cypress run command | One automated run, named after the CI build, closed at the end |
Cypress ends a cypress run with the number of its own failed tests, and reporting changes
nothing of it: four failed tests still end the command with 4, whatever Probara answered
(statuses).
Same cases as the JUnit import
The reporter gives each test the automation key probara import junit gives it on the report of
Cypress's built-in junit reporter or of cypress-junit
written with their default options:
the spec file relative to the project root, then > between spaces, then the describes and the
it title joined by spaces (the name both write), without the case ids. For these two
specs:
// cypress/e2e/cart.cy.js
describe('Cart', () => {
it('SHOP-12 adds an item', () => {
cy.get('.add').click();
});
it('removes an item', () => {
cy.get('.remove').click();
});
});// cypress/e2e/login.cy.js
describe('Login', () => {
it('logs in with a valid password', () => {
cy.get('#submit').click();
});
});the reporter sends:
[
{
"automationKey": "cypress/e2e/cart.cy.js > Cart adds an item",
"caseDisplayId": "SHOP-12",
"status": "passed"
},
{ "automationKey": "cypress/e2e/cart.cy.js > Cart removes an item", "status": "passed" },
{
"automationKey": "cypress/e2e/login.cy.js > Login logs in with a valid password",
"status": "passed"
}
]If your JUnit reports were written with a mochaFile that one spec overwrites, or without
the file attribute of the root suite, set keyIncludesFile: false: the keys then leave the file
out (configuration). Either way, a test keeps its case and
its history when you switch from the JUnit import
(migrating from the JUnit import).
Documentation
| Page | What it covers |
| --------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| Configuration | The three registrations, every option, its variable and default; getting a token |
| Linking tests to cases | Case ids in titles and describes, probara.id(), automation keys, describe and it.only |
| Metadata | Title, suite, comment, tags, fields, parameters, ignoring an attempt; where helpers work |
| Steps | probara.step(): nesting, status, errors, Cypress commands, the steps of a new case |
| Attachments | probara.attach(), files of steps, screenshots, video, console output, limits |
| Probara Snap | cy.probaraSnap(): screenshots compared between commits, masking, split specs |
| Links | probara.link(), probara.issue() and issueUrlTemplate |
| Statuses | How attempts become statuses; it.skip, hooks, specs that fail; mapping and filter |
| Specs | --spec, it.only, retries, specs that cannot run, the spec as a suite |
| Retries and flaky tests | Every attempt is a result |
| Run options | Name, description, environment, milestone, plan, configurations, tags, an existing run, closing |
| Sharding and CI | One run for every shard |
| Cypress and Probara projects | Results to other Probara projects, keyIncludesFile, the browser as a parameter |
| Interactive mode | Why cypress open reports nothing, and what to run instead |
| Run selection | runCasesOnly: run only the tests of a Probara run |
| Assign failed results | assignFailedTo: who looks into failures |
| Results file | Keep what could not be sent, send it later |
| Migrating from the JUnit import | From Cypress's junit reporter or cypress-junit and probara import junit, keeping every case |
| Migrating from Qase | Option by option and call by call, what is different, what is not ported |
| Coming from other tools | Allure Cypress and TestRail's trcli, mapped, and what is not ported |
| Troubleshooting | Problems and their solutions; every line the reporter logs |
| Debugging | PROBARA_DEBUG, the logs, checking what would be sent |
| Network | Requests, timeouts, retries, rate limits, proxies and certificates |
| Upgrading | Versioning policy, the automation key contract, Cypress versions |
| Changelog | What changed in each version |
CI guides: GitHub Actions, GitLab CI, CircleCI, Azure Pipelines, Jenkins, Bitbucket Pipelines and Buildkite.
On the Probara side, the Cypress integration guide covers the card, its app tokens and what Probara shows.
Reporting never breaks your test run
The reporter never throws into Cypress and never changes its exit code: a failed test still fails
the command, a reporting problem does not. Every problem (a wrong setting, Probara unreachable, a
refused token) is logged, and the tests keep their outcome. probara.* calls never throw into a
test either: a call Probara cannot use is left out with a warning. There is no option to fail the
command on a reporting error; to keep what could not be sent, set a results file
(resultsFile).
