cypress-backoff
v1.2.0
Published
Apply different timeouts to retried tests
Downloads
815
Readme
cypress-backoff
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
Install the module.
npm install cypress-backoff
Add the retries to
cypress.config.js
.... module.exports = defineConfig({ retries: 5, ...
Import the module
const backoff = require('cypress-backoff')
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.