I'm trying to write a test that goes back in a calendar to look for a specific date to click. I have come up with an IF statement that should loop to the next month should date not be found.
Given('I test {string}', (control) => {
if (
cy
.get(`[data-cy="${control}"]`)
.scrollIntoView()
.should('be.visible')
) {
cy.get(control).first().click();
// do something if it's active
} else {
cy.get(`[data-cy="${'date-picker-left-arrow'}"]`).click();
// do something else
}
});
However, my test fails without iterating to the next condition.