Skip to content

Commit cc68672

Browse files
Merge pull request #538 from browserstack/AFD-1921-use-default-port-cypress
Use default port cypress
2 parents eec0ab1 + 0f439d4 commit cc68672

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

bin/helpers/capabilityHelper.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ const validate = (bsConfig, args) => {
286286
if (!Utils.isUndefined(bsConfig.run_settings.nodeVersion) && typeof(bsConfig.run_settings.nodeVersion) === 'string' && !bsConfig.run_settings.nodeVersion.match(/^(\d+\.)?(\d+\.)?(\*|\d+)$/))
287287
logger.warn(Constants.validationMessages.NODE_VERSION_PARSING_ERROR);
288288

289+
if(!Utils.isUndefined(cypressConfigFile.port)) {
290+
logger.warn(Constants.userMessages.CYPRESS_PORT_WARNING.replace("<x>", cypressConfigFile.port));
291+
}
289292
resolve(cypressConfigFile);
290293
});
291294
}

bin/helpers/constants.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ const userMessages = {
113113
SPEC_LIMIT_SUCCESS_MESSAGE:
114114
"Spec timeout specified as <x> minutes. If any of your specs exceed the specified time limit, it would be forcibly killed by BrowserStack",
115115
NO_CONNECTION_WHILE_UPDATING_UPLOAD_PROGRESS_BAR:
116-
"Unable to determine zip upload progress due to undefined/null connection request"
116+
"Unable to determine zip upload progress due to undefined/null connection request",
117+
CYPRESS_PORT_WARNING:
118+
"The requested port number <x> is ignored. The default BrowserStack port will be used for this execution"
117119
};
118120

119121
const validationMessages = {

test/unit/bin/helpers/capabilityHelper.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,11 +962,20 @@ describe("capabilityHelper.js", () => {
962962
run_settings: {
963963
cypress_proj_dir: "random path",
964964
cypressConfigFilePath: "random path",
965-
cypressProjectDir: "random path"
965+
cypressProjectDir: "random path",
966+
cypress_config_filename: "cypress.json",
967+
spec_timeout: 10,
968+
cypressTestSuiteType: Constants.CYPRESS_V9_AND_OLDER_TYPE
966969
},
967970
connection_settings: {local: false}
968971
};
972+
loggerWarningSpy = sinon.stub(logger, 'warn');
973+
});
974+
975+
afterEach(function() {
976+
loggerWarningSpy.restore();
969977
});
978+
970979
it("validate cypress json is present", () => {
971980
//Stub for cypress json validation
972981
sinon.stub(fs, 'existsSync').returns(false);
@@ -1046,6 +1055,19 @@ describe("capabilityHelper.js", () => {
10461055
});
10471056
});
10481057

1058+
it("should warn if port is passed in cypress config file", async () => {
1059+
//Stub for cypress json validation
1060+
sinon.stub(fs, 'existsSync').returns(true);
1061+
sinon.stub(fs, 'readFileSync').returns('{ "port": 23455}');
1062+
1063+
await capabilityHelper
1064+
.validate(bsConfig, { parallels: 2 })
1065+
1066+
sinon.assert.calledWith(loggerWarningSpy, Constants.userMessages.CYPRESS_PORT_WARNING.replace('<x>', 23455));
1067+
fs.existsSync.restore();
1068+
fs.readFileSync.restore();
1069+
});
1070+
10491071
context("cypress config file set to false", () => {
10501072
beforeEach(function() {
10511073
readFileSpy = sinon.stub(fs, 'readFileSync');

0 commit comments

Comments
 (0)