Skip to content
This repository has been archived by the owner on May 24, 2021. It is now read-only.

Retry with option to set intervals #52

Closed
volkanogretmen opened this issue Feb 20, 2020 · 1 comment
Closed

Retry with option to set intervals #52

volkanogretmen opened this issue Feb 20, 2020 · 1 comment
Labels
question Further information is requested

Comments

@volkanogretmen
Copy link

volkanogretmen commented Feb 20, 2020

I love using this plugin! The only that could make it even better from my point of view is the need to set an interval or "cool-down-period" before commencing the next retry.

So this:
Cypress.currentTest.retries(3)

Could perhaps look like this:
Cypress.currentTest.retries(3, 3000)

Where 3000 stands for ms to wait until next retry is kicked-off.

@kuceb
Copy link
Owner

kuceb commented Feb 28, 2020

here's an example of how to do that:

/// <reference types="cypress" />

Cypress.on('test:before:run:async', () => {
  if (Cypress.currentTest.currentRetry() > 0) {
    return new Promise((resolve) => setTimeout(resolve, 2000))
  }
})

describe('Some flaky suite', () => {
  let counter = 0

  beforeEach(() => {
    Cypress.currentTest.retries(4)
  })

  it('should pass on 3rd attempt', () => {
    counter++
    expect(counter === 3, 'some flaky assertion').eq(true)
  })
})

@kuceb kuceb closed this as completed Feb 28, 2020
@kuceb kuceb added the question Further information is requested label Feb 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants