cypress-config-switcher
v1.0.0
Published
Support for switching between different dev/ci environments at runtime
Downloads
256
Readme
Introduction
Support for switching between different dev/ci environments at runtime based on the CYPRESS_ENVIRONMENT env variable.
Install
Add git repo to your package.json
dependencies
"cypress-config-switcher": "*"
or use npm install
and save
npm install --save-dev cypress-config-switcher
Configure
Plugin file
The code below should be added to your cypress/plugins/index.js
file.
const ConfigSwitcher = require('cypress-config-switcher');
module.exports = (on, config) => {
config = ConfigSwitcher.loadEnvConfig(config);
// Do stuff with config. e.g. pass to DB extension
return config;
}
Config Files
Add a config folder to your Cypress/support folder. Within this, multiple config files can be created containing values that change across environments. For example, DB credentials or the baseUrl for your app.
"baseUrl" : "https"//my.testurl.com",
"db": {
"userName": "",
"password": "",
"server": "",
"options": {
"database": "",
"encrypt": true,
"rowCollectionOnRequestCompletion" : true
}
}
If no CYPRESS_ENVIRONMENT is specified, the config switcher will look for config/dev.json by default. If no config file is present, cypress.json is used as a fallback.