const { initLaunchDarklyApiTasks } = require('cypress-ld-control'); require('dotenv').config(); module.exports = (on, config) => { const tasks = { // add your other Cypress tasks if any } if ( process.env.LAUNCH_DARKLY_PROJECT_KEY && process.env.LAUNCH_DARKLY_AUTH_TOKEN ) { const ldApiTasks = initLaunchDarklyApiTasks({ projectKey: process.env.LAUNCH_DARKLY_PROJECT_KEY, authToken: process.env.LAUNCH_DARKLY_AUTH_TOKEN, environment: 'production', // the name of your environment to use }) // copy all LaunchDarkly methods as individual tasks Object.assign(tasks, ldApiTasks) // set an environment variable for specs to use // to check if the LaunchDarkly can be controlled config.env.launchDarklyApiAvailable = true } else { console.log('Skipping cypress-ld-control plugin') } // register all tasks with Cypress on('task', tasks) // IMPORTANT: return the updated config object return config }