Created
February 22, 2021 22:45
-
-
Save bahmutov/6f527fe62a2eeec76b49c343fa74163d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('until the number 7 appears', () => { | |
const checkAndReload = () => { | |
// get the element's text, convert into a number | |
cy.get('#result').should('not.be.empty') | |
.invoke('text').then(parseInt) | |
.then((number) => { | |
// if the expected number is found | |
// stop adding any more commands | |
if (number === 7) { | |
cy.log('lucky **7**') | |
} else { | |
// otherwise insert more Cypress commands | |
// by calling the function after reload | |
cy.wait(500, { log: false }) | |
cy.reload() | |
checkAndReload() | |
} | |
}) | |
} | |
cy.visit('public/index.html') | |
checkAndReload() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment