Skip to content
Discussion options

You must be logged in to vote

Minimal example of a Cypress command:

Cypress.Commands.add("shouldNotBeActionable", { prevSubject: "element" }, (subject, done) => {
  cy.once("fail", (err) => {
    expect(err.message).to.include("`cy.click()` failed because this element");
    expect(err.message).to.include("is being covered by another element");
    done();
  });

  cy.wrap(subject).click(position, { timeout: 100 }).then(() =>
    done(new Error("Expected element NOT to be clickable, but click() succeeded")));
});

declare global {
  namespace Cypress {
    interface Chainable {
      shouldNotBeActionable(done: Mocha.Done): Chainable<Element>;
    }
  }
}

Example usage:

it("should not be clickable", (done) => {
  cy.get(

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@varganatt
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by varganatt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants