You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am retrying a function that calls either a simple async promise-returning function or a function that calls cy.task. In both cases little utility function retry checks the upcoming assertion to stop.
constgetRandomNumber=()=>{returnnewCypress.Promise((resolve,reject)=>{setTimeout(()=>{constx=Cypress._.random(0,50)console.log('resolving with %d',x)resolve(x)},10)})}constretry=fn=>()=>{returnfn().then(value=>{returncy.verifyUpcomingAssertions(value,{},{onRetry: retry(fn)})})}it('retries task',()=>{letcounter=0constlimit=100constprintToTerminal=()=>cy.task('print',(counter+=1),{log: false})// cypress-pipe does not retry Cypress chains// cy.document()// // .pipe(printToTerminal)// .should('equal', limit)cy.log('retrying task')cy.then(retry(printToTerminal)).should('equal',limit)cy.log('retrying async random number')cy.then({timeout: 10000},retry(getRandomNumber)).should('equal',10)})
The getRandomNumber retries itself fine and stops, and the assertion is green.
The printToTerminal that calls cy.task runs, retries, passes - but the assertion is still spinning in the UI
The text was updated successfully, but these errors were encountered:
Quite an esoteric test case, but shows some edge case in assertion state management
Cypress 3.1.4 on Mac
Source code in https://github.com/bahmutov/retry-task-demo just clone, install and run
I am retrying a function that calls either a simple async promise-returning function or a function that calls
cy.task
. In both cases little utility functionretry
checks the upcoming assertion to stop.The
getRandomNumber
retries itself fine and stops, and the assertion is green.The
printToTerminal
that callscy.task
runs, retries, passes - but the assertion is still spinning in the UIThe text was updated successfully, but these errors were encountered: