typescripttestingcypresscypress-custom-commands

Cypress custom commands


If you have separate repositories for library and consumer, the custom commands defined in one repository(library) is not available in consumer repository. I get cy.samplecommmand() is not a function error

Is there a way to use custom commands from one repository in another repository?

Cypress from consumer repository couldn’t able to identify the commands from library tried adding ../support/commands in library package


Solution

  • Adding an import statement in command.js (consumer package) referring to node_modules worked for me.

    Example:

    import "@ex/librarypackage/dist/support/command.js";