Skip to content

Cypress.Commands.add with object argument #18886

@benwiley4000

Description

@benwiley4000

What would you like?

I want to be able to do this:

Cypress.Commands.add({
  myCommand(arg) {
    // ...
  },
  myOtherCommand(arg) {
    // ...
  }
});

Why is this needed?

This way we can maintain a commands.js file that looks like this:

export function myCommand(arg) {
  // ...
}

export function myOtherCommand(arg) {
  // ...
}

And we can add them all like this:

import * as commands from './commands';
Cypress.Commands.add(commands);

Other

This will be especially useful for typescript where declaring the function separately from the Cypress.Commands.add(...) call is helpful for maintaining correct typing in Cypress.Chainable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions