question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong TS signature for `Cypress.Commands.add`

See original GitHub issue

Current 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.

image

image

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:closed
  • Created 3 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
sainthkhcommented, Jun 4, 2020

Thanks for the info. I finally reproduced it and created a test for that.

0reactions
jennifer-shehanecommented, Aug 20, 2020

Released.

This comment thread has been locked as resolved.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found