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):
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).
Import Results to Testiny
Make sure you've generated an API key and use the Testiny CLI to import the results to Testiny:
- Node.js/npm
- Linux
- Windows
- macOS
export TESTINY_API_KEY=****
npx @testiny/cli automation --project ID_OR_KEY --source "e2e" --cypress cypress/reports/*.json e2e
export TESTINY_API_KEY=****
./testiny-importer-linux automation --project ID_OR_KEY --source "e2e" --cypress cypress/reports/*.json e2e
set TESTINY_API_KEY=****
testiny-importer-win.exe automation --project ID_OR_KEY --source "e2e" --cypress cypress/reports/*.json e2e
export TESTINY_API_KEY=****
./testiny-importer-macos automation --project ID_OR_KEY --source "e2e" --cypress cypress/reports/*.json e2e
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).
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.
Specify another relative base directory path with --attachment-path <FILE-PATH>
.
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.