Skip to content
Cypress plugin that enables compatability with dotenv
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.env
.env.no-cypress
.gitignore
.prettierrc.json
.travis.yml
README.md
index.js
index.spec.js
jest.config.js
package-lock.json
package.json

README.md

Cypress dotenv

Cypress plugin that enables compatability with dotenv.

Build Status Maintainability Test Coverage

What does this thing do?

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

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

npm install --save-dev cypress-dotenv

or

yarn add --dev cypress-dotenv

Configure

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

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

Options

This plugin takes two paramaters. The first parameter (which is mandatory) is the Cypress config object and the other is an optional dotenv config object.

You can’t perform that action at this time.