Cypress: Environment based configurations

Created on 27 Jul 2017  路  7Comments  路  Source: cypress-io/cypress

Is this a Feature or Bug?

Feature

Current behavior:

Managing different environments for running cypress requires changes to code, to load different sets of variables.

Desired behavior:

In the desktop app, and cli you can specify a specific configuration file to use for loading different configurations.

Ideally, you could create different environment based configurations via cypress.qa.json cypress.dev.json cypress.prod.json with your environment based configurations set there. Then tell cypress which environment variable file you wanna use.

For the desktop app this could be done with a selectable menu, or input.
For the cli this could be done with a command argument, such as --config cypress.qa.json

feature

Most helpful comment

Not quite what you're suggesting, but much better, since you'll be able to use any arbitrary code to set config or environment variables.

How is it better? Here's my use case: I want to be able to call cypress run --configFile staging to execute my tests against the environment variables specified in cypress/config/staging.json.

How would you handle this?

All 7 comments

+1 for this feature. I thought it actually did this based on the .env doc.

The way node-config does it is really elegant, I'd recommend looking at this - https://github.com/lorenwest/node-config

This is being done here: https://github.com/cypress-io/cypress/issues/1042

Not quite what you're suggesting, but much better, since you'll be able to use any arbitrary code to set config or environment variables.

Released in 1.2.0.

Not quite what you're suggesting, but much better, since you'll be able to use any arbitrary code to set config or environment variables.

How is it better? Here's my use case: I want to be able to call cypress run --configFile staging to execute my tests against the environment variables specified in cypress/config/staging.json.

How would you handle this?

+1 to @pieterdd
I need the same functionality for different env types

You can call cypress run --configFile staging, --configFile is an argument that can be passed via the CLI for some time now. See https://on.cypress.io/command-line#cypress-open-config-file-lt-config-file-gt

Was this page helpful?
0 / 5 - 0 ratings

Related issues

simonhaenisch picture simonhaenisch  路  3Comments

zbigniewkalinowski picture zbigniewkalinowski  路  3Comments

jennifer-shehane picture jennifer-shehane  路  3Comments

rbung picture rbung  路  3Comments

weskor picture weskor  路  3Comments