Skip to content

Commit 8102831

Browse files
Added UT
1 parent da2c8c1 commit 8102831

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

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, `The requested port number 23455 is ignored. The default BrowserStack port will be used for this execution`);
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)