Skip to content

Commit 205a737

Browse files
Merge pull request #95 from browserstack/multiple_versions
Multiple Versions of Cypress
2 parents 1a5ce6d + 2f795a8 commit 205a737

File tree

6 files changed

+54
-2
lines changed

6 files changed

+54
-2
lines changed

bin/commands/runs.js

+6
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,16 @@ module.exports = function run(args) {
6868
logger.warn(Constants.userMessages.NO_PARALLELS);
6969
}
7070

71+
if (bsConfig.cypress_version && bsConfig.cypress_version !== data.cypress_version) {
72+
let versionMessage = utils.versionChangedMessage(bsConfig.cypress_version, data.cypress_version)
73+
logger.warn(versionMessage);
74+
}
75+
7176
if (!args.disableNpmWarning && bsConfig.run_settings.npm_dependencies && Object.keys(bsConfig.run_settings.npm_dependencies).length <= 0) {
7277
logger.warn(Constants.userMessages.NO_NPM_DEPENDENCIES);
7378
logger.warn(Constants.userMessages.NO_NPM_DEPENDENCIES_READ_MORE);
7479
}
80+
7581
if (args.sync) {
7682
syncRunner.pollBuildStatus(bsConfig, data).then((exitCode) => {
7783
// Generate custom report!

bin/helpers/capabilityHelper.js

+2
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ const caps = (bsConfig, zip) => {
8383
}
8484
}
8585

86+
if (bsConfig.cypress_version) obj.cypress_version = bsConfig.cypress_version;
87+
8688
if(obj.parallels === Constants.cliMessages.RUN.DEFAULT_PARALLEL_MESSAGE) obj.parallels = undefined
8789

8890
if (obj.project) logger.log(`Project name is: ${obj.project}`);

bin/helpers/constants.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ const userMessages = {
3636
EXIT_SYNC_CLI_MESSAGE: "Exiting the CLI, but your build is still running. You can use the --sync option to keep getting test updates. You can also use the build-info <build-id> command now.",
3737
FATAL_NETWORK_ERROR: `fatal: unable to access '${config.buildUrl}': Could not resolve host: ${config.rails_host}`,
3838
RETRY_LIMIT_EXCEEDED: `Max retries exceeded trying to connect to the host (retries: ${config.retries})`,
39-
CHECK_DASHBOARD_AT: "Please check the build status at: "
39+
CHECK_DASHBOARD_AT: "Please check the build status at: ",
40+
CYPRESS_VERSION_CHANGED: "Your build will run using Cypress <actualVersion> instead of Cypress <preferredVersion>. Read more about supported versions here: http://browserstack.com/docs/automate/cypress/supported-versions"
4041
};
4142

4243
const validationMessages = {

bin/helpers/utils.js

+6
Original file line numberDiff line numberDiff line change
@@ -374,3 +374,9 @@ exports.getNetworkErrorMessage = (dashboard_url) => {
374374
+ Constants.userMessages.CHECK_DASHBOARD_AT + dashboard_url
375375
return chalk.red(message)
376376
}
377+
378+
exports.versionChangedMessage = (preferredVersion, actualVersion) => {
379+
let message = Constants.userMessages.CYPRESS_VERSION_CHANGED.replace("<preferredVersion>", preferredVersion);
380+
message = message.replace("<actualVersion>", actualVersion);
381+
return message
382+
}

test/unit/bin/helpers/capabilityHelper.js

+30
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,36 @@ describe("capabilityHelper.js", () => {
4444
});
4545
});
4646

47+
it("handle cypress version passed", () => {
48+
let zip_url = "bs://<random>";
49+
let cypress_version = "version"
50+
let bsConfig = {
51+
auth: {
52+
username: "random",
53+
access_key: "random",
54+
},
55+
browsers: [
56+
{
57+
browser: "chrome",
58+
os: "Windows 10",
59+
versions: ["78", "77"],
60+
},
61+
],
62+
cypress_version: cypress_version,
63+
connection_settings: {
64+
local: true
65+
}
66+
};
67+
return capabilityHelper
68+
.caps(bsConfig, { zip_url: zip_url })
69+
.then(function (data) {
70+
chai.assert.equal(JSON.parse(data).cypress_version, cypress_version);
71+
})
72+
.catch((error) => {
73+
chai.assert.fail("Promise error");
74+
});
75+
});
76+
4777
it("handle empty test_suite", () => {
4878
let zip_url = undefined;
4979
let incorrectBsConfig = {

test/unit/bin/helpers/utils.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1135,8 +1135,15 @@ describe('utils', () => {
11351135
let message = constant.userMessages.FATAL_NETWORK_ERROR + '\n'
11361136
+ constant.userMessages.RETRY_LIMIT_EXCEEDED + '\n'
11371137
+ constant.userMessages.CHECK_DASHBOARD_AT + dashboard_url
1138-
utils.getNetworkErrorMessage(dashboard_url);
11391138
expect(utils.getNetworkErrorMessage(dashboard_url)).to.eq(chalk.red(message))
11401139
});
11411140
});
1141+
1142+
describe('#versionChangedMessage', () => {
1143+
it('should return proper error message with placeholders replaced', () => {
1144+
let preferredVersion = "v1", actualVersion = "v2";
1145+
let message = constant.userMessages.CYPRESS_VERSION_CHANGED.replace("<preferredVersion>", preferredVersion).replace("<actualVersion>", actualVersion);
1146+
expect(utils.versionChangedMessage(preferredVersion, actualVersion)).to.eq(message)
1147+
});
1148+
})
11421149
});

0 commit comments

Comments
 (0)