Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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