A Cypress plugin to retry failed tests.
Branch: master
Clone or download
Latest commit 421fb17 Feb 18, 2019



A Cypress plugin to retry failed tests

Please report bugs in the issues of this repo.

Please refer to this issue for updates about official cypress retry support


Add the plugin to devDependencies

npm install -D cypress-plugin-retries

At the top of cypress/support/index.js:



Use the environment variable CYPRESS_RETRIES to set the retry number for all spec files:

CYPRESS_RETRIES=2 npm run cypress

or Use Cypress.env('RETRIES') in your spec file to set the retry number for all tests:

Cypress.env('RETRIES', 2)

or On a per-test or per-hook basis, set the retry number:

Note: this plugin adds Cypress.currentTest and you should only access it in the context of this plugin.

it('test', ()=>{

or [undersirable] Use mocha's this.retries(n) inside of a test:

Note: must use function() notation, not arrows ()=>{}

it('test', function() {

How it works

  • tests only retry on failure. If all your tests pass on the first try, it's as if you didn't have this plugin.
  • only the final run of a test will be sent to the mocha reporter/Dashboard. his means if a test passes on the second retry, you'll see one passing test.
  • a screenshot is taken on each test retry. This can be configured as detailed here: https://docs.cypress.io/api/commands/screenshot.html#Test-Failures
  • commands from past test tries will be faded out, as shown in the screenshot above