Skip to content

exit loop based on if/else condition #15576

Discussion options

You must be logged in to vote

Cypress commands are asynchronous, thus the while or for loops will always NOT work as you expect them. Instead you need to use recursion. See this recipe https://github.com/cypress-io/cypress-example-recipes/tree/master/examples/testing-dom__page-reloads and implement your logic using https://github.com/bahmutov/cypress-recurse

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by bahmutov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants