Chaining after within: Return inner chainable?
See original GitHub issueCurrent behavior:
cy.get(`.parent`).within(() => cy.get(`.child`))
Yields the parent if I’m correct (?).
Desired behavior:
I’d expect the previous command to yields the selected child.
It would be very helpful so that when we have a function or a getter to retrieve an element we could chain them.
Versions
Cypress 3.2.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Promises chaining - The Modern JavaScript Tutorial
A Promise keeps an internal state. It calls the handler wrapped in a try...catch block and stores the error. That is why asynchronous...
Read more >How can I chain two observables and return the inner ...
I think its not returning the correct observable. It seems to just return the getSpecificSegment and then the inner observable doesn't execute, ...
Read more >Understanding Method Chaining In Javascript - segunolalive
This example shares lots of similarities with the ChainAble class shown before. It contains methods that do some things, then return this.
Read more >Understanding Cypress's command execution order and ...
A Chainable object is what all Cypress commands return, and are what is stored in the queue of commands mentioned above. As explained,...
Read more >Optional chaining (?.) - JavaScript - MDN Web Docs - Mozilla
This is an idiomatic pattern in JavaScript, but it gets verbose when the chain is long, and it's not safe. For example, if...
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 think we will close for now but track if anyone else requests this feature.
Yeah, you could use
.then()
to return the inner “promise” https://on.cypress.io/then#Yields but then you’d have to scope the inner commands yourself, since you’d be losing thewithin
scope.Something like: