Skip to content

Commit c3a3759

Browse files
Merge pull request #110 from japneetlambdatest/MLE-7910
Mle 7910 Cypress Param Support
2 parents 4d96057 + d2eed67 commit c3a3759

File tree

4 files changed

+40
-3
lines changed

4 files changed

+40
-3
lines changed

commands/run.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module.exports = function (args) {
4949
.sync_args_from_cmd(args)
5050
.then(function (lt_config) {
5151
//validate the config options
52-
validate(lt_config)
52+
validate(lt_config, resp)
5353
.then(function () {
5454
batcher
5555
.make_batches(lt_config)

commands/utils/set_args.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,13 @@ function sync_args_from_cmd(args) {
262262
if (!("downloads" in lt_config["run_settings"])) {
263263
lt_config["run_settings"]["downloads"] = "";
264264
}
265+
//Check for cypress settings
266+
if ("cypress_settings" in args) {
267+
lt_config["run_settings"]["cypress_settings"] = args["cypress_settings"];
268+
} else if (!lt_config["run_settings"]["cypress_settings"]) {
269+
lt_config["run_settings"]["cypress_settings"] = "";
270+
}
271+
265272
//get specs from current directory if specs are not passed in config or cli
266273
if (
267274
(lt_config["run_settings"]["specs"] == undefined ||

commands/utils/validate.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const fs = require("fs");
22
const constants = require("./constants.js");
3-
module.exports = validate_config = function (lt_config) {
3+
module.exports = validate_config = function (lt_config, validation_configs) {
44
return new Promise(function (resolve, reject) {
55
//validate auth keys are present
66
if (
@@ -168,15 +168,40 @@ module.exports = validate_config = function (lt_config) {
168168
for (folder in download_folders) {
169169
console.log(download_folders[folder]);
170170
if (download_folders[folder][0] != ".") {
171-
reject("Error!! dowloads folder path is not relative ", folder);
171+
reject("Error!! dowloads folder path is not relative " + folder);
172172
}
173173
}
174174
}
175+
176+
if (lt_config["run_settings"]["cypress_settings"] != "") {
177+
let settings = lt_config["run_settings"]["cypress_settings"].split(";");
178+
//let setting_names = [];
179+
let settings_flag = true;
180+
let setting_param = "";
181+
for (let i = 0; i < settings.length; i++) {
182+
if (
183+
validation_configs.blacklistCommands.includes(
184+
settings[i].split(" ")[0]
185+
)
186+
) {
187+
settings_flag = false;
188+
setting_param = settings[i].split(" ")[0];
189+
break;
190+
}
191+
}
192+
if (settings_flag == false) {
193+
reject(
194+
"Error!! Following cypress param is not allowed " + setting_param
195+
);
196+
}
197+
}
198+
175199
if ("smart_ui" in lt_config.run_settings) {
176200
if (!("project" in lt_config.run_settings.smart_ui)) {
177201
reject("Smart UI project name is missing");
178202
} else if (lt_config.run_settings.smart_ui.project == "") {
179203
reject("Smart UI porject name can not be blank");
204+
180205
}
181206
}
182207
resolve("Validated the Config");

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ const argv = require("yargs")
101101
alias: "exit-on-failure",
102102
describe: "Exit With Code 1 on failure",
103103
type: "string",
104+
})
105+
.option("cy", {
106+
alias: "cypress_settings",
107+
describe: "Pass Cypress Settings",
108+
type: "string",
104109
});
105110
},
106111
function (argv) {

0 commit comments

Comments
 (0)