How do I retry the whole spec instead of individual specs in Cypress?

Viewed 556

there is an option to use in cypress.json called "retries" that defines the number of times a failed test will be retried.

The way I have written my tests there is some relation between the tests (test1 : create entry and get id, test2: get entry by id and edit it, test3: delete by id ) and most times the retries do not help me avoid flakiness and all the retries fail.

I can use the retry option in my CI/CD that will retry all the specs. which is too wasteful and not super helpful as I might get a flaky error in some other test in the second retry.

So ideally, I would like to retry the whole spec when it fails, is there a way to do this?

EDIT:

even if configured in describe at the top of the spec, retries are still per test: enter image description here

1 Answers

You shouldn't make your test dependent, have a look on the the cypress best practices, but if you really have no other way look at retries guide, you can use the retries on the describe:

describe('User bank accounts', {
  retries: 2
}, () => {
...
Related