Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use default port cypress #538

Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions bin/helpers/capabilityHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can add a spec for this. Eg.

it("should log a warning if nodeVersion is not in x.x.x format where x is a number", () => {
return capabilityHelper
.validate(bsConfig, {})
.then(function (data) {
sinon.assert.called(loggerWarningSpy);
});
});

logger.warn(Constants.userMessages.CYPRESS_PORT_WARNING.replace("<x>", cypressConfigFile.port));
}
resolve(cypressConfigFile);
});
}
Expand Down
4 changes: 3 additions & 1 deletion bin/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ const userMessages = {
SPEC_LIMIT_SUCCESS_MESSAGE:
"Spec timeout specified as <x> 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 <x> is ignored. The default BrowserStack port will be used for this execution"
};

const validationMessages = {
Expand Down
24 changes: 23 additions & 1 deletion test/unit/bin/helpers/capabilityHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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('<x>', 23455));
fs.existsSync.restore();
fs.readFileSync.restore();
});

context("cypress config file set to false", () => {
beforeEach(function() {
readFileSpy = sinon.stub(fs, 'readFileSync');
Expand Down