Skip to content

Commit 73353a9

Browse files
Merge pull request #202 from LambdaTest/dev
3.0.4
2 parents 38c0841 + cf3ae01 commit 73353a9

File tree

4 files changed

+168
-159
lines changed

4 files changed

+168
-159
lines changed

commands/utils/set_args.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ function sync_args_from_cmd(args) {
375375
lt_config["run_settings"]["exclude_specs"] == [];
376376
}
377377
console.log(
378-
"specs to exclude are ",
378+
"specs to exclude are",
379379
lt_config["run_settings"]["exclude_specs"]
380380
);
381381

commands/utils/validate.js

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const fs = require("fs");
22
const semver = require("semver");
3-
const semverCompare = require('semver/functions/compare');
3+
const semverCompare = require("semver/functions/compare");
44

55
const constants = require("./constants.js");
66
module.exports = validate_config = function (lt_config, validation_configs) {
@@ -51,7 +51,6 @@ module.exports = validate_config = function (lt_config, validation_configs) {
5151
reject("Error!! Parallels value not correct");
5252
}
5353

54-
5554
//Validate if package.json is having the cypress dependency
5655
var cypress_version;
5756
if (!fs.existsSync("package.json")) {
@@ -123,13 +122,11 @@ module.exports = validate_config = function (lt_config, validation_configs) {
123122
}
124123

125124
//validate if cypress config file is passed and exists
126-
127125
cypress_version = semver.coerce(cypress_version).version;
128126
// validate cypress.json only in case of cypress<10
129127
if (
130128
semverCompare(cypress_version, "10.0.0") == -1 &&
131-
lt_config["run_settings"]["cypress_config_file"] &&
132-
lt_config["run_settings"]["cypress_config_file"] != ""
129+
lt_config["run_settings"]["cypress_config_file"]
133130
) {
134131
if (!fs.existsSync(lt_config["run_settings"]["cypress_config_file"])) {
135132
reject("Error!! Cypress Config File does not exist");
@@ -146,9 +143,15 @@ module.exports = validate_config = function (lt_config, validation_configs) {
146143
reject("Error!! Cypress Config File does not has correct json");
147144
}
148145
}
146+
} else if (
147+
semverCompare(cypress_version, "10.0.0") >= 0 &&
148+
lt_config["run_settings"]["cypress_config_file"]
149+
) {
150+
reject(
151+
'Error!! --ccf flag and cypress_config_file is not supported with cypress>=10,use \n --cy="--config-file <file path>"'
152+
);
149153
}
150154

151-
152155
if (
153156
lt_config["run_settings"]["ignore_files"] &&
154157
lt_config["run_settings"]["ignore_files"].length > 0
@@ -238,9 +241,14 @@ module.exports = validate_config = function (lt_config, validation_configs) {
238241
reject(
239242
"Error!! Reporter JSON File has no keys, either remove Key reporter_config_file from lambdatest config or pass some options"
240243
);
241-
}else if (reporter_config.reporterEnabled && reporter_config.reporterEnabled != ""){
242-
if (!reporter_config.reporterEnabled.includes("mochawesome")){
243-
console.log("Warning!! mochawesome reporter config not present. Command log may not be visible on dashboard");
244+
} else if (
245+
reporter_config.reporterEnabled &&
246+
reporter_config.reporterEnabled != ""
247+
) {
248+
if (!reporter_config.reporterEnabled.includes("mochawesome")) {
249+
console.log(
250+
"Warning!! mochawesome reporter config not present. Command log may not be visible on dashboard"
251+
);
244252
}
245253
}
246254
} catch {
@@ -250,8 +258,10 @@ module.exports = validate_config = function (lt_config, validation_configs) {
250258
reject("Error!! Reporter JSON File does not have correct json");
251259
}
252260
}
253-
}else{
254-
console.log("Warning!! Value of reporter_config_file parameter missing. Proceeding with default reporter config")
261+
} else {
262+
console.log(
263+
"Warning!! Value of reporter_config_file parameter missing. Proceeding with default reporter config"
264+
);
255265
}
256266

257267
if (
@@ -342,17 +352,19 @@ module.exports = validate_config = function (lt_config, validation_configs) {
342352
if ("sys_envs" in lt_config["run_settings"]) {
343353
let sys_envs = lt_config["run_settings"]["sys_envs"];
344354
let envValue;
345-
Object.keys(sys_envs).forEach(function(envKey) {
355+
Object.keys(sys_envs).forEach(function (envKey) {
346356
envValue = sys_envs[envKey];
347-
if (envKey && ! constants.WHITELISTED_ENV_VARS.includes(envKey)){
348-
reject(`Usage of unwanted environment variable detected. Allowed variables are - ${constants.WHITELISTED_ENV_VARS}`);
357+
if (envKey && !constants.WHITELISTED_ENV_VARS.includes(envKey)) {
358+
reject(
359+
`Usage of unwanted environment variable detected. Allowed variables are - ${constants.WHITELISTED_ENV_VARS}`
360+
);
349361
}
350-
if (envValue == undefined || envValue === ""){
362+
if (envValue == undefined || envValue === "") {
351363
reject("Value of environment variable cannot be left blank");
352364
}
353-
})
354-
365+
});
355366
}
367+
356368
resolve(cypress_version);
357369
});
358370
};

index.js

Lines changed: 137 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -11,146 +11,143 @@ const argv = require("yargs")
1111
"run",
1212
"run tests on lambdatest",
1313
function (yargs) {
14-
return (
15-
yargs
16-
.option("ccf", {
17-
alias: "cypress-config-file",
18-
describe: "path of the config file",
19-
type: "string",
20-
})
21-
.option("lcf", {
22-
alias: "lambdatest-config-file",
23-
describe: "path of the lambdatest config file",
24-
type: "string",
25-
})
26-
.option("s", {
27-
alias: "specs",
28-
describe: "path of the spec file or directory or pattern",
29-
type: "string",
30-
})
31-
.option("env", {
32-
alias: "environment",
33-
describe: "environment",
34-
type: "string",
35-
})
36-
.option("bn", {
37-
alias: "build-name",
38-
describe: "build name",
39-
type: "string",
40-
})
41-
.option("t", {
42-
alias: "tags",
43-
describe: "test tags",
44-
type: "string",
45-
})
46-
.option("p", {
47-
alias: "parallels",
48-
describe: "no of parellel sessions",
49-
type: "string",
50-
})
51-
.option("envs", {
52-
alias: "env-variables",
53-
describe: "environment variables",
54-
type: "string",
55-
})
56-
.option("tun", {
57-
alias: "tunnel",
58-
describe: "tunnel",
59-
type: "string",
60-
})
61-
.option("tname", {
62-
alias: "tunnel_name",
63-
describe: "tunnel name",
64-
type: "string",
65-
})
66-
.option("brs", {
67-
alias: "browsers",
68-
describe: "browsers to run test format: platform:browser:version",
69-
type: "string",
70-
})
71-
.option("bi", {
72-
alias: "build-identifier",
73-
describe: "Build Identifier / Build Counter",
74-
type: "string",
75-
})
76-
.option("if", {
77-
alias: "ignore_files",
78-
describe: "Files to ignore in the project zip",
79-
type: "string",
80-
})
81-
.option("sync", {
82-
alias: "sync-mode",
83-
describe: "Sync Build",
84-
type: "string",
85-
})
86-
.option("autostart", {
87-
alias: "tat",
88-
describe: "Tunnel Auto Start",
89-
type: "string",
90-
})
91-
.option("headless", {
92-
alias: "headless-mode",
93-
describe: "Run in headless mode",
94-
type: "boolean",
95-
})
96-
.option("net", {
97-
alias: "network",
98-
describe: "Capture Network logs",
99-
type: "string",
100-
})
101-
.option("eof", {
102-
alias: "exit-on-failure",
103-
describe: "Exit With Code 1 on failure",
104-
type: "string",
105-
})
106-
.option("cy", {
107-
alias: "cypress_settings",
108-
describe: "Pass Cypress Settings",
109-
type: "string",
110-
})
111-
.option("geo", {
112-
alias: "geo_location",
113-
describe: "Pass Geo Country Code",
114-
type: "string",
115-
})
116-
.option("sof", {
117-
alias: "stop_on_failure",
118-
describe:
119-
"Stop other tests if any test in session gets errored out",
120-
type: "bool",
121-
})
122-
.option("ra", {
123-
alias: "reject_unauthorized",
124-
describe:
125-
"Default rejects self signed certificates in external requests",
126-
type: "bool",
127-
})
128-
.option("bt", {
129-
alias: "build-tags",
130-
describe: "build tags",
131-
type: "string",
132-
})
133-
.option("sys-envs", {
134-
alias: "sys-env-variables",
135-
describe: "system environment variables",
136-
type: "string",
137-
})
138-
// .option("npm-f", {
139-
// alias: "npm-force",
140-
// describe: "force npm install",
141-
// type: "bool",
142-
// })
143-
// .option("npm-lpd", {
144-
// alias: "legacy-peer-deps",
145-
// describe: "force npm install",
146-
// type: "bool",
147-
// })
148-
.option("vip", {
149-
alias: "vi-project",
150-
describe: "visual ui project name",
151-
type: "string",
152-
})
153-
);
14+
return yargs
15+
.option("ccf", {
16+
alias: "cypress-config-file",
17+
describe: "path of the config file",
18+
type: "string",
19+
})
20+
.option("lcf", {
21+
alias: "lambdatest-config-file",
22+
describe: "path of the lambdatest config file",
23+
type: "string",
24+
})
25+
.option("s", {
26+
alias: "specs",
27+
describe: "path of the spec file or directory or pattern",
28+
type: "string",
29+
})
30+
.option("env", {
31+
alias: "environment",
32+
describe: "environment",
33+
type: "string",
34+
})
35+
.option("bn", {
36+
alias: "build-name",
37+
describe: "build name",
38+
type: "string",
39+
})
40+
.option("t", {
41+
alias: "tags",
42+
describe: "test tags",
43+
type: "string",
44+
})
45+
.option("p", {
46+
alias: "parallels",
47+
describe: "no of parellel sessions",
48+
type: "string",
49+
})
50+
.option("envs", {
51+
alias: "env-variables",
52+
describe: "environment variables",
53+
type: "string",
54+
})
55+
.option("tun", {
56+
alias: "tunnel",
57+
describe: "tunnel",
58+
type: "string",
59+
})
60+
.option("tname", {
61+
alias: "tunnel_name",
62+
describe: "tunnel name",
63+
type: "string",
64+
})
65+
.option("brs", {
66+
alias: "browsers",
67+
describe: "browsers to run test format: platform:browser:version",
68+
type: "string",
69+
})
70+
.option("bi", {
71+
alias: "build-identifier",
72+
describe: "Build Identifier / Build Counter",
73+
type: "string",
74+
})
75+
.option("if", {
76+
alias: "ignore_files",
77+
describe: "Files to ignore in the project zip",
78+
type: "string",
79+
})
80+
.option("sync", {
81+
alias: "sync-mode",
82+
describe: "Sync Build",
83+
type: "string",
84+
})
85+
.option("autostart", {
86+
alias: "tat",
87+
describe: "Tunnel Auto Start",
88+
type: "string",
89+
})
90+
.option("headless", {
91+
alias: "headless-mode",
92+
describe: "Run in headless mode",
93+
type: "boolean",
94+
})
95+
.option("net", {
96+
alias: "network",
97+
describe: "Capture Network logs",
98+
type: "string",
99+
})
100+
.option("eof", {
101+
alias: "exit-on-failure",
102+
describe: "Exit With Code 1 on failure",
103+
type: "string",
104+
})
105+
.option("cy", {
106+
alias: "cypress_settings",
107+
describe: "Pass Cypress Settings",
108+
type: "string",
109+
})
110+
.option("geo", {
111+
alias: "geo_location",
112+
describe: "Pass Geo Country Code",
113+
type: "string",
114+
})
115+
.option("sof", {
116+
alias: "stop_on_failure",
117+
describe: "Stop other tests if any test in session gets errored out",
118+
type: "bool",
119+
})
120+
.option("ra", {
121+
alias: "reject_unauthorized",
122+
describe:
123+
"Default rejects self signed certificates in external requests",
124+
type: "bool",
125+
})
126+
.option("bt", {
127+
alias: "build-tags",
128+
describe: "build tags",
129+
type: "string",
130+
})
131+
.option("sys-envs", {
132+
alias: "sys-env-variables",
133+
describe: "system environment variables",
134+
type: "string",
135+
})
136+
.option("npm-f", {
137+
alias: "npm-force",
138+
describe: "force npm install",
139+
type: "bool",
140+
})
141+
.option("npm-lpd", {
142+
alias: "legacy-peer-deps",
143+
describe: "force npm install",
144+
type: "bool",
145+
})
146+
.option("vip", {
147+
alias: "vi-project",
148+
describe: "visual ui project name",
149+
type: "string",
150+
});
154151
},
155152
function (argv) {
156153
require("./commands/run")(argv);

0 commit comments

Comments
 (0)