Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose current retry attempt with test / hook to programatically handle retries #8404

Closed
mattrlong opened this issue Aug 25, 2020 · 3 comments
Labels
existing workaround stage: ready for work The issue is reproducible and in scope type: enhancement Requested enhancement of existing feature

Comments

@mattrlong
Copy link

Current behavior:

Prior to v5.0.0 and using cypress-retries-plugin the retry attempt could be programmatically obtained through Cypress.currentTest.currentRetry()

Have tried using Mocha's this.test._currentRetry but this is only usable within the tests (.it) and not the hooks where much of our test setup resides.

Interestingly keeping the plugin installed as a dependency seems to be working, although not sure what other consequences this might cause.

Desired behavior:

The same feature being made available natively through Cypress. Would be great to be made available on the Cypress global as before.

Test code to reproduce

Previous usage documented here.

Versions

Cypress v5.0.0

@kuceb
Copy link
Contributor

kuceb commented Aug 25, 2020

It's undocumented, but you may use cy.state('test').currentRetry() to get the current retry number from anywhere in the spec.

If you use function () {} syntax,
In test bodies you may use this.test.currentRetry()
In hooks you may use this.currentTest.currentRetry()

I agree we should add a better api for accessing this and document it.

@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Aug 25, 2020
@mattrlong
Copy link
Author

Thanks @bkucera, cy.state('test').currentRetry() looks to fulfil our requirements as this can also be used in support files.

@jennifer-shehane jennifer-shehane changed the title expose retry attempt to programatically handle retries expose current retry attempt with test / hook to programatically handle retries Aug 26, 2020
@emilyrohrbough
Copy link
Member

This was exposed as Cypress.currentRetry() in 12.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
existing workaround stage: ready for work The issue is reproducible and in scope type: enhancement Requested enhancement of existing feature
Projects
None yet
Development

No branches or pull requests

4 participants