Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 6 additions & 1 deletion bin/helpers/capabilityHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ const caps = (bsConfig, zip) => {
// Local Mode
if (obj.local === true && bsConfig.connection_settings.local_mode) {
obj.localMode = bsConfig.connection_settings.local_mode;
if (bsConfig.connection_settings.user_defined_local_mode_warning) {
logger.warn(Constants.userMessages.INVALID_LOCAL_MODE_WARNING);
}
logger.info(`Local testing set up in ${obj.localMode} mode.`);
}

Expand Down Expand Up @@ -160,7 +163,9 @@ const validate = (bsConfig, args) => {

// validate local args i.e --local-mode and --local-identifier

if( Utils.searchForOption('--local-identifier') && (Utils.isUndefined(args.localIdentifier) || (!Utils.isUndefined(args.localIdentifier) && !args.localIdentifier.trim()))) reject(Constants.validationMessages.INVALID_LOCAL_IDENTIFIER);
if( Utils.searchForOption('--local-identifier') && (Utils.isUndefined(args.localIdentifier) || (!Utils.isUndefined(args.localIdentifier) && !args.localIdentifier.trim()))) reject(Constants.validationMessages.INVALID_CLI_LOCAL_IDENTIFIER);

if( Utils.getLocalFlag(bsConfig.connection_settings) && (Utils.isUndefined(bsConfig["connection_settings"]["local_identifier"]) || ( !Utils.isUndefined(bsConfig["connection_settings"]["local_identifier"]) && !bsConfig["connection_settings"]["local_identifier"].trim()))) reject(Constants.validationMessages.INVALID_LOCAL_IDENTIFIER);

if( Utils.searchForOption('--local-mode') && ( Utils.isUndefined(args.localMode) || (!Utils.isUndefined(args.localMode) && !["always-on","on-demand"].includes(args.localMode)))) reject(Constants.validationMessages.INVALID_LOCAL_MODE);

Expand Down
8 changes: 5 additions & 3 deletions bin/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const userMessages = {
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",
LOCAL_START_FAILED: "Local Testing setup failed.",
LOCAL_STOP_FAILED: "Local Binary stop 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"
};

const validationMessages = {
Expand All @@ -60,9 +61,10 @@ const validationMessages = {
INVALID_DEFAULT_AUTH_PARAMS: "Your username and access key are required to run your tests on BrowserStack. Learn more at https://www.browserstack.com/docs/automate/cypress/authentication",
LOCAL_NOT_SET: "To test <baseUrlValue> on BrowserStack, you will have to set up Local testing. Read more here: https://www.browserstack.com/docs/automate/cypress/local-testing",
INCORRECT_DIRECTORY_STRUCTURE: "No tests to run. Note that your Cypress tests should be in the same directory where the cypress.json exists.",
INVALID_LOCAL_IDENTIFIER: "When using --local-identifier, a value needs to be supplied. \n--local-identifier <String>.\nFor more info, check out https://www.browserstack.com/docs/automate/cypress/cli-reference",
INVALID_CLI_LOCAL_IDENTIFIER: "When using --local-identifier, a value needs to be supplied. \n--local-identifier <String>.\nFor more info, check out https://www.browserstack.com/docs/automate/cypress/cli-reference",
INVALID_LOCAL_MODE: "When using --local-mode, a value needs to be supplied. \n--local-mode (\"always-on\" | \"on-demand\").\nFor more info, check out https://www.browserstack.com/docs/automate/cypress/cli-reference",
INVALID_LOCAL_CONFIG_FILE: "When using --local-config-file, a value needs to be supplied. \n--local-config-file \"path to local-config-file.yaml\".\nFor more info, check out https://www.browserstack.com/docs/automate/cypress/cli-reference"
INVALID_LOCAL_CONFIG_FILE: "When using --local-config-file, a value needs to be supplied. \n--local-config-file \"path to local-config-file.yaml\".\nFor more info, check out https://www.browserstack.com/docs/automate/cypress/cli-reference",
INVALID_LOCAL_IDENTIFIER: "Invalid value specified for local_identifier. For more info, check out https://www.browserstack.com/docs/automate/cypress/cli-reference"
};

const cliMessages = {
Expand Down
9 changes: 7 additions & 2 deletions bin/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ exports.getErrorCodeFromMsg = (errMsg) => {
case Constants.validationMessages.INVALID_LOCAL_IDENTIFIER:
errorCode = 'invalid_local_identifier';
break;
case Constants.validationMessages.INVALID_CLI_LOCAL_IDENTIFIER:
errorCode = 'invalid_local_identifier';
break;
case Constants.validationMessages.INVALID_LOCAL_MODE:
errorCode = 'invalid_local_mode';
break;
Expand Down Expand Up @@ -383,9 +386,11 @@ exports.setLocalMode = (bsConfig, args) => {

if (!this.isUndefined(args.localMode) && args.localMode == 'always-on') {
local_mode = 'always-on';
} else if (!localModeUndefined && !["always-on", "on-demand"].includes(bsConfig['connection_settings']['local_mode'])) {
bsConfig.connection_settings.user_defined_local_mode_warning = bsConfig['connection_settings']['local_mode'];
} else if (
!this.isUndefined(bsConfig['connection_settings']['local_mode']) &&
bsConfig['connection_settings']['local_mode'].toLowerCase() ===
String(bsConfig['connection_settings']['local_mode']).toLowerCase() ===
'always-on'
) {
local_mode = 'always-on';
Expand Down Expand Up @@ -611,7 +616,7 @@ exports.isJSONInvalid = (err, args) => {
return false
}

if( err === Constants.validationMessages.INVALID_LOCAL_IDENTIFIER || err === Constants.validationMessages.INVALID_LOCAL_MODE ){
if( err === Constants.validationMessages.INVALID_CLI_LOCAL_IDENTIFIER || err === Constants.validationMessages.INVALID_LOCAL_MODE ){
return false
}

Expand Down
7 changes: 6 additions & 1 deletion test/unit/bin/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ describe('utils', () => {
constant.validationMessages.INVALID_LOCAL_IDENTIFIER
)
).to.eq('invalid_local_identifier');
expect(
utils.getErrorCodeFromMsg(
constant.validationMessages.INVALID_CLI_LOCAL_IDENTIFIER
)
).to.eq('invalid_local_identifier');
expect(
utils.getErrorCodeFromMsg(
constant.validationMessages.INVALID_LOCAL_MODE
Expand Down Expand Up @@ -1604,7 +1609,7 @@ describe('utils', () => {
});

it('JSON is invalid if local identifier is invalid', () =>{
let error = constant.validationMessages.INVALID_LOCAL_IDENTIFIER;
let error = constant.validationMessages.INVALID_CLI_LOCAL_IDENTIFIER;
expect(utils.isJSONInvalid(error,{})).to.eq(false);
});

Expand Down