I need to create a test in Cypress that loads a page and checks if a modal opens within 5 seconds. If the modal opens, it should close it. If the modal does not open, the test should proceed to the specified testcase in the before block. How can I achieve this? Currently, I have the following code which only closes the modal if it exists.
function checkModalThenProceed() {
cy.get(#check modal is open function).then(($modal) => {
if ($modal) {
closedModal();
}
})
}
describe('testing if-else scenario', () => {
before(()=>{
checkModalThenProceed();
})
it('testflow', () => {
expect(1).to.eq(1);
});
})