Adding to module.exports on cypress/plugins/index.js file Cypress
Solution 1:
I believe that you can pass in the config from your function to your require
and then return that new config.
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
const file = config.env.configFile || 'qa';
let newConfig = getConfigurationByFile(file);
require('cypress-grep/src/plugin')(newConfig);
return newConfig;
};
Since your getConfigurationByFile()
function returns a JSON Object like the original config
, and the cypress-grep
plugin takes in a JSON Object, you can probably just add the resolved JSON from getConfigurationByFile
instead of the standard one provided by config
.