Skip to content

Commit 69da94e

Browse files
authored
Wrap CSV input for --spec around with {} (#120)
* wrap csv around {} * fix a typo * undefined for null
1 parent dccfce9 commit 69da94e

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

bin/helpers/utils.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,16 @@ exports.setHeaded = (bsConfig, args) => {
341341

342342
exports.getNumberOfSpecFiles = (bsConfig, args, cypressJson) => {
343343
let testFolderPath = cypressJson.integrationFolder || Constants.DEFAULT_CYPRESS_SPEC_PATH;
344-
let globSearchPatttern = bsConfig.run_settings.specs || `${testFolderPath}/**/*.+(${Constants.specFileTypes.join("|")})`;
344+
let globSearchPattern = this.sanitizeSpecsPattern(bsConfig.run_settings.specs) || `${testFolderPath}/**/*.+(${Constants.specFileTypes.join("|")})`;
345345
let ignoreFiles = args.exclude || bsConfig.run_settings.exclude;
346-
let files = glob.sync(globSearchPatttern, {cwd: bsConfig.run_settings.cypressProjectDir, matchBase: true, ignore: ignoreFiles});
346+
let files = glob.sync(globSearchPattern, {cwd: bsConfig.run_settings.cypressProjectDir, matchBase: true, ignore: ignoreFiles});
347347
return files;
348348
};
349349

350+
exports.sanitizeSpecsPattern = (pattern) => {
351+
return pattern && pattern.split(",").length > 1 ? "{" + pattern + "}" : pattern;
352+
}
353+
350354
exports.getBrowserCombinations = (bsConfig) => {
351355
let osBrowserArray = [];
352356
let osBrowser = "";

test/unit/bin/helpers/utils.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,21 @@ describe('utils', () => {
10891089

10901090
});
10911091

1092+
describe('sanitizeSpecsPattern', () => {
1093+
1094+
it('should wrap pattern around {} when input is csv', () => {
1095+
expect(utils.sanitizeSpecsPattern("pattern1,pattern2")).to.eq("{pattern1,pattern2}");
1096+
});
1097+
1098+
it('should not wrap pattern around {} when input is single glob pattern', () => {
1099+
expect(utils.sanitizeSpecsPattern("pattern3")).to.eq("pattern3");
1100+
});
1101+
1102+
it('should return undefined when --spec is undefined', () => {
1103+
expect(utils.sanitizeSpecsPattern(undefined)).to.eq(undefined);
1104+
});
1105+
});
1106+
10921107
describe('getBrowserCombinations', () => {
10931108

10941109
it('returns correct number of browserCombinations for one combination', () => {

0 commit comments

Comments
 (0)