Apply different timeouts to retried tests
npm install 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.
1. Install the module.
``shell`
npm install cypress-backoff
2. Add the retries to cypress.config.js.
`javascript`
...
module.exports = defineConfig({
retries: 5,
...
3. Import the module
`javascript`
const backoff = require('cypress-backoff')
4. Add your preferred timeout and strategy in the beforeEach block of your test
`javascript`
beforeEach(() => {
backoff.linear(1000)
}
The timeout will increase with this number for every next attempt, i.e. 1000, 2000, 3000...
`javascript`
backoff.linear(1000)
The timeout will be calculated as $T = timeout * exponentialrate^r$
`javascript`
backoff.exponential(1000, 2)
`javascript`
backoff.fixed([1000, 2000, 3000])
`javascript`
backoff.fibonacci(1000)
`javascript``
backoff.custom((retryCount) => {return retryCount*2000})
The documentation of each of the functions can be found here.