Skip to content

Commit

Permalink
Custom command recipe throws an error
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Yohandah authored Feb 24, 2022
1 parent b751316 commit 1de09f1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion examples/fundamentals__add-custom-command/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ You write Cypress custom command, for example for selecting DOM elements by `dat
*
* @example cy.dataCy('greeting')
*/
Cypress.Commands.add('dataCy', (value) => cy.get(`[data-cy=${value}]`))
Cypress.Commands.add('dataCy', (value) => {
cy.get(`[data-cy=${value}]`)
})
```

Yet, TypeScript compiler and IntelliSense do not understand that you have added a new method to the global `cy` object.
Expand Down

0 comments on commit 1de09f1

Please sign in to comment.