Return types of Cypress commands
See original GitHub issueWhat would you like?
It seems that Cypress.Chainable
interface is not really used or required when yielding stuff from one command to another. A visual example:
I’d imagine that in order to use .click()
command a previous command needs to return proper type. Ideally compiler should complain about a command chain like this.
Ideally there should be possibility to use this at least with custom commands so that when I create something like cy.createItem()
in my codebase, it should be easily identifiable if this returns a response body from API or a DOM element.
@marktnoonan told me I can tag @lmiller1990 on this 😂
Why is this needed?
No response
Other
No response
Issue Analytics
- State:
- Created a year ago
- Comments:5 (4 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 >How to get returned value from custom commands ? (Cypress ...
To do this I'm using wrap() to return a Chainable containing the value I want to return. Since wrap() is returning a Cypress....
Read more >Cypress Return Values, Variables, and Aliases - YouTube
In today's video, we discuss return values, variables, and aliases in Cypress at a high level. This covers closures, the then command, ...
Read more >Return Cypress Chain - YouTube
If you refactor the test code, remember to return the Cypress command chain from the utility functions. This lets you attach more commands...
Read more >How to return a list of objects from Cypress Custom ... - GitHub
Chainable<JQuery<expectedData[]>> // ??? not sure what return type should be given here. } } } Cypress.Commands.add('getTestDataFromDynamoDB', ({locale, ...
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
I wonder if we just need to do a table/doc of all the different combinations that are possible, what we expect, and any edge cases, and re-assess how our types are organized/defined from a more high level… I am not sure how far we can get with incremental improvements. Starting with all DOM node related commands is a good idea. Getting type inference on commands that return DOM elements would be a huge productivity boost.
I’m thinking maybe a good place to start are commands that we definitely know will return an HTML element, like
eq()
,.filter()
,.parent()
etc. and then maybe pair them with all the.should()
assertion that only work for DOM elements? It’s not very “rounded feature”, but could maybe work as an initial proof of concept.