I want to check if a text/comment at a special location is like expected. If so, I want to count up itemFound by 1. The problem is, that I can't bring the variable to the outer scope. (later I want to search many locations for this element)
let itemFound = 0;
cy.xpath('//table/div/span').then((item) => {
let comment = item.text().trim();
if (comment == "myuniquecomment")
{
itemFound += 1;
}
cy.log(itemFound) // okay
})
cy.log(itemFound) // not okay