Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set an environment variable during a Cypress test? [closed]

Tags:

cypress

I am looking to re-use a particular value across multiple step definitions in my Cypress/Cucumber test.

I was thinking of using a normal variable, but the problem is that the step definitions are stored in different files.

So I am wondering if I could assign the value to an environment variable & reference that in the other file.

I was trying to do something like Cypress.env('myUsername') = 'testUser', but I get this lint error:

enter image description here

like image 861
user9847788 Avatar asked Oct 12 '25 04:10

user9847788


1 Answers

Cypress environment variables can be set during a test by passing in the desired value as the second argument.

Cypress.env('HOST', 'asdf');
like image 168
agoff Avatar answered Oct 14 '25 17:10

agoff