Skip to content

Custom Command is not a function #25348

Closed
@yurakhomitsky

Description

@yurakhomitsky

Current behavior

I was following along with the installation instructions from cypress/schematic for "ng new" project

Then I decided to add a custom command however cypress throws the error: "cy.login is not a function"

  • To add a custom command I wrote the following code in the commands.ts file
    Cypress.Commands.add("login", () => { cy.log('login...') })

  • Added it to the namespace
    declare namespace Cypress { interface Chainable<Subject = any> { login(): any; } }

  • Uncommented this line import './commands'; in the e2e.ts file

  • Used cy.login() in the spec.cy.ts file

image

Desired behavior

Cypress should not throw the error "cy.login is not a function"

Test code to reproduce

https://github.com/yurakhomitsky/cypress-angular-schematic-issue

Cypress Version

12.2.0

Node version

16.15.0

Operating System

macOS 13.0.1

Debug Logs

No response

Other

No response

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