Cypress yeilding boolean outside .then scope [duplicate]

  automated-tests, cypress, javascript, testing

I try to yield my boolean value outside my .then() scope,
But it always keeps the value that I intialized it with..

This is what I tried:

        exampleFunc(){
        Let isTrue = false;
            Cy.get('@YieldedLocator).then(($YieldedLocator) => {
            isTrue = true;         
 cy.wrap(isTrue).as('isTrue');
            });
     
    `   cy.get('@isTrue').then(($isTrue) => {
        cy.log($isTrue);
        });
            }

After debbugging the code I can see that inside the scope the value is ‘True’,
And outside it ‘False’..

Source: Ask Javascript Questions

LEAVE A COMMENT