From b7efabbe35f3b512280c42108c4f0fcfa6312920 Mon Sep 17 00:00:00 2001 From: Sagar Ganiga Date: Fri, 5 Mar 2021 13:36:28 +0530 Subject: [PATCH 1/3] wrap csv around {} --- bin/helpers/utils.js | 8 ++++++-- test/unit/bin/helpers/utils.js | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/bin/helpers/utils.js b/bin/helpers/utils.js index 1925853a..9c979796 100644 --- a/bin/helpers/utils.js +++ b/bin/helpers/utils.js @@ -341,12 +341,16 @@ exports.setHeaded = (bsConfig, args) => { exports.getNumberOfSpecFiles = (bsConfig, args, cypressJson) => { let testFolderPath = cypressJson.integrationFolder || Constants.DEFAULT_CYPRESS_SPEC_PATH; - let globSearchPatttern = bsConfig.run_settings.specs || `${testFolderPath}/**/*.+(${Constants.specFileTypes.join("|")})`; + let globSearchPattern = this.sanitizeSpecsPattern(bsConfig.run_settings.specs) || `${testFolderPath}/**/*.+(${Constants.specFileTypes.join("|")})`; let ignoreFiles = args.exclude || bsConfig.run_settings.exclude; - let files = glob.sync(globSearchPatttern, {cwd: bsConfig.run_settings.cypressProjectDir, matchBase: true, ignore: ignoreFiles}); + let files = glob.sync(globSearchPattern, {cwd: bsConfig.run_settings.cypressProjectDir, matchBase: true, ignore: ignoreFiles}); return files; }; +exports.sanitizeSpecsPattern = (pattern) => { + return pattern && pattern.split(",").length > 1 ? "{" + pattern + "}" : pattern; +} + exports.getBrowserCombinations = (bsConfig) => { let osBrowserArray = []; let osBrowser = ""; diff --git a/test/unit/bin/helpers/utils.js b/test/unit/bin/helpers/utils.js index 2dde99bf..27c7bfdc 100644 --- a/test/unit/bin/helpers/utils.js +++ b/test/unit/bin/helpers/utils.js @@ -1089,6 +1089,21 @@ describe('utils', () => { }); + describe('sanitizeSpecsPattern', () => { + + it('should wrap pattern around {} when input is csv', () => { + expect(utils.sanitizeSpecsPattern("pattern1,pattern2")).to.eq("{pattern1,pattern2}"); + }); + + it('should not wrap pattern around {} when input is single glob pattern', () => { + expect(utils.sanitizeSpecsPattern("pattern3")).to.eq("pattern3"); + }); + + it('should return null when --spec is undeffined', () => { + expect(utils.sanitizeSpecsPattern(undefined)).to.eq(undefined); + }); + }); + describe('getBrowserCombinations', () => { it('returns correct number of browserCombinations for one combination', () => { From c102d7ee8d7ed3d7c827e287bbc40517cdd758e9 Mon Sep 17 00:00:00 2001 From: Sagar Ganiga Date: Fri, 5 Mar 2021 15:12:59 +0530 Subject: [PATCH 2/3] fix a typo --- test/unit/bin/helpers/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/bin/helpers/utils.js b/test/unit/bin/helpers/utils.js index 27c7bfdc..cc202c14 100644 --- a/test/unit/bin/helpers/utils.js +++ b/test/unit/bin/helpers/utils.js @@ -1099,7 +1099,7 @@ describe('utils', () => { expect(utils.sanitizeSpecsPattern("pattern3")).to.eq("pattern3"); }); - it('should return null when --spec is undeffined', () => { + it('should return null when --spec is undefined', () => { expect(utils.sanitizeSpecsPattern(undefined)).to.eq(undefined); }); }); From c42b77d34bebbadc3a62e80bb4b18a24cd287ccf Mon Sep 17 00:00:00 2001 From: Sagar Ganiga Date: Fri, 5 Mar 2021 15:29:54 +0530 Subject: [PATCH 3/3] undefined for null --- test/unit/bin/helpers/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/bin/helpers/utils.js b/test/unit/bin/helpers/utils.js index cc202c14..f5e943cf 100644 --- a/test/unit/bin/helpers/utils.js +++ b/test/unit/bin/helpers/utils.js @@ -1099,7 +1099,7 @@ describe('utils', () => { expect(utils.sanitizeSpecsPattern("pattern3")).to.eq("pattern3"); }); - it('should return null when --spec is undefined', () => { + it('should return undefined when --spec is undefined', () => { expect(utils.sanitizeSpecsPattern(undefined)).to.eq(undefined); }); });