Skip to content

Instantly share code, notes, and snippets.

@jrson83
Forked from estefafdez/cypress-plugins-index.js
Created February 6, 2023 21:46
Show Gist options
  • Save jrson83/041793814a4426a3bb35840bfe68f9a5 to your computer and use it in GitHub Desktop.
Save jrson83/041793814a4426a3bb35840bfe68f9a5 to your computer and use it in GitHub Desktop.
cypress/plugins/index.js with different configuration files.
// promisified fs module
const fs = require('fs-extra')
const path = require('path')
function getConfigurationByFile(file) {
const pathToConfigFile = path.resolve(__dirname, '../config', `${file}.json`)
return fs.readJson(pathToConfigFile)
}
// plugins file
module.exports = (on, config) => {
// accept a configFile value or use qa by default
const file = config.env.configFile || 'qa'
console.info('\n> Cypress config:', config);
return getConfigurationByFile(file)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment