diff --git a/bin/commands/runs.js b/bin/commands/runs.js index b80d50ec..20d68728 100644 --- a/bin/commands/runs.js +++ b/bin/commands/runs.js @@ -15,10 +15,13 @@ module.exports = function run(args) { return utils.validateBstackJson(bsConfigPath).then(function (bsConfig) { utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting); - // Validate browserstack.json values - return capabilityHelper.validate(bsConfig).then(function (validated) { + // Validate browserstack.json values and parallels specified via arguments + return capabilityHelper.validate(bsConfig, args).then(function (validated) { logger.info(validated); + // accept the number of parallels + utils.setParallels(bsConfig, args); + // Archive the spec files return archiver.archive(bsConfig.run_settings, config.fileName).then(function (data) { @@ -57,7 +60,12 @@ module.exports = function run(args) { }).catch(function (err) { // browerstack.json is not valid logger.error(err); - logger.error(Constants.validationMessages.NOT_VALID); + + // display browserstack.json is not valid only if validation of browserstack.json field has failed, otherwise display just the error message + // If parallels specified in arguments are invalid do not display browserstack.json is invalid message + if (!(err === Constants.validationMessages.INVALID_PARALLELS_CONFIGURATION && !utils.isUndefined(args.parallels))) { + logger.error(Constants.validationMessages.NOT_VALID); + } let error_code = utils.getErrorCodeFromMsg(err); utils.sendUsageReport(bsConfig, args, `${err}\n${Constants.validationMessages.NOT_VALID}`, Constants.messageTypes.ERROR, error_code); diff --git a/bin/helpers/capabilityHelper.js b/bin/helpers/capabilityHelper.js index d308bd19..ac87419f 100644 --- a/bin/helpers/capabilityHelper.js +++ b/bin/helpers/capabilityHelper.js @@ -1,5 +1,6 @@ const logger = require("./logger").winstonLogger, Constants = require("./constants"), + Utils = require("./utils"), fs = require('fs'), path = require('path'); @@ -66,6 +67,7 @@ const caps = (bsConfig, zip) => { obj.customBuildName = bsConfig.run_settings.customBuildName || bsConfig.run_settings.build_name; obj.callbackURL = bsConfig.run_settings.callback_url; obj.projectNotifyURL = bsConfig.run_settings.project_notify_URL; + obj.parallels = bsConfig.run_settings.parallels; } if (obj.project) logger.log(`Project name is: ${obj.project}`); @@ -76,12 +78,14 @@ const caps = (bsConfig, zip) => { if (obj.projectNotifyURL) logger.info(`Project notify URL is: ${obj.projectNotifyURL}`); + if (obj.parallels) logger.info(`Parallels limit specified: ${obj.parallels}`); + var data = JSON.stringify(obj); resolve(data); }) } -const validate = (bsConfig) => { +const validate = (bsConfig, args) => { return new Promise(function(resolve, reject){ if (!bsConfig) reject(Constants.validationMessages.EMPTY_BROWSERSTACK_JSON); @@ -91,7 +95,13 @@ const validate = (bsConfig) => { if (!bsConfig.run_settings) reject(Constants.validationMessages.EMPTY_RUN_SETTINGS); - if(!bsConfig.run_settings.cypress_proj_dir) reject(Constants.validationMessages.EMPTY_SPEC_FILES); + if (!bsConfig.run_settings.cypress_proj_dir) reject(Constants.validationMessages.EMPTY_SPEC_FILES); + + // validate parallels specified in browserstack.json if parallels are not specified via arguments + if (!Utils.isUndefined(args) && Utils.isUndefined(args.parallels) && !Utils.isParallelValid(bsConfig.run_settings.parallels)) reject(Constants.validationMessages.INVALID_PARALLELS_CONFIGURATION); + + // if parallels specified via arguments validate only arguments + if (!Utils.isUndefined(args) && !Utils.isUndefined(args.parallels) && !Utils.isParallelValid(args.parallels)) reject(Constants.validationMessages.INVALID_PARALLELS_CONFIGURATION); if (!fs.existsSync(path.join(bsConfig.run_settings.cypress_proj_dir, 'cypress.json'))) reject(Constants.validationMessages.CYPRESS_JSON_NOT_FOUND + bsConfig.run_settings.cypress_proj_dir); diff --git a/bin/helpers/constants.js b/bin/helpers/constants.js index f99d678c..15a2a853 100644 --- a/bin/helpers/constants.js +++ b/bin/helpers/constants.js @@ -24,6 +24,7 @@ const validationMessages = { NOT_VALID: "browerstack.json is not valid", NOT_VALID_JSON: "browerstack.json is not a valid json", INVALID_EXTENSION: "Invalid files, please remove these files and try again.", + INVALID_PARALLELS_CONFIGURATION: "Invalid value specified for parallels to use. Maximum parallels to use should be a number greater than 0.", CYPRESS_JSON_NOT_FOUND: "cypress.json file is not found at cypress_proj_dir path ", INVALID_CYPRESS_JSON: "cypress.json is not a valid json" }; @@ -48,6 +49,7 @@ const cliMessages = { STOP_MESSAGE: "Stopping build with given buildId " }, RUN: { + PARALLEL_DESC: "The maximum number of parallels to use to run your test suite", INFO: "Run your tests on BrowserStack.", DESC: "Path to BrowserStack config", CONFIG_DEMAND: "config file is required" diff --git a/bin/helpers/utils.js b/bin/helpers/utils.js index 8128f9f2..ca12e121 100644 --- a/bin/helpers/utils.js +++ b/bin/helpers/utils.js @@ -70,6 +70,20 @@ exports.setUsageReportingFlag = (bsConfig, disableUsageReporting) => { } } +exports.setParallels = (bsConfig, args) => { + if (!this.isUndefined(args.parallels)) { + bsConfig['run_settings']['parallels'] = args.parallels; + } +} + +exports.isUndefined = value => (value === undefined || value === null); + +exports.isFloat = value => (Number(value) && Number(value) % 1 !== 0); + +exports.isParallelValid = (value) => { + return this.isUndefined(value) || !(isNaN(value) || this.isFloat(value) || parseInt(value, 10) === 0 || parseInt(value, 10) < -1); +} + exports.getUserAgent = () => { return `BStack-Cypress-CLI/1.x (${os.arch()}/${os.platform()}/${os.release()})`; } diff --git a/bin/runner.js b/bin/runner.js index 2b65587b..553b69c0 100755 --- a/bin/runner.js +++ b/bin/runner.js @@ -101,7 +101,7 @@ var argv = yargs }) .command('run', Constants.cliMessages.RUN.INFO, function(yargs) { argv = yargs - .usage('usage: $0 build') + .usage('usage: $0 run ') .options({ 'cf': { alias: 'config-file', @@ -117,6 +117,12 @@ var argv = yargs description: Constants.cliMessages.COMMON.DISABLE_USAGE_REPORTING, type: "boolean" }, + 'p': { + alias: 'parallels', + describe: Constants.cliMessages.RUN.PARALLEL_DESC, + type: "number", + default: undefined + } }) .help('help') .wrap(null) diff --git a/bin/templates/configTemplate.js b/bin/templates/configTemplate.js index 70acb184..8aa31037 100644 --- a/bin/templates/configTemplate.js +++ b/bin/templates/configTemplate.js @@ -15,6 +15,7 @@ module.exports = function () { "cypress_proj_dir" : "/path/to/cypress.json", "project_name": "project-name", "build_name": "build-name", + "parallels": "Here goes the number of parallels you want to run", "npm_dependencies": { } }, diff --git a/test/unit/bin/commands/runs.js b/test/unit/bin/commands/runs.js index 68111bd6..b762c184 100644 --- a/test/unit/bin/commands/runs.js +++ b/test/unit/bin/commands/runs.js @@ -134,6 +134,7 @@ describe("runs", () => { beforeEach(() => { sandbox = sinon.createSandbox(); + setParallelsStub = sandbox.stub(); validateBstackJsonStub = sandbox.stub(); setUsageReportingFlagStub = sandbox.stub().returns(undefined); sendUsageReportStub = sandbox.stub().callsFake(function () { @@ -158,6 +159,7 @@ describe("runs", () => { "../helpers/utils": { validateBstackJson: validateBstackJsonStub, sendUsageReport: sendUsageReportStub, + setParallels: setParallelsStub, setUsageReportingFlag: setUsageReportingFlagStub, }, "../helpers/capabilityHelper": { @@ -180,6 +182,7 @@ describe("runs", () => { chai.assert.fail("Promise error"); }) .catch((error) => { + sinon.assert.calledOnce(setParallelsStub) sinon.assert.calledOnce(validateBstackJsonStub); sinon.assert.calledOnce(capabilityValidatorStub); sinon.assert.calledOnce(archiverStub); @@ -203,6 +206,7 @@ describe("runs", () => { beforeEach(() => { sandbox = sinon.createSandbox(); validateBstackJsonStub = sandbox.stub(); + setParallelsStub = sandbox.stub(); setUsageReportingFlagStub = sandbox.stub().returns(undefined); sendUsageReportStub = sandbox.stub().callsFake(function () { return "end"; @@ -227,6 +231,7 @@ describe("runs", () => { "../helpers/utils": { validateBstackJson: validateBstackJsonStub, sendUsageReport: sendUsageReportStub, + setParallels: setParallelsStub, setUsageReportingFlag: setUsageReportingFlagStub, }, "../helpers/capabilityHelper": { @@ -253,6 +258,7 @@ describe("runs", () => { chai.assert.fail("Promise error"); }) .catch((error) => { + sinon.assert.calledOnce(setParallelsStub); sinon.assert.calledOnce(validateBstackJsonStub); sinon.assert.calledOnce(capabilityValidatorStub); sinon.assert.calledOnce(archiverStub); @@ -280,6 +286,7 @@ describe("runs", () => { beforeEach(() => { sandbox = sinon.createSandbox(); validateBstackJsonStub = sandbox.stub(); + setParallelsStub = sandbox.stub(); setUsageReportingFlagStub = sandbox.stub().returns(undefined); sendUsageReportStub = sandbox.stub().callsFake(function () { return "end"; @@ -305,6 +312,7 @@ describe("runs", () => { "../helpers/utils": { validateBstackJson: validateBstackJsonStub, sendUsageReport: sendUsageReportStub, + setParallels: setParallelsStub, setUsageReportingFlag: setUsageReportingFlagStub, }, "../helpers/capabilityHelper": { @@ -339,6 +347,7 @@ describe("runs", () => { .catch((error) => { sinon.assert.calledOnce(validateBstackJsonStub); sinon.assert.calledOnce(capabilityValidatorStub); + sinon.assert.calledOnce(setParallelsStub); sinon.assert.calledOnce(archiverStub); sinon.assert.calledOnce(setUsageReportingFlagStub); sinon.assert.calledOnce(zipUploadStub); @@ -368,6 +377,7 @@ describe("runs", () => { beforeEach(() => { sandbox = sinon.createSandbox(); validateBstackJsonStub = sandbox.stub(); + setParallelsStub = sandbox.stub(); setUsageReportingFlagStub = sandbox.stub().returns(undefined); sendUsageReportStub = sandbox.stub().callsFake(function () { return "end"; @@ -394,6 +404,7 @@ describe("runs", () => { validateBstackJson: validateBstackJsonStub, sendUsageReport: sendUsageReportStub, setUsageReportingFlag: setUsageReportingFlagStub, + setParallels: setParallelsStub, }, "../helpers/capabilityHelper": { validate: capabilityValidatorStub, @@ -427,6 +438,7 @@ describe("runs", () => { .catch((error) => { sinon.assert.calledOnce(validateBstackJsonStub); sinon.assert.calledOnce(capabilityValidatorStub); + sinon.assert.calledOnce(setParallelsStub); sinon.assert.calledOnce(archiverStub); sinon.assert.calledOnce(setUsageReportingFlagStub); sinon.assert.calledOnce(zipUploadStub); diff --git a/test/unit/bin/helpers/capabilityHelper.js b/test/unit/bin/helpers/capabilityHelper.js index 293ab235..aa25029d 100644 --- a/test/unit/bin/helpers/capabilityHelper.js +++ b/test/unit/bin/helpers/capabilityHelper.js @@ -1,5 +1,7 @@ const chai = require("chai"), - chaiAsPromised = require("chai-as-promised"); + chaiAsPromised = require("chai-as-promised"), + fs = require('fs'), + sinon = require('sinon'); const capabilityHelper = require("../../../../bin/helpers/capabilityHelper"), Constants = require("../../../../bin/helpers/constants"), @@ -250,10 +252,259 @@ describe("capabilityHelper.js", () => { }); describe("validate", () => { + + describe("validate parallels specified in bsconfig and arguments", () => { + beforeEach(() => { + //Stub for cypress json validation + sinon.stub(fs, 'existsSync').returns(true); + sinon.stub(fs, 'readFileSync').returns("{}"); + + bsConfig = { + auth: {}, + browsers: [ + { + browser: "chrome", + os: "Windows 10", + versions: ["78", "77"], + }, + ], + run_settings: { + cypress_proj_dir: "random path" + }, + }; + }); + + afterEach(() => { + fs.existsSync.restore(); + fs.readFileSync.restore(); + }); + + it("validate parallels present in arguments (not a number) when specified (valid) in bsconfig run_settings", () => { + bsConfig.run_settings.parallels = 10; + return capabilityHelper + .validate(bsConfig, { parallels: 'cypress' }) + .then(function (data) { + chai.assert.fail("Promise error"); + }) + .catch((error) => { + chai.assert.equal(error, Constants.validationMessages.INVALID_PARALLELS_CONFIGURATION); + }); + }); + + it("validate parallels present in arguments (float) when specified (valid) in bsconfig run_settings", () => { + bsConfig.run_settings.parallels = 10; + return capabilityHelper + .validate(bsConfig, { parallels: '1.234' }) + .then(function (data) { + chai.assert.fail("Promise error"); + }) + .catch((error) => { + chai.assert.equal(error, Constants.validationMessages.INVALID_PARALLELS_CONFIGURATION); + }); + }); + + it("validate parallels present in arguments (negative value < -1) when specified (valid) in bsconfig run_settings", () => { + bsConfig.run_settings.parallels = 10; + return capabilityHelper + .validate(bsConfig, { parallels: -200 }) + .then(function (data) { + chai.assert.fail("Promise error"); + }) + .catch((error) => { + chai.assert.equal(error, Constants.validationMessages.INVALID_PARALLELS_CONFIGURATION); + }); + }); + + it("validate parallels present in arguments (zero) when specified (valid) in bsconfig run_settings", () => { + bsConfig.run_settings.parallels = 10; + return capabilityHelper + .validate(bsConfig, { parallels: 0 }) + .then(function (data) { + chai.assert.fail("Promise error"); + }) + .catch((error) => { + chai.assert.equal(error, Constants.validationMessages.INVALID_PARALLELS_CONFIGURATION); + }); + }); + + it("validate parallels present in arguments (not a number) when not specified in bsconfig run_settings", () => { + return capabilityHelper + .validate(bsConfig, { parallels: 'cypress' }) + .then(function (data) { + chai.assert.fail("Promise error"); + }) + .catch((error) => { + chai.assert.equal(error, Constants.validationMessages.INVALID_PARALLELS_CONFIGURATION); + }); + }); + + it("validate parallels present in arguments (float) when not specified in bsconfig run_settings", () => { + return capabilityHelper + .validate(bsConfig, { parallels: '1.234' }) + .then(function (data) { + chai.assert.fail("Promise error"); + }) + .catch((error) => { + chai.assert.equal(error, Constants.validationMessages.INVALID_PARALLELS_CONFIGURATION); + }); + }); + + it("validate parallels present in arguments (negative value < -1) when not specified in bsconfig run_settings", () => { + return capabilityHelper + .validate(bsConfig, { parallels: -200 }) + .then(function (data) { + chai.assert.fail("Promise error"); + }) + .catch((error) => { + chai.assert.equal(error, Constants.validationMessages.INVALID_PARALLELS_CONFIGURATION); + }); + }); + + it("validate parallels present in arguments (zero) when specified not in bsconfig run_settings", () => { + return capabilityHelper + .validate(bsConfig, { parallels: 0 }) + .then(function (data) { + chai.assert.fail("Promise error"); + }) + .catch((error) => { + chai.assert.equal(error, Constants.validationMessages.INVALID_PARALLELS_CONFIGURATION); + }); + }); + + it("validate parallels present in bsconfig run settings (not a number) when not specified in arguments", () => { + + bsConfig.run_settings.parallels = "cypress"; + + return capabilityHelper + .validate(bsConfig, { parallels: undefined }) + .then(function (data) { + chai.assert.fail("Promise error"); + }) + .catch((error) => { + chai.assert.equal(error, Constants.validationMessages.INVALID_PARALLELS_CONFIGURATION); + }); + }); + + it("validate parallels present in bsconfig run settings (float) when not specified in arguments", () => { + bsConfig.run_settings.parallels = "1.234"; + + return capabilityHelper + .validate(bsConfig, { parallels: undefined }) + .then(function (data) { + chai.assert.fail("Promise error"); + }) + .catch((error) => { + chai.assert.equal(error, Constants.validationMessages.INVALID_PARALLELS_CONFIGURATION); + }); + }); + + it("validate parallels present in bsconfig run settings (negative value < -1) when not specified in arguments", () => { + bsConfig.run_settings.parallels = -200; + + return capabilityHelper + .validate(bsConfig, { parallels: undefined }) + .then(function (data) { + chai.assert.fail("Promise error"); + }) + .catch((error) => { + chai.assert.equal(error, Constants.validationMessages.INVALID_PARALLELS_CONFIGURATION); + }); + }); + + it("validate parallels present in bsconfig run settings (zero value) when not specified in arguments", () => { + bsConfig.run_settings.parallels = -200; + + return capabilityHelper + .validate(bsConfig, { parallels: undefined }) + .then(function (data) { + chai.assert.fail("Promise error"); + }) + .catch((error) => { + chai.assert.equal(error, Constants.validationMessages.INVALID_PARALLELS_CONFIGURATION); + }); + }); + + it("should return true for valid parallels (positive) present in bsconfig if arguments are undefined", () => { + bsConfig.run_settings.parallels = 10; + + return capabilityHelper + .validate(bsConfig, { parallels: undefined }) + .then(function (data) { + chai.assert.equal(data, Constants.validationMessages.VALIDATED); + }) + .catch((error) => { + chai.assert.fail("Promise error"); + }); + }); + + it("should return true for valid parallels (-1) present in bsconfig if arguments are undefined", () => { + bsConfig.run_settings.parallels = -1; + + return capabilityHelper + .validate(bsConfig, { parallels: undefined }) + .then(function (data) { + chai.assert.equal(data, Constants.validationMessages.VALIDATED); + }) + .catch((error) => { + chai.assert.fail("Promise error"); + }); + }); + + it("should return true for valid parallels (positive) present in arguments if bsconfig parallels are undefined", () => { + + return capabilityHelper + .validate(bsConfig, { parallels: 200 }) + .then(function (data) { + chai.assert.equal(data, Constants.validationMessages.VALIDATED); + }) + .catch((error) => { + chai.assert.fail("Promise error"); + }); + }); + + it("should return true for valid parallels (-1) present in arguments if bsconfig parallels are undefined", () => { + + return capabilityHelper + .validate(bsConfig, { parallels: -1 }) + .then(function (data) { + chai.assert.equal(data, Constants.validationMessages.VALIDATED); + }) + .catch((error) => { + chai.assert.fail("Promise error"); + }); + }); + + it("should return true for valid parallels (-1) present in arguments even if bsconfig parallels are not valid", () => { + bsConfig.run_settings.parallels = "not valid"; + + return capabilityHelper + .validate(bsConfig, { parallels: -1 }) + .then(function (data) { + chai.assert.equal(data, Constants.validationMessages.VALIDATED); + }) + .catch((error) => { + chai.assert.fail("Promise error"); + }); + }); + + it("should return true for valid parallels (-1) present in arguments if bsconfig parallels are also valid", () => { + bsConfig.run_settings.parallels = "10"; + + return capabilityHelper + .validate(bsConfig, { parallels: -1 }) + .then(function (data) { + chai.assert.equal(data, Constants.validationMessages.VALIDATED); + }) + .catch((error) => { + chai.assert.fail("Promise error"); + }); + }); + }); + it("validate bsConfig", () => { let bsConfig = undefined; return capabilityHelper - .validate(bsConfig) + .validate(bsConfig, {parallels: undefined}) .then(function (data) { chai.assert.fail("Promise error"); }) @@ -265,7 +516,7 @@ describe("capabilityHelper.js", () => { it("validate bsConfig.auth", () => { bsConfig = {}; return capabilityHelper - .validate(bsConfig) + .validate(bsConfig, {parallels: undefined}) .then(function (data) { chai.assert.fail("Promise error"); }) @@ -283,7 +534,7 @@ describe("capabilityHelper.js", () => { browsers: [], }; return capabilityHelper - .validate(bsConfig) + .validate(bsConfig, {parallels: undefined}) .then(function (data) { chai.assert.fail("Promise error"); }) @@ -307,7 +558,7 @@ describe("capabilityHelper.js", () => { ], }; return capabilityHelper - .validate(bsConfig) + .validate(bsConfig, {parallels: undefined}) .then(function (data) { chai.assert.fail("Promise error"); }) @@ -333,7 +584,7 @@ describe("capabilityHelper.js", () => { }; return capabilityHelper - .validate(bsConfig) + .validate(bsConfig, {parallels: undefined}) .then(function (data) { chai.assert.fail("Promise error"); }) @@ -360,7 +611,7 @@ describe("capabilityHelper.js", () => { }, }; capabilityHelper - .validate(bsConfig) + .validate(bsConfig, {parallels: undefined}) .then(function (data) { chai.assert.equal(data, Constants.validationMessages.VALIDATED); }) diff --git a/test/unit/bin/helpers/utils.js b/test/unit/bin/helpers/utils.js index 24ca85c8..cc7f2e2c 100644 --- a/test/unit/bin/helpers/utils.js +++ b/test/unit/bin/helpers/utils.js @@ -27,6 +27,91 @@ describe("utils", () => { }); }); + describe("isParallelValid", () => { + it("should return false for a float value", () => { + expect(utils.isParallelValid(1.2)).to.be.equal(false); + expect(utils.isParallelValid("7.3")).to.be.equal(false); + expect(utils.isParallelValid(7.33333)).to.be.equal(false); + expect(utils.isParallelValid("1.2.2.2")).to.be.equal(false); + expect(utils.isParallelValid("1.456789")).to.be.equal(false); + }); + + it("should return false for a string which is not a number", () => { + expect(utils.isParallelValid("cypress")).to.be.equal(false); + expect(utils.isParallelValid("browserstack")).to.be.equal(false); + }); + + it("should return false for any negative value less than -1 or zero", () => { + expect(utils.isParallelValid(-200)).to.be.equal(false); + expect(utils.isParallelValid("-200")).to.be.equal(false); + expect(utils.isParallelValid(-1000)).to.be.equal(false); + expect(utils.isParallelValid("0")).to.be.equal(false); + expect(utils.isParallelValid(0)).to.be.equal(false); + }); + + it("should return true for any positive value or -1", () => { + expect(utils.isParallelValid(5)).to.be.equal(true); + expect(utils.isParallelValid("5")).to.be.equal(true); + expect(utils.isParallelValid(10)).to.be.equal(true); + expect(utils.isParallelValid("-1")).to.be.equal(true); + expect(utils.isParallelValid(-1)).to.be.equal(true); + }); + + it("should return true for undefined", () => { + expect(utils.isParallelValid(undefined)).to.be.equal(true); + }); + }); + + describe("isFloat", () => { + it("should return true for a float value", () => { + expect(utils.isFloat(1.2333)).to.be.equal(true); + expect(utils.isFloat(-1.2333567)).to.be.equal(true); + expect(utils.isFloat(0.123456)).to.be.equal(true); + }); + + it("should return false for a non float value", () => { + expect(utils.isFloat(100)).to.be.equal(false); + expect(utils.isFloat(-1000)).to.be.equal(false); + expect(utils.isFloat(333)).to.be.equal(false); + }); + }); + + describe("isUndefined", () => { + it("should return true for a undefined value", () => { + expect(utils.isUndefined(undefined)).to.be.equal(true); + expect(utils.isUndefined(null)).to.be.equal(true); + }); + + it("should return false for a defined value", () => { + expect(utils.isUndefined(1.234)).to.be.equal(false); + expect(utils.isUndefined("1.234")).to.be.equal(false); + expect(utils.isUndefined(100)).to.be.equal(false); + expect(utils.isUndefined(-1)).to.be.equal(false); + }); + }); + + describe("setParallels", () => { + it("should set bsconfig parallels equal to value provided in args", () => { + let bsConfig = { + "run_settings": { + "parallels": 10, + } + }; + utils.setParallels(bsConfig, {parallels: 100}); + expect(bsConfig['run_settings']['parallels']).to.be.eq(100); + }); + + it("should retain bsconfig parallels if args is undefined", () => { + let bsConfig = { + "run_settings": { + "parallels": 10, + } + }; + utils.setParallels(bsConfig, {parallels: undefined}); + expect(bsConfig['run_settings']['parallels']).to.be.eq(10); + }); + }); + describe("getErrorCodeFromErr", () => { it("should return bstack_json_invalid_unknown if err.Code is not present in the list", () => { expect(utils.getErrorCodeFromErr("random_value")).to.be.eq("bstack_json_invalid_unknown"); diff --git a/test/unit/support/fixtures/testObjects.js b/test/unit/support/fixtures/testObjects.js index 21c6c1ab..9ffb6102 100644 --- a/test/unit/support/fixtures/testObjects.js +++ b/test/unit/support/fixtures/testObjects.js @@ -104,6 +104,8 @@ const runSampleArgs = { "config-file": "/browserstack.json", configFile: "/browserstack.json", "disable-usage-reporting": undefined, + p: undefined, + "parallels": undefined, disableUsageReporting: undefined, $0: "browserstack-cypress", };