1 | initial version |
Here are the steps to designate the .env file to be utilized for the dev server while carrying out Cypress tests:
API_URL=https://api.example.com
npm install --save-dev cypress-env
const cypressEnv = require('cypress-env')
module.exports = (on, config) => {
return cypressEnv.config(config)
}
This code will load the environment variables from your .env file into the Cypress configuration.
API_URL=http://localhost:3000 cypress open
This command sets the API_URL environment variable to the development server's URL.
Cypress.env()
method. For example:cy.visit(Cypress.env('API_URL'))