diff --git a/bin/helpers/utils.js b/bin/helpers/utils.js index 3e7d7c9e..db6937ee 100644 --- a/bin/helpers/utils.js +++ b/bin/helpers/utils.js @@ -1297,7 +1297,7 @@ exports.setVideoCliConfig = (bsConfig, videoConfig) => { let cypress_major_version = (user_cypress_version && user_cypress_version.match(/^(\d+)/)) ? user_cypress_version.split(".")[0] : undefined; let config_args = (bsConfig && bsConfig.run_settings && bsConfig.run_settings.config) ? bsConfig.run_settings.config : undefined; if(this.isUndefined(user_cypress_version) || this.isUndefined(cypress_major_version) || parseInt(cypress_major_version) >= 13 ) { - logger.info('Setting default video for cypress 13 and above'); + logger.debug('Setting default video for cypress 13 and above'); let video_args = `video=${videoConfig.video},videoUploadOnPasses=${videoConfig.videoUploadOnPasses}`; config_args = this.isUndefined(config_args) ? video_args : config_args + ',' + video_args; logger.debug(`Setting video true in cli for cypress version ${user_cypress_version} with cli args - ${config_args}`) @@ -1321,9 +1321,14 @@ exports.setEnforceSettingsConfig = (bsConfig) => { logger.debug(`Setting base_url_args for enforce_settings to ${base_url_args}`); } // set specs in config of specpattern to override cypress config - if( this.isNotUndefined(bsConfig.run_settings.specs) && bsConfig.run_settings.cypressTestSuiteType === Constants.CYPRESS_V10_AND_ABOVE_TYPE ) { + if( this.isNotUndefined(bsConfig.run_settings.specs) && bsConfig.run_settings.cypressTestSuiteType === Constants.CYPRESS_V10_AND_ABOVE_TYPE && (this.isUndefined(config_args) || !config_args.includes("specPattern")) ) { // doing this only for cypress 10 and above as --spec is given precedence for cypress 9. - let spec_pattern_args = 'specPattern="'+bsConfig.run_settings.specs+'"'; + let specConfigs = bsConfig.run_settings.specs; + // if multiple specs are passed, convert it into an array. + if(specConfigs && specConfigs.includes(',')) { + specConfigs = JSON.stringify(bsConfig.run_settings.specs.split(',')); + } + let spec_pattern_args = 'specPattern="'+specConfigs+'"'; config_args = this.isUndefined(config_args) ? spec_pattern_args : config_args + ',' + spec_pattern_args; } if ( this.isNotUndefined(config_args) ) bsConfig["run_settings"]["config"] = config_args; diff --git a/test/unit/bin/helpers/utils.js b/test/unit/bin/helpers/utils.js index 42feb144..559d91e3 100644 --- a/test/unit/bin/helpers/utils.js +++ b/test/unit/bin/helpers/utils.js @@ -3101,7 +3101,7 @@ describe('utils', () => { utils.setEnforceSettingsConfig(bsConfig); expect(args.config).to.be.eql(bsConfig.run_settings.config); }); - it('the specPattern config should be assigned to bsconfig run_settings config', () => { + it('the specPattern config should be assigned as strings for single string to bsconfig run_settings config', () => { let bsConfig = { run_settings: { specs: 'somerandomspecs', cypressTestSuiteType: 'CYPRESS_V10_AND_ABOVE_TYPE' }, }; @@ -3111,6 +3111,16 @@ describe('utils', () => { utils.setEnforceSettingsConfig(bsConfig); expect(args.config).to.be.eql(bsConfig.run_settings.config); }); + it('the specPattern config should be assigned as array for multiple spec strings to bsconfig run_settings config', () => { + let bsConfig = { + run_settings: { specs: 'somerandomspecs1,somerandomspecs2', cypressTestSuiteType: 'CYPRESS_V10_AND_ABOVE_TYPE' }, + }; + let args = { + config: 'video=false,videoUploadOnPasses=false,specPattern="["somerandomspecs1","somerandomspecs2"]"' + } + utils.setEnforceSettingsConfig(bsConfig); + expect(args.config).to.be.eql(bsConfig.run_settings.config); + }); it('the testFiles config should be assigned to bsconfig run_settings config', () => { let bsConfig = { run_settings: { specs: 'somerandomspecs', cypressTestSuiteType: 'CYPRESS_V9_AND_OLDER_TYPE' },