Convience library to apply different timeout strategies to retried tests. Inspired by Filip Hric.
This repository is not maintained by the Cypress developers.
-
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) }
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)
Provide the desired timeout in milliseconds and exponential rate as an integer.
The timeout will be calculated as
backoff.exponential(1000, 2)
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])
Provide the desired timeout which will be multiplied by the fibonacci number of the retry.
backoff.fibonacci(1000)
Provide a custom function that accepts the retry count as a parameter and returns the desired timeout.
backoff.custom((retryCount) => {return retryCount*2000})
The documentation of each of the functions can be found here.