morficus / cypress-dotenv

Cypress plugin that enables compatability with dotenv
53 stars 13 forks source link

Add mapping from one environment variable to another #11

Closed vintprox closed 4 years ago

vintprox commented 4 years ago

What really gets me is that I have to duplicate BASE_URL (that is supposed for running Nuxt.js server) in .env into CYPRESS_BASE_URL variable (that overrides baseUrl for Cypress).

Would be neat if cypress-dotenv provided a way to solve such problem via mapping existing variable to another.

vintprox commented 4 years ago

Actualy, when I give it a second thought, there is a way for me to do it: https://docs.cypress.io/api/plugins/configuration-api.html#Usage

morficus commented 4 years ago

You can also pass in a 3rd argument in to the plugin and it will load ALL env vars in to Cypress, not just the ones prefixed with CYPRESS_

The third is an optional [all] boolean parameter, which is set to false by default. If set to true, it returns all available environmental variables, not limited to those prefixed with CYPRESS_.

So it would look something like this:

config = dotenvPlugin(config, {}, true)
morficus commented 4 years ago

If you are still having issues with this, please feel free to comment back on this feature request and I'll open it back up