Coder Social home page Coder Social logo

cypress-backoff's Introduction

cypress-backoff

npm

Convience library to apply different timeout strategies to retried tests. Inspired by Filip Hric.

This repository is not maintained by the Cypress developers.

Installation & usage

  1. Install the module.

    npm install cypress-backoff
  2. Add the retries to cypress.config.js.

    ...
    module.exports = defineConfig({
        retries: 5,
    ...
  3. Import the module

    const backoff = require('cypress-backoff')
  4. Add your preferred timeout and strategy in the beforeEach block of your test

    beforeEach(() => {
        backoff.linear(1000)
    }

Available strategies

linear

Provide the desired timeout increase in milliseconds.

The timeout will increase with this number for every next attempt, i.e. 1000, 2000, 3000...

backoff.linear(1000)

exponential

Provide the desired timeout in milliseconds and exponential rate as an integer.

The timeout will be calculated as $T = timeout * exponentialrate^r$

backoff.exponential(1000, 2)

fixed

Provide an array with the desired timeout for each subsequent retry. If you allow more retries than elements specified the last element will be used.

backoff.fixed([1000, 2000, 3000])

fibonacci

Provide the desired timeout which will be multiplied by the fibonacci number of the retry.

backoff.fibonacci(1000)

custom

Provide a custom function that accepts the retry count as a parameter and returns the desired timeout.

backoff.custom((retryCount) => {return retryCount*2000})

JSDoc function documentation

The documentation of each of the functions can be found here.

cypress-backoff's People

Contributors

joostvanwollingen avatar

Stargazers

 avatar

Watchers

 avatar

cypress-backoff's Issues

Proud of you

I'm so proud of you. keep up the good work Joost you will become a great developer ๐Ÿ‘๐Ÿพ

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.