Reputation: 6265
I'm new to cypress and have created my first project with a cypress.json file in the root directory.
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?
Upvotes: 3
Views: 13315
Reputation: 51
just FYI - Cypress no longer supports cypress.json. Use cypress.config.js instead.
I got an error when I had both a cypress.json and cypress.config.json file in my repo.
Upvotes: 3
Reputation: 424
the picture you have posted, cypress.json
is not placed the root. It is inside the cypress
folder.
Either you can place the cypress.json
one level up, I mean in the root of the project
Or, you can pass the config file path parameter in your script, like:
npx cypress open --config-file cypress/cypress.json
Upvotes: 6