npm.io
1.3.0 • Published 3 years ago

cypress-plugin-dotenv

Licence
MIT
Version
1.3.0
Deps
1
Size
8 kB
Vulns
0
Weekly
0
Stars
5

Install

  • npm:
npm install cypress-plugin-dotenv
  • yarn:
yarn add cypress-plugin-dotenv
  • pnpm:
pnpm add cypress-plugin-dotenv

Usage

Import the plugin into your config file:

import { dotenv } from 'cypress-plugin-dotenv';
// or
const dotenv = require('cypress-plugin-dotenv');

export default defineConfig({
  e2e: {
    setupNodeEvents: (_, config) => {
      return dotenv(config);
    }
  }
});

Dynamic Types

Automate TypeScript definitions for .env with:

import { generateEnvTypes } from 'cypress-plugin-dotenv';

on('before:browser:launch', (browser, launchOptions) => {
  generateEnvTypes(outputPath, options);

  // your code
});

Important: Run Cypress once after setup to initialize the types.

Example

Take a look at cypress folder

License

This project is licensed under the terms of the MIT license.

Keywords