Skip to content

Commit 69f5089

Browse files
committed
error shown if username or password not given
1 parent 6519702 commit 69f5089

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

bin/helpers/capabilityHelper.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ const validate = (bsConfig, args) => {
132132
// if parallels specified via arguments validate only arguments
133133
if (!Utils.isUndefined(args) && !Utils.isUndefined(args.parallels) && !Utils.isParallelValid(args.parallels)) reject(Constants.validationMessages.INVALID_PARALLELS_CONFIGURATION);
134134

135+
if(!Utils.isUndefined(args)){
136+
if(!Utils.isUndefined(args.username) && !Utils.isUndefined(args.key))
137+
reject(Constants.validationMessages.EMPTY_ARGS.replace("<argsNotGiven>", "Username and Password"));
138+
else if(!Utils.isUndefined(args.username))
139+
reject(Constants.validationMessages.EMPTY_ARGS.replace("<argsNotGiven>", "Username"));
140+
else if(!Utils.isUndefined(args.key))
141+
reject(Constants.validationMessages.EMPTY_ARGS.replace("<argsNotGiven>", "Password"));
142+
}
135143
// validate if config file provided exists or not when cypress_config_file provided
136144
// validate the cypressProjectDir key otherwise.
137145
let cypressConfigFilePath = bsConfig.run_settings.cypressConfigFilePath;

bin/helpers/constants.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ const validationMessages = {
5757
INVALID_CYPRESS_JSON: "cypress.json is not a valid json",
5858
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",
5959
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",
60-
INCORRECT_DIRECTORY_STRUCTURE: "No tests to run. Note that your Cypress tests should be in the same directory where the cypress.json exists."
60+
INCORRECT_DIRECTORY_STRUCTURE: "No tests to run. Note that your Cypress tests should be in the same directory where the cypress.json exists.",
61+
EMPTY_ARGS: "Empty <argsNotGiven>"
6162
};
6263

6364
const cliMessages = {

0 commit comments

Comments
 (0)