Closed emilong closed 3 years ago
A done callback is passed as the first argument for test functions, same as Mocha: https://mochajs.org/#asynchronous-code So, it could not be available as the first arg.
Since this functionality is already possible with the existing arrow function and this calls, I would not expect this to be introduced anytime soon, if at all.
We will reconsider if we see this issue gains more 👍 or comments in support.
What would you like?
Yield context as the first argument to a test function, much like
this
is bound to non-arrow functionsfunction() {}
.e.g.
Why is this needed?
Currently the only way to get the value of aliases is to use:
function() {}
style test body and usethis.myAlias
. Many people prefer not to usethis
and/orfunction
syntax as they find it less descriptive.cy.get("@myAlias")
, which has the potential to introduce a lot of nesting tests with a lot of aliases.I believe part of this issue (related to aliases, but not to selectors) covers these concerns: https://github.com/cypress-io/cypress/issues/1417
Given that nothing appears(?) to be passed as an argument to test functions now, I think this should be fully backwards compatible.