Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Cypress plugin that enables compatability with dotenv

Notifications You must be signed in to change notification settings

kamikazePT/cypress-dotenv-flow

 
 

Repository files navigation

Cypress dotenv-flow

Cypress plugin that enables compatability with dotenv-flow.

Build Status Maintainability Test Coverage

What does this thing do?

It will load any environment variables defined in your .env.<environment>.local file so you can access them via Cypress.env() from within your tests as you would expect.

Any Cypress config options defined in your .env will also be applied and take precedence over what is in your cypress.json file. See the Cypress docs for details on this

For example, if your .env file has something like this:

CYPRESS_HELLO=hola
GOODBYE=adios

You can use Cypress.env('HELLO') to access its value.

Install

You will also need to install the original dotenv-flow package along with cypress-dotenv-flow

npm install --save-dev dotenv-flow cypress-dotenv-flow 

or

yarn add --dev dotenv-flow cypress-dotenv-flow

Configure

Since this is a plugin, you will need to modify your file cypress/plugins/index.js to look something like this:

const dotenvFlowPlugin = require('cypress-dotenv-flow');
module.exports = (on, config) => {
  config = dotenvFlowPlugin(config)
  return config
}

Options

This plugin takes three paramaters. The first parameter (which is mandatory) is the Cypress config object.

The second is an optional dotenv-flow config object.

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_.

About

Cypress plugin that enables compatability with dotenv

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 98.4%
  • Shell 1.6%