diff --git a/bin/helpers/capabilityHelper.js b/bin/helpers/capabilityHelper.js index 4e6cb2bd..06c9ebee 100644 --- a/bin/helpers/capabilityHelper.js +++ b/bin/helpers/capabilityHelper.js @@ -286,6 +286,9 @@ const validate = (bsConfig, args) => { if (!Utils.isUndefined(bsConfig.run_settings.nodeVersion) && typeof(bsConfig.run_settings.nodeVersion) === 'string' && !bsConfig.run_settings.nodeVersion.match(/^(\d+\.)?(\d+\.)?(\*|\d+)$/)) logger.warn(Constants.validationMessages.NODE_VERSION_PARSING_ERROR); + if(!Utils.isUndefined(cypressConfigFile.port)) { + logger.warn(Constants.userMessages.CYPRESS_PORT_WARNING.replace("", cypressConfigFile.port)); + } resolve(cypressConfigFile); }); } diff --git a/bin/helpers/constants.js b/bin/helpers/constants.js index cdb19579..eb032384 100644 --- a/bin/helpers/constants.js +++ b/bin/helpers/constants.js @@ -113,7 +113,9 @@ const userMessages = { SPEC_LIMIT_SUCCESS_MESSAGE: "Spec timeout specified as minutes. If any of your specs exceed the specified time limit, it would be forcibly killed by BrowserStack", NO_CONNECTION_WHILE_UPDATING_UPLOAD_PROGRESS_BAR: - "Unable to determine zip upload progress due to undefined/null connection request" + "Unable to determine zip upload progress due to undefined/null connection request", + CYPRESS_PORT_WARNING: + "The requested port number is ignored. The default BrowserStack port will be used for this execution" }; const validationMessages = { diff --git a/test/unit/bin/helpers/capabilityHelper.js b/test/unit/bin/helpers/capabilityHelper.js index 59beed8b..b8f7a8b7 100644 --- a/test/unit/bin/helpers/capabilityHelper.js +++ b/test/unit/bin/helpers/capabilityHelper.js @@ -962,11 +962,20 @@ describe("capabilityHelper.js", () => { run_settings: { cypress_proj_dir: "random path", cypressConfigFilePath: "random path", - cypressProjectDir: "random path" + cypressProjectDir: "random path", + cypress_config_filename: "cypress.json", + spec_timeout: 10, + cypressTestSuiteType: Constants.CYPRESS_V9_AND_OLDER_TYPE }, connection_settings: {local: false} }; + loggerWarningSpy = sinon.stub(logger, 'warn'); + }); + + afterEach(function() { + loggerWarningSpy.restore(); }); + it("validate cypress json is present", () => { //Stub for cypress json validation sinon.stub(fs, 'existsSync').returns(false); @@ -1046,6 +1055,19 @@ describe("capabilityHelper.js", () => { }); }); + it("should warn if port is passed in cypress config file", async () => { + //Stub for cypress json validation + sinon.stub(fs, 'existsSync').returns(true); + sinon.stub(fs, 'readFileSync').returns('{ "port": 23455}'); + + await capabilityHelper + .validate(bsConfig, { parallels: 2 }) + + sinon.assert.calledWith(loggerWarningSpy, Constants.userMessages.CYPRESS_PORT_WARNING.replace('', 23455)); + fs.existsSync.restore(); + fs.readFileSync.restore(); + }); + context("cypress config file set to false", () => { beforeEach(function() { readFileSpy = sinon.stub(fs, 'readFileSync');