Skip to content

Commit 9c3ec18

Browse files
committed
use new specPattern logic only when curly braces are passed
1 parent 812ad50 commit 9c3ec18

File tree

1 file changed

+28
-19
lines changed

1 file changed

+28
-19
lines changed

bin/helpers/utils.js

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,27 +1337,36 @@ exports.setEnforceSettingsConfig = (bsConfig, args) => {
13371337
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")) ) {
13381338
// doing this only for cypress 10 and above as --spec is given precedence for cypress 9.
13391339
let specConfigs = bsConfig.run_settings.specs;
1340-
// if multiple specs are passed, convert it into an array.
1341-
if (specConfigs && !Array.isArray(specConfigs)) {
1342-
if (specConfigs.includes(',')) {
1343-
specConfigs = this.splitStringByCharButIgnoreIfWithinARange(specConfigs, ',', '{', '}');
1344-
} else {
1345-
specConfigs = [specConfigs];
1340+
let spec_pattern_args = "";
1341+
1342+
if (specConfigs && specConfigs.includes('{') && specConfigs.includes('}')) {
1343+
if (specConfigs && !Array.isArray(specConfigs)) {
1344+
if (specConfigs.includes(',')) {
1345+
specConfigs = this.splitStringByCharButIgnoreIfWithinARange(specConfigs, ',', '{', '}');
1346+
} else {
1347+
specConfigs = [specConfigs];
1348+
}
13461349
}
1350+
let ignoreFiles = args.exclude || bsConfig.run_settings.exclude
1351+
let specFilesMatched = [];
1352+
specConfigs.forEach(specPattern => {
1353+
specFilesMatched.push(
1354+
...glob.sync(specPattern, {
1355+
cwd: bsConfig.run_settings.cypressProjectDir, matchBase: true, ignore: ignoreFiles
1356+
})
1357+
);
1358+
});
1359+
logger.debug(`${specFilesMatched && specFilesMatched.length > 0 ? specFilesMatched.length : 0} spec files found with the provided specPattern for enforce_settings`);
1360+
// If spec files were found then lets we'll load the matched spec files
1361+
// If spec files were not found then we'll let cypress decide the loading of spec files
1362+
spec_pattern_args = `specPattern=${JSON.stringify(specFilesMatched && specFilesMatched.length > 0 ? specFilesMatched : specConfigs)}`;
1363+
} else {
1364+
// if multiple specs are passed, convert it into an array.
1365+
if(specConfigs && specConfigs.includes(',')) {
1366+
specConfigs = JSON.stringify(specConfigs.split(','));
1367+
}
1368+
spec_pattern_args = `specPattern=${specConfigs}`;
13471369
}
1348-
let ignoreFiles = args.exclude || bsConfig.run_settings.exclude
1349-
let specFilesMatched = [];
1350-
specConfigs.forEach(specPattern => {
1351-
specFilesMatched.push(
1352-
...glob.sync(specPattern, {
1353-
cwd: bsConfig.run_settings.cypressProjectDir, matchBase: true, ignore: ignoreFiles
1354-
})
1355-
);
1356-
});
1357-
logger.debug(`${specFilesMatched && specFilesMatched.length > 0 ? specFilesMatched.length : 0} spec files found with the provided specPattern for enforce_settings`);
1358-
// If spec files were found then lets we'll load the matched spec files
1359-
// If spec files were not found then we'll let cypress decide the loading of spec files
1360-
let spec_pattern_args = `specPattern=${JSON.stringify(specFilesMatched && specFilesMatched.length > 0 ? specFilesMatched : specConfigs)}`;
13611370
config_args = this.isUndefined(config_args) ? spec_pattern_args : config_args + ',' + spec_pattern_args;
13621371
}
13631372
if ( this.isNotUndefined(config_args) ) bsConfig["run_settings"]["config"] = config_args;

0 commit comments

Comments
 (0)