-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expand clarification of cy.wrap() when used with Promises #2689
Conversation
👍 I still find it mighty important to mention this behavior at the top of the documentation. otherwise it will still be overlooked. once I know I needed |
There's an entire section on Promises. Highlighting one use case of a command at the top of the API documents would quickly get out of hand if everyone requested their specific use case be highlighted more importantly. There's multiple reasons to use wrap, so I don't see why this use case should require more highlighting than the others. |
Because, if you see it with beginners eye, the naming of the method That's clear from the name, but many would have never thought (like seen in the linked issues thread) about using it to wait for a promise and then use it's result already wrapped. I think it just cost me and several others dozen of hours, because whenever as a newbie you see Because why would you think about that there is some "hidden" additional feature, which is pretty important if you work with promises, you need to learn about via an example, if there is no indication given at the top, that it can be used for other uses than just make object
And since a lot of use cases of cypress need promises/async workflow, I think it's pretty important for newcomers to get a grip on this feature of All in all it made my first encounter with using |
lib/tags/assertions.js
Outdated
@@ -83,6 +83,13 @@ module.exports = function yields (hexo, args) { | |||
</ul>`) | |||
} | |||
|
|||
const wrap = () => { | |||
return render(`<ul> | |||
<li><p>${cmd}, when its argument is a promise, will automatically {% url "retry" retry-ability %} until the promise resolves.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should call it "retry" since we are NOT going to re-execute the promise, it is impossible. I think we can say "will automatically wait until the promise resolves".
We should also note that if the promise is rejected, cy.wrap
will fail the test
I think at the top we could mention it @jennifer-shehane
Also I noticed at the bottom we are not including the following links
|
Updated based off of @bahmutov feedback - did not link to example recipes since that has not been deployed. Will go back to update inter-links after that's deployed on API pages. |
🙌 |
Truthfully #1808 originally addressed this, but the examples were not obvious enough (needs to be specified in the assertions and could probably use a less complicated example as noted in #2664)
wrap(promise)
more prominent #2664