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

Multiple Versions of Cypress #95

Merged
merged 9 commits into from
Dec 7, 2020
6 changes: 6 additions & 0 deletions bin/commands/runs.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,16 @@ module.exports = function run(args) {
logger.warn(Constants.userMessages.NO_PARALLELS);
}

if (bsConfig.cypress_version && bsConfig.cypress_version !== data.cypress_version) {
let versionMessage = utils.versionChangedMessage(bsConfig.cypress_version, data.cypress_version)
logger.warn(versionMessage);
}

if (!args.disableNpmWarning && bsConfig.run_settings.npm_dependencies && Object.keys(bsConfig.run_settings.npm_dependencies).length <= 0) {
logger.warn(Constants.userMessages.NO_NPM_DEPENDENCIES);
logger.warn(Constants.userMessages.NO_NPM_DEPENDENCIES_READ_MORE);
}

if (args.sync) {
syncRunner.pollBuildStatus(bsConfig, data).then((exitCode) => {
// Generate custom report!
Expand Down
2 changes: 2 additions & 0 deletions bin/helpers/capabilityHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ const caps = (bsConfig, zip) => {
}
}

if (bsConfig.cypress_version) obj.cypress_version = bsConfig.cypress_version;

if(obj.parallels === Constants.cliMessages.RUN.DEFAULT_PARALLEL_MESSAGE) obj.parallels = undefined

if (obj.project) logger.log(`Project name is: ${obj.project}`);
Expand Down
3 changes: 2 additions & 1 deletion bin/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ const userMessages = {
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.",
FATAL_NETWORK_ERROR: `fatal: unable to access '${config.buildUrl}': Could not resolve host: ${config.rails_host}`,
RETRY_LIMIT_EXCEEDED: `Max retries exceeded trying to connect to the host (retries: ${config.retries})`,
CHECK_DASHBOARD_AT: "Please check the build status at: "
CHECK_DASHBOARD_AT: "Please check the build status at: ",
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"
};

const validationMessages = {
Expand Down
6 changes: 6 additions & 0 deletions bin/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,9 @@ exports.getNetworkErrorMessage = (dashboard_url) => {
+ Constants.userMessages.CHECK_DASHBOARD_AT + dashboard_url
return chalk.red(message)
}

exports.versionChangedMessage = (preferredVersion, actualVersion) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add Spec for this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

let message = Constants.userMessages.CYPRESS_VERSION_CHANGED.replace("<preferredVersion>", preferredVersion);
message = message.replace("<actualVersion>", actualVersion);
return message
}
30 changes: 30 additions & 0 deletions test/unit/bin/helpers/capabilityHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,36 @@ describe("capabilityHelper.js", () => {
});
});

it("handle cypress version passed", () => {
let zip_url = "bs://<random>";
let cypress_version = "version"
let bsConfig = {
auth: {
username: "random",
access_key: "random",
},
browsers: [
{
browser: "chrome",
os: "Windows 10",
versions: ["78", "77"],
},
],
cypress_version: cypress_version,
connection_settings: {
local: true
}
};
return capabilityHelper
.caps(bsConfig, { zip_url: zip_url })
.then(function (data) {
chai.assert.equal(JSON.parse(data).cypress_version, cypress_version);
})
.catch((error) => {
chai.assert.fail("Promise error");
});
});

it("handle empty test_suite", () => {
let zip_url = undefined;
let incorrectBsConfig = {
Expand Down
9 changes: 8 additions & 1 deletion test/unit/bin/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1135,8 +1135,15 @@ describe('utils', () => {
let message = constant.userMessages.FATAL_NETWORK_ERROR + '\n'
+ constant.userMessages.RETRY_LIMIT_EXCEEDED + '\n'
+ constant.userMessages.CHECK_DASHBOARD_AT + dashboard_url
utils.getNetworkErrorMessage(dashboard_url);
expect(utils.getNetworkErrorMessage(dashboard_url)).to.eq(chalk.red(message))
});
});

describe('#versionChangedMessage', () => {
it('should return proper error message with placeholders replaced', () => {
let preferredVersion = "v1", actualVersion = "v2";
let message = constant.userMessages.CYPRESS_VERSION_CHANGED.replace("<preferredVersion>", preferredVersion).replace("<actualVersion>", actualVersion);
expect(utils.versionChangedMessage(preferredVersion, actualVersion)).to.eq(message)
});
})
});