Monday, December 11, 2023
 Popular · Latest · Hot · Upcoming
20
rated 0 times [  24] [ 4]  / answers: 1 / hits: 8636  / 4 Years ago, tue, may 19, 2020, 12:00:00

I'm new to cypress and have created my first project with a cypress.json file in the root directory.



project



The contents of this file are as follows:



{
projectId: bdld4
env:{
host: http://localhost:8000,
email: [email protected],
password: obviouslyNotaRealPassword
}
}


Within the integration folder I have a test case which is attempting to access those environment variables:



Cypress.env('host')


This returns undefined. I have also tried this in cypress.env.json and have also tried placing the cypress.json file one level above the Cypress folder.



To run the tests, i'm using npx cypress open and selecting the test from the gui. Am I running the tests incorrectly or should the file be placed elsewhere? Any ideas?


More From » cypress

 Answers
6

the picture you have posted, cypress.json is not placed the root. It is inside the cypress folder.




  1. Either you can place the cypress.json one level up, I mean in the root of the project


  2. Or, you can pass the config file path parameter in your script, like:




npx cypress open --config-file cypress/cypress.json

[#3758] Sunday, May 17, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hailie

Total Points: 25
Total Questions: 112
Total Answers: 111

Location: Belize
Member since Tue, Dec 8, 2020
3 Years ago
;