Skip to content

How to overwrite baseUrl via commandline when using a config file that extends cypress.json? #16367

Discussion options

You must be logged in to vote

Here's a neat trick. You can dynamically modify the config from cypress/plugins/index.js:

// cypress/plugins/index.js
module.exports = (on, config) => {
  return config
}

So, you could do:

// cypress/plugins/index.js
module.exports = (on, config) => {
  return {
    ...config
    baseUrl: process.env.CYPRESS_BASE_URL || config.baseUrl
  }
}

That would override the baseUrl dynamically from an environment variable. Since plugins/index.js is just JS, you have lots of power and flexibility. You should be able to use some combination of code and config to accomplish what you want.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@timnederhoff
Comment options

Answer selected by lmiller1990
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants