Skip to content

Commit

Permalink
Wrap CSV input for --spec around with {} (#120)
Browse files Browse the repository at this point in the history
* wrap csv around {}

* fix a typo

* undefined for null
  • Loading branch information
SagarGaniga committed Mar 12, 2021
1 parent dccfce9 commit 69da94e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bin/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down
15 changes: 15 additions & 0 deletions test/unit/bin/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 undefined when --spec is undefined', () => {
expect(utils.sanitizeSpecsPattern(undefined)).to.eq(undefined);
});
});

describe('getBrowserCombinations', () => {

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

0 comments on commit 69da94e

Please sign in to comment.