I'm trying to do a simple while loop within a Cypress test that exits when a variable is updated.
I know that the variable 'done' is being updated to tru at the time within the loop - but by the time it gets back up to the top of the loop, it's still set to false.
    let ii = 0;
    let done = true;
    cy.log('done outside the loop - its true: ' + done);
    done = false;
    cy.log('done outside the loop - its now false: ' + done);
    while((ii<4) && (!done)) {
        cy.log('done inside the loop:  ' + done);
        
        cy.wait(1000);
        ii++;
        cy.get('[data-cy="reportGenOtherDialog"]').then($dialog => {
            let reportGenOtherDialog = $dialog;
            cy.log(reportGenOtherDialog.text());
            if (reportGenOtherDialog.text() === 'Publish Successful.') {
                
                done = true;
                cy.log('this proves that it is getting to here and updating - but it will still be false the next go-around: ' + done);
            }
        })
        
    }
Any suggestions?
Thanks much.
