cypress-plugin-dotenv
ย 
โ๏ธ Install
npm install cypress-plugin-dotenv
yarn add cypress-plugin-dotenv
pnpm add cypress-plugin-dotenv
๐งช Usage
Import the plugin into your config file:
import { dotenv } from 'cypress-plugin-dotenv';
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);
});
โ ๏ธ 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.