Reputation: 27
I have to create a new user in each test. To avoid duplicate emails, I always want to append the current date to the end of the mail. Since I then need this date in different places in the test, I would like to export it as env. Is there a way to do this directly from the test. The env must thereby also exist across multiple test files and only be reset when the test runs again.
Upvotes: 0
Views: 1004
Reputation: 4395
The way to do it is to provide the value as 2nd parameter
Cypress.env('email', 'the-email') // set
...
const email = Cypress.env('email') // get
This persists across all tests in the run.
Upvotes: 1