Skip to content

Commit 4e36fdb

Browse files
Fix for specs passed as array in enforce_settings
1 parent c4b5ab7 commit 4e36fdb

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

bin/helpers/utils.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ exports.setVideoCliConfig = (bsConfig, videoConfig) => {
12971297
let cypress_major_version = (user_cypress_version && user_cypress_version.match(/^(\d+)/)) ? user_cypress_version.split(".")[0] : undefined;
12981298
let config_args = (bsConfig && bsConfig.run_settings && bsConfig.run_settings.config) ? bsConfig.run_settings.config : undefined;
12991299
if(this.isUndefined(user_cypress_version) || this.isUndefined(cypress_major_version) || parseInt(cypress_major_version) >= 13 ) {
1300-
logger.info('Setting default video for cypress 13 and above');
1300+
logger.debug('Setting default video for cypress 13 and above');
13011301
let video_args = `video=${videoConfig.video},videoUploadOnPasses=${videoConfig.videoUploadOnPasses}`;
13021302
config_args = this.isUndefined(config_args) ? video_args : config_args + ',' + video_args;
13031303
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) => {
13211321
logger.debug(`Setting base_url_args for enforce_settings to ${base_url_args}`);
13221322
}
13231323
// set specs in config of specpattern to override cypress config
1324-
if( this.isNotUndefined(bsConfig.run_settings.specs) && bsConfig.run_settings.cypressTestSuiteType === Constants.CYPRESS_V10_AND_ABOVE_TYPE ) {
1324+
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")) ) {
13251325
// doing this only for cypress 10 and above as --spec is given precedence for cypress 9.
1326-
let spec_pattern_args = 'specPattern="'+bsConfig.run_settings.specs+'"';
1326+
let specConfigs = bsConfig.run_settings.specs;
1327+
// if multiple specs are passed, convert it into an array.
1328+
if(specConfigs && specConfigs.includes(',')) {
1329+
specConfigs = JSON.stringify(bsConfig.run_settings.specs.split(','));
1330+
}
1331+
let spec_pattern_args = 'specPattern="'+specConfigs+'"';
13271332
config_args = this.isUndefined(config_args) ? spec_pattern_args : config_args + ',' + spec_pattern_args;
13281333
}
13291334
if ( this.isNotUndefined(config_args) ) bsConfig["run_settings"]["config"] = config_args;

test/unit/bin/helpers/utils.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3101,7 +3101,7 @@ describe('utils', () => {
31013101
utils.setEnforceSettingsConfig(bsConfig);
31023102
expect(args.config).to.be.eql(bsConfig.run_settings.config);
31033103
});
3104-
it('the specPattern config should be assigned to bsconfig run_settings config', () => {
3104+
it('the specPattern config should be assigned as strings for single string to bsconfig run_settings config', () => {
31053105
let bsConfig = {
31063106
run_settings: { specs: 'somerandomspecs', cypressTestSuiteType: 'CYPRESS_V10_AND_ABOVE_TYPE' },
31073107
};
@@ -3111,6 +3111,16 @@ describe('utils', () => {
31113111
utils.setEnforceSettingsConfig(bsConfig);
31123112
expect(args.config).to.be.eql(bsConfig.run_settings.config);
31133113
});
3114+
it('the specPattern config should be assigned as array for multiple spec strings to bsconfig run_settings config', () => {
3115+
let bsConfig = {
3116+
run_settings: { specs: 'somerandomspecs1,somerandomspecs2', cypressTestSuiteType: 'CYPRESS_V10_AND_ABOVE_TYPE' },
3117+
};
3118+
let args = {
3119+
config: 'video=false,videoUploadOnPasses=false,specPattern="["somerandomspecs1","somerandomspecs2"]"'
3120+
}
3121+
utils.setEnforceSettingsConfig(bsConfig);
3122+
expect(args.config).to.be.eql(bsConfig.run_settings.config);
3123+
});
31143124
it('the testFiles config should be assigned to bsconfig run_settings config', () => {
31153125
let bsConfig = {
31163126
run_settings: { specs: 'somerandomspecs', cypressTestSuiteType: 'CYPRESS_V9_AND_OLDER_TYPE' },

0 commit comments

Comments
 (0)