-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Alias in before
block disappears after first test
#18161
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Current behavior
If we alias a value in a
before()
block then it can only be retrieved (withcy.get()
) in the first test in a suite; attempting to retrieve it in the second or subsequent tests results inDesired behavior
It is quite common to want to run a some initial query (e.g. a fetch from an API) at the start of a suite of tests, and alias with
cy.as()
. This alias should be available to all subsequent tests (within the current scope / context).Test code to reproduce
Cypress Version
8.3.1
Other
One workaround is to move the setup steps to
beforeEach
but this might be heavyweight (e.g. running a bunch of initial API requests on every single test, rather than once per suite)The text was updated successfully, but these errors were encountered: