worried-hairdresser-56712
05/02/2023, 6:01 AMcy.get("strong + .btn-close").should("be.visible").click().then(function() {
let text = moment().format("YYYY-MM-DD hh:mm");
return text
});
cy.contains(text).should("be.visible");
The result is:
text is not defined
What did I do wrong here? Thank you.enough-truck-68085
05/02/2023, 3:49 PMtext variable within a different scope than your cy.contains(text) validation
This is just a JS problem where you are trying to reference a variable that isn't defined in the correct scope.
If you move cy.contains(text).should("be.visible"); within the .then this should would just fine without having to return any variable.