index.js
1 //const webpackPreprocessor = require('@cypress/webpack-preprocessor'); 2 // *********************************************************** 3 // This example plugins/index.js can be used to load plugins 4 // 5 // You can change the location of this file or turn off loading 6 // the plugins file with the 'pluginsFile' configuration option. 7 // 8 // You can read more here: 9 // https://on.cypress.io/plugins-guide 10 // *********************************************************** 11 12 // This function is called when a project is opened or re-opened (e.g. due to 13 // the project's config changing) 14 15 /** 16 * @type {Cypress.PluginConfig} 17 */ 18 // eslint-disable-next-line no-unused-vars 19 module.exports = (on, config) => { 20 // `on` is used to hook into various events Cypress emits 21 // `config` is the resolved Cypress config 22 try { 23 // eslint-disable-next-line @typescript-eslint/no-var-requires 24 const configWithDotenv = require('dotenv').config({ 25 path: process.env.DOTENV_CONFIG_PATH, 26 }); 27 const env = { ...config.env, ...configWithDotenv.parsed }; 28 const result = { ...config, env }; 29 return result; 30 } catch (e) { 31 return config; 32 } 33 };