Much to my regret if one of the tests is failing in a block, the statements in my after or afterEach
functions don’t get executed. It turned out that it is a known Cypress issue; any click event in the after block fails if one of the tests in an it block fails. It is a known since 2018.
Yes, it’s the click function that I need so much.
Folks, what is your workaround solution for this? Or you don’t experience this behaviour?
Here are the workarounds I have tried so far:
Force click
I guess you are familiar with this, but to make sure:
cy.get('element').click({ force: true });
ScrollIntoView
Something like:
cy.get('element').scrollIntoView().click();
Wrapping the click function
It is just the fancy way of force clicking on an element:
Cypress.Commands.add('forceClick', { prevSubject: 'element' }, (subject, options) => {
cy.wrap(subject).click({ force: true });
});
None of these worked. API calls remained as a refuge, which is kind of k. Not more than that.
How is it for you? Do you have a solution?