Understanding the difference between invoking cy commands inside a promise in these two examples #25975
Unanswered
zakariaelas
asked this question in
Questions and Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
Would appreciate anyone helping me wrap my head around the following two examples:
Example 1
Initially, I did something like this:
Then I invoked the custom command from my test.
From the above example, I got this error:
Example 2
I tried fixing the above error by doing the following:
This worked, but I don't really understand why. I can see that in Example 2 my custom command is no longer returning a promise (removal of
async
from the arrow function), however,then
is also technically returning a promise in which I'm calling a cy command (cy.log
).Can you help me understand why Example 2 works, but not Example 1? Would really appreciate help building the right mental model for working with Cypress.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions