Skip to main content

Cypress

Submit and collect your Cypress tests in Testiny to track results over time, identify frequently failing tests, efficiently debug and fix CI failures or flaky tests.

Generate Cypress Mochawesome JSON Reports

Configure your Cypress test with the mochawesome reporter (or any another reporter, that outputs Mocha JSON files):

cypress.config.js
const { defineConfig } = require("cypress");

module.exports = defineConfig({
reporter: 'mochawesome',
reporterOptions: {
overwrite: false // for mochawesome, generate a report for each spec file,
reportDir: 'cypress/reports',
html: false,
json: true
},
});

Run your Cypress tests with cypress run and the mochawesome reporter will create reports for each spec file in the specified reportDir folder (or if no folder is specified, by default in the mochawesome-report folder).

Make sure you've set the reporter option overwrite to false, so that a report is generated for each test file. With Testiny, you don't need to merge the single files into one report, the CLI will do that for you.

Import Results to Testiny

Make sure you've generated an API key and use the Testiny CLI to import the results to Testiny:

export TESTINY_API_KEY=****
npx @testiny/cli automation --project ID_OR_KEY --source "e2e" --cypress cypress/reports/*.json 

In the above example, the environment variable TESTINY_API_KEY is set to authenticate the request. The --project flag specifies the target Testiny project using its ID or key and the --source flag categorizes the test results (e.g., frontend, backend, integration tests, ...). The --cypress flag specifies the format of the specified test result file(s).

Once executed, the Testiny CLI will automatically create a new automated test run in Testiny and import all results from the specified report(s).

Merging reports

You don't need to merge the mochawesome JSON files into one report, the CLI will do that for you. You can simply specify the whole report folder for importing as shown in the example above.

Importing Screenshots

The attachment path is by default cypress/screenshots and the Testiny CLI searches this directory and imports screenshots for failed tests found in this folder.
If you have another screenshot folder configured, specify another relative base directory path with --attachment-path <FILE-PATH>.

note

Tests marked with it.skip(), context.skip, or it('some test') (no callback) produce "pending" tests. These are shown as "blocked" in Testiny. See this issue for more information.

Additional Fields

If you run your Cypress tests in your CI pipeline with different configurations (for example, with different browsers), you can add this information as additional fields with --field-values:

npx cypress run --browser firefox
npx @testiny/cli automation --project 57 --source cypress-tests --field-values browser=firefox --cypress mochawesome-report/*.json
info

See how to run Cypress with different browsers and report results to Testiny in the Cypress Example Integration in our GitHub repository.

More resources

Here are some further resources to help you get started with integrating Cypress with Testiny, including CI/CD integration examples, a full automation guide, and the Testiny CLI.