Test and Automate Features behind the Flags using Cypress Tests (#206)

* nodejs cypress test launchdarkly

* Delete README.md

* refactor code

* refactor code

* code cleanup

Co-authored-by: Arpendu Kumar Garai <Arpendu.KumarGarai@microfocus.com>
This commit is contained in:
Arpendu Kumar Garai
2022-11-07 14:21:48 +05:30
committed by GitHub
parent cd3e68cc66
commit 3930e1cb03
20 changed files with 591 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
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
}