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:
committed by
GitHub
parent
cd3e68cc66
commit
3930e1cb03
31
nodejs/react-cypress-launchdarkly-feature-flag-test/cypress/plugins/index.js
vendored
Normal file
31
nodejs/react-cypress-launchdarkly-feature-flag-test/cypress/plugins/index.js
vendored
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user