Skip to content

Typings for Command.add are missing types for the subject #18879

@SimeonC

Description

@SimeonC

Current behavior

A simple custom command that relies on prevSubject is not correctly typed.

Desired behavior

The "previous subject" argument should be correctly added to the command type and error if not passed.

Test code to reproduce

declare global {
  namespace Cypress {
    interface Chainable {
      confirmClick(): void;
    }
  }
}

Cypress.Commands.add('confirmClick', { prevSubject: true }, (confirmButton) => {
  confirmButton.click();
  cy.wrap(confirmButton)
    .should('have.attr', 'data-state', 'confirming')
    .click({ force: true });
});

Cypress Version

9.0.0

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    v9.0.0 🐛Issue present since 9.0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions