Wrong TS signature for `Cypress.Commands.add`
See original GitHub issueCurrent behavior:
Current signature expect Cypress.Commands.add
to return void
.
This is incorrect, as you see by adding the example command you provide in docs:
https://docs.cypress.io/guides/tooling/typescript-support.html#Types-for-custom-commands
That command returns a Chainable
, which TS marks as error because the signature doesn’t expect any return value.
Desired behavior:
Avoid TS errors, as it actually works fine.
Test code to reproduce
Your dataCy
snippet.
Versions
TS: 1.8.3 Cypress: 4.7.0 Linux: 18.04
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Custom Commands - Cypress Documentation
Cypress comes with its own API for creating custom commands and overwriting existing commands. The built in Cypress commands use the very same...
Read more >Have an error when trying do make a Cypress.Commands ...
TS2345: Argument of type '(email: string, password: string) => void' is not assignable to parameter of type 'CommandFn"login">'. why am I having ...
Read more >Convert Cypress Specs from JavaScript to TypeScript
Convert Cypress Specs from JavaScript to TypeScript. While Cypress test is running you cannot insert or add new test commands from "outside".
Read more >Custom Commands in Cypress - Tools QA
We describe the signature of the custom command in file cypress/support/index.d.ts as shown below. We do it to let the TypeScript compiler know ......
Read more >property does not exist on type 'cy - You.com | The AI Search ...
cypress/support/index.ts. Cypress.Commands.add('typeRandomWords', { prevSubject: ... cy.pa11y typescript error: Property 'pa11y' does not exist on type 'cy ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the info. I finally reproduced it and created a test for that.
Released.
This comment thread has been locked as resolved.