Skip to content

Changes in CLI messages to support browserstack cypress latest flag #156

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

Merged
merged 4 commits into from
Sep 8, 2021
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
9 changes: 7 additions & 2 deletions bin/commands/runs.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,13 @@ module.exports = function run(args) {
}

if (bsConfig.run_settings.cypress_version && bsConfig.run_settings.cypress_version !== data.cypress_version) {
let versionMessage = utils.versionChangedMessage(bsConfig.run_settings.cypress_version, data.cypress_version)
logger.warn(versionMessage);
if (bsConfig.run_settings.cypress_version.match(Constants.LATEST_VERSION_SYNTAX_REGEX)) {
let versionMessage = utils.latestSyntaxToActualVersionMessage(bsConfig.run_settings.cypress_version, data.cypress_version);
logger.info(versionMessage);
} else {
let versionMessage = utils.versionChangedMessage(bsConfig.run_settings.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) {
Expand Down
8 changes: 6 additions & 2 deletions bin/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ const userMessages = {
LOCAL_START_FAILED: "Local Testing setup failed.",
LOCAL_STOP_FAILED: "Local Binary stop failed.",
INVALID_LOCAL_MODE_WARNING: "Invalid value specified for local_mode. local_mode: (\"always-on\" | \"on-demand\"). For more info, check out https://www.browserstack.com/docs/automate/cypress/cli-reference",
SPEC_LIMIT_WARNING: "You might not see all your results on the dashboard because of high spec count, please consider reducing the number of spec files in this folder."
SPEC_LIMIT_WARNING: "You might not see all your results on the dashboard because of high spec count, please consider reducing the number of spec files in this folder.",
LATEST_SYNTAX_TO_ACTUAL_VERSION_MESSAGE: "Your build will run using Cypress <actualVersion> as you had specified <latestSyntaxVersion>. Read more about supported versions here: http://browserstack.com/docs/automate/cypress/supported-versions"
};

const validationMessages = {
Expand Down Expand Up @@ -170,6 +171,8 @@ const DEFAULT_CYPRESS_SPEC_PATH = "cypress/integration"
const SPEC_TOTAL_CHAR_LIMIT = 32243;
const METADATA_CHAR_BUFFER_PER_SPEC = 175;

const LATEST_VERSION_SYNTAX_REGEX = /\d*.latest(.\d*)?/gm

module.exports = Object.freeze({
syncCLI,
userMessages,
Expand All @@ -183,5 +186,6 @@ module.exports = Object.freeze({
specFileTypes,
DEFAULT_CYPRESS_SPEC_PATH,
SPEC_TOTAL_CHAR_LIMIT,
METADATA_CHAR_BUFFER_PER_SPEC
METADATA_CHAR_BUFFER_PER_SPEC,
LATEST_VERSION_SYNTAX_REGEX
});
6 changes: 6 additions & 0 deletions bin/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,12 @@ exports.versionChangedMessage = (preferredVersion, actualVersion) => {
return message
}

exports.latestSyntaxToActualVersionMessage = (latestSyntaxVersion, actualVersion) => {
let message = Constants.userMessages.LATEST_SYNTAX_TO_ACTUAL_VERSION_MESSAGE.replace("<latestSyntaxVersion>", latestSyntaxVersion);
message = message.replace("<actualVersion>", actualVersion);
return message
}

exports.isJSONInvalid = (err, args) => {
let invalid = true

Expand Down
8 changes: 8 additions & 0 deletions test/unit/bin/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1812,6 +1812,14 @@ describe('utils', () => {
});
})

describe('#latestSyntaxToActualVersionMessage', () => {
it('should return proper info message with placeholders replaced', () => {
let latestSyntaxVersion = "7.latest", actualVersion = "7.6.0";
let message = constant.userMessages.LATEST_SYNTAX_TO_ACTUAL_VERSION_MESSAGE.replace("<latestSyntaxVersion>", latestSyntaxVersion).replace("<actualVersion>", actualVersion);
expect(utils.latestSyntaxToActualVersionMessage(latestSyntaxVersion, actualVersion)).to.eq(message)
});
})

describe('#isJSONInvalid', () => {
it('JSON is valid when error is parallel misconfiguration', () => {
let error = constant.validationMessages.INVALID_PARALLELS_CONFIGURATION;
Expand Down