Can I have cy.task retry until assertion passes?
See original GitHub issuecy.task
is great but does not retry its action, even if it is idempotent code. In situations like “checking if the database has been updated” (see https://github.com/cypress-io/cypress-example-recipes/commit/e6f3b4c2cc7731c1ec9936426bb71b5ecb9af9ae#diff-11f8d1f12b6eb04ff4abd710d5e9d786) it would be perfect NOT to implement “retry until my assertion passes” logic in Node, but instead have cy.task
behave like a regular Cypress command.
Something like this
cy.taks('find item in the database').should('deep.equal', {id: 1, text: 'something'})
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Retry-ability - Cypress Documentation
Queries and assertions are always executed in order, and always retry 'from the top'. If you have multiple assertions, Cypress will retry until...
Read more >Incredibly Powerful cy.task - Gleb Bahmutov
The cy.task command does not retry. Because Cypress has no idea what your task is going to do - it probably is NOT...
Read more >Cypress not retrying assertion - Stack Overflow
From reading about Cypress retry-ability, my understanding is that the should assertion should keep trying until timeout, which is set as " ...
Read more >What are flaky tests in Cypress and how to prevent them?
You know that you have a flaky test when it passes when run ... and the assertion fails, Cypress will only retry the...
Read more >CRUD API testing a deployed service with Cypress using cy ...
What you will learn: CRUD testing any API. cy.task ... There are 4 ways to do assertions with Cypress, 3 of them have...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
better formatting
Closing as resolved since there is a workaround outlined.
If you’re experiencing a bug similar to this in Cypress, please open a new issue with a fully reproducible example that we can run. There may be a specific edge case with the issue that we need more detail to fix.