@monitorapex/cypress-config-switcher

1.0.0 • Public • Published

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

"@monitorapex/cypress-config-switcher": "*"

or use npm install and save

npm install --save-dev @monitorapex/cypress-config-switcher

Configure

Plugin file

The code below should be added to your cypress/plugins/index.js file.

const ConfigSwitcher = require('@monitorapex/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.

Readme

Keywords

none

Package Sidebar

Install

npm i @monitorapex/cypress-config-switcher

Weekly Downloads

0

Version

1.0.0

License

UNLICENSED

Unpacked Size

3.17 kB

Total Files

10

Last publish

Collaborators

  • drumbeg
  • dlawton