Code Monkey home page Code Monkey logo

cypress-plugin-retries's Introduction

cypress-plugin-retries

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

Installation

Add the plugin to devDependencies

npm install -D cypress-plugin-retries

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

require('cypress-plugin-retries')

Usage

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', () => {
    Cypress.currentTest.retries(2)
})

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

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

it('test', function() {
    this.retries(2)
})

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.
  • during a retry, all beforeEach and afterEach hooks that apply the test will be re-ran
  • beforeAll(before) hooks are not re-ran on retry. These are guaranteeed only to be ran once.
  • if a test fails in a beforeEach hook, the test will retry
  • if a test fails in a afterEach/afterAll hook, the test will not retry, but fail as normal
  • only the final run of a test will be sent to the mocha reporter/Dashboard. This 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

License

MIT

cypress-plugin-retries's People

Contributors

kuceb avatar

Stargazers

dirk avatar

Watchers

James Cloos avatar Jalal Fathi avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.