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

Custom command recipe throws an error #764

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Yohandah
Copy link

See : cypress-io/cypress#18915

An error 'Argument of type '() => void' is not assignable to parameter of type '() => Chainable' throws when you return directly

cypress-io/cypress#18915 (comment)
Sans titre

fixes #763

See : cypress-io/cypress#18915

An error 'Argument of type '() => void' is not assignable to parameter of type '() => Chainable<any>' throws when you return directly

cypress-io/cypress#18915 (comment)

fixes cypress-io#763
@CLAassistant
Copy link

CLAassistant commented Feb 24, 2022

CLA assistant check
All committers have signed the CLA.

Comment on lines +14 to +16
Cypress.Commands.add('dataCy', (value) => {
cy.get(`[data-cy=${value}]`)
})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change breaks command chaining. The command needs to return the cy.get() chain. Either keep the original one-liner:

Cypress.Commands.add('dataCy', (value) => cy.get(`[data-cy=${value}]`))

Or explicitly return the chain:

Cypress.Commands.add('dataCy', (value) => {
  return cy.get(`[data-cy=${value}]`)
})

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom command recipe throws an error
2 participants