Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command anomaly #6146

Open
alastair-todd opened this issue Jan 12, 2020 · 1 comment
Open

Add command anomaly #6146

alastair-todd opened this issue Jan 12, 2020 · 1 comment

Comments

@alastair-todd
Copy link

@alastair-todd alastair-todd commented Jan 12, 2020

Cypress.Commands.add('getAlias', (alias:string) => cy.get(`@${alias}`));

results in

TypeError: command.get is not a function

but

Cypress.Commands.add('alias', (alias:string) => cy.get(`@${alias}`));

does not

what trickerypokery?

@jennifer-shehane

This comment has been minimized.

Copy link
Member

@jennifer-shehane jennifer-shehane commented Jan 13, 2020

I can recreate this behavior.

Cypress.Commands.add('getAlias', (alias:string) => cy.get(`@${alias}`));

cy.getAlias('foo')

The command above throws the error TypeError: command.get is not a function when called

Screen Shot 2020-01-13 at 11 41 01 AM

This error is throwing from this line of code as shown from the stack trace you can see when you click on the yellow error: https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cy/commands/querying.js#L240:L240

Why

I thought this may have been some sort of regression with a decaffeinated file but this error throws back to version 3.4.1.

I believe this is throwing because we have an internal command called cy.getAlias

https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cy/aliases.coffee#L54:L54

So, this is a 'reserved name' of sorts although there's no documentation of this.

Workaround

Name your custom command anything other than getAlias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.