Limitations | Tricks of Cypress: after or afterEach Hook

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 });


Something like:


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?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s