You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using cypress-cucumber-preprocessor with esbuild.
I have many test environments and I want to add dynamically proper parameters from my config files loading from scripts.
JSON config files with unique parameters are located in the cypress/config directory: test.json, test2.json, dev.json, local.json etc.
I don't want to duplicate parameters and create each cypress.config.ts file and run it by pointing to --config-file cypress/config/local.cypress.config.ts.
Is there any way to overwrite the config from setupNodeEvents ?
The example below doesn't work.
async function setupNodeEvents(
on: Cypress.PluginEvents,
config: Cypress.PluginConfigOptions
): Promise<Cypress.PluginConfigOptions> {
// This is required for the preprocessor to be able to generate JSON reports after each run, and more,
await preprocessor.addCucumberPreprocessorPlugin(on, config);
on(
'file:preprocessor',
createBundler({
plugins: [createEsbuildPlugin(config)],
})
);
on('before:browser:launch', (browser, launchOptions) => {
if (browser.family === 'chromium' && browser.name !== 'electron') {
launchOptions.args.push('--disable-dev-shm-usage');
launchOptions.args.push('--js-flags=--expose-gc');
}
if (browser.family === 'chromium' && browser.name !== 'electron' && browser.isHeaded) {
launchOptions.args.push('--disable-dev-shm-usage');
launchOptions.args.push('--js-flags=--expose-gc');
// `args` is an array of all the arguments that will be passed to browsers when it launches
console.log(launchOptions.args); // print all current browser args
// auto open devtools on the dashboard mode
launchOptions.args.push('--auto-open-devtools-for-tabs');
//launchOptions.args.push('--start-fullscreen')
}
if (browser.family === 'firefox' && browser.isHeaded) {
// auto open devtools
launchOptions.args.push('-devtools');
}
return launchOptions;
});
function getConfigurationByFile(file) {
// accept a configFile value or use dev by default
const pathToConfigFile = path.resolve('cypress/config/', `${file}.json`)
return fs.readJson(pathToConfigFile)
}
const file = config.env.configFile || 'dev';
// Make sure to return the config object as it might have been modified by the plugin.
return config && getConfigurationByFile(file);
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm using cypress-cucumber-preprocessor with esbuild.
I have many test environments and I want to add dynamically proper parameters from my config files loading from scripts.
JSON config files with unique parameters are located in the cypress/config directory: test.json, test2.json, dev.json, local.json etc.
I don't want to duplicate parameters and create each cypress.config.ts file and run it by pointing to --config-file cypress/config/local.cypress.config.ts.
Is there any way to overwrite the config from setupNodeEvents ?
The example below doesn't work.
Beta Was this translation helpful? Give feedback.
All reactions