I want to use a value of a var that is set inside of .then() in the outer scope
I tried
let numOfDropdownFields = 0;
cy.get("dropdown")
.find("button")
.its("length")
.as("len")
.then(($len) => {
cy.log("No. of buttons:" + $len);
numOfDropdownFields = $len;
cy.get("@len").should("eq", numOfDropdownFields);
cy.log(numOfDropdownFields);
});
cy.log(numOfDropdownFields);
The first log prints: No. of elements: 14
The second log: 14
And the third log: 0
How can I see the value 14 outside the .then() callback?