Run Cypress multiple times in a row, great at finding test flaky and force is needed
Read Wrap Cypress Using NPM Module API and Retry, Rerun, Repeat.
npm i -D cypress-repeat-pro
# or using Yarn
yarn add -D cypress-repeat-pro
This module assumes the cypress
dependency v5.3.0+ has been installed.
npx cypress-repeat-pro run -n <N> ... rest of "cypress run" arguments
Which will run Cypresss <N>
times, exiting after the first failed run or after all runs finish successfully.
You can flip the logic and run Cypress up to N times until the first successful exit
npx cypress-repeat-pro run -n <N> --until-passes ... rest of "cypress run" arguments
You can rerun only the specs that failed
npx cypress-repeat-pro run -n <N> --until-passes --rerun-failed-only ... rest of "cypress run" arguments
You can force continue running through all iterations even if a test fails
npx cypress-repeat-pro run -n <N> --force ... rest of "cypress run" arguments
Every run has two utility variables injected
const n = Cypress.env('cypress_repeat_n') // total repeat attempts
const k = Cypress.env('cypress_repeat_k') // current attempt, starts with 1
// and is <= n
Run this script with environment variable DEBUG=cypress-repeat-pro
to see verbose logs
This NPM module retries the entire Cypress run, if you need to retry just the failed tests, use the Test Retries.
***** Repeat Run Summary *****
Total Tests with repeat: 8
Total Passed: 7
Total Failed: 1
Total Skipped: 0
*****************************