From 1de09f1c147d93f759c890afdfc7cc750776e352 Mon Sep 17 00:00:00 2001 From: Yohan Dahmani Date: Thu, 24 Feb 2022 15:36:18 +0100 Subject: [PATCH] Custom command recipe throws an error See : https://github.com/cypress-io/cypress/issues/18915 An error 'Argument of type '() => void' is not assignable to parameter of type '() => Chainable' throws when you return directly https://github.com/cypress-io/cypress/issues/18915#issuecomment-971834823 fixes #763 --- examples/fundamentals__add-custom-command/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/fundamentals__add-custom-command/README.md b/examples/fundamentals__add-custom-command/README.md index d3e50701f..c12e0a02f 100644 --- a/examples/fundamentals__add-custom-command/README.md +++ b/examples/fundamentals__add-custom-command/README.md @@ -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.