Skip to content

3.0.4 #202

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 10 commits into from
Nov 3, 2022
Merged

3.0.4 #202

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
2 changes: 1 addition & 1 deletion commands/utils/set_args.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ function sync_args_from_cmd(args) {
lt_config["run_settings"]["exclude_specs"] == [];
}
console.log(
"specs to exclude are ",
"specs to exclude are",
lt_config["run_settings"]["exclude_specs"]
);

Expand Down
46 changes: 29 additions & 17 deletions commands/utils/validate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require("fs");
const semver = require("semver");
const semverCompare = require('semver/functions/compare');
const semverCompare = require("semver/functions/compare");

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


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

//validate if cypress config file is passed and exists

cypress_version = semver.coerce(cypress_version).version;
// validate cypress.json only in case of cypress<10
if (
semverCompare(cypress_version, "10.0.0") == -1 &&
lt_config["run_settings"]["cypress_config_file"] &&
lt_config["run_settings"]["cypress_config_file"] != ""
lt_config["run_settings"]["cypress_config_file"]
) {
if (!fs.existsSync(lt_config["run_settings"]["cypress_config_file"])) {
reject("Error!! Cypress Config File does not exist");
Expand All @@ -146,9 +143,15 @@ module.exports = validate_config = function (lt_config, validation_configs) {
reject("Error!! Cypress Config File does not has correct json");
}
}
} else if (
semverCompare(cypress_version, "10.0.0") >= 0 &&
lt_config["run_settings"]["cypress_config_file"]
) {
reject(
'Error!! --ccf flag and cypress_config_file is not supported with cypress>=10,use \n --cy="--config-file <file path>"'
);
}


if (
lt_config["run_settings"]["ignore_files"] &&
lt_config["run_settings"]["ignore_files"].length > 0
Expand Down Expand Up @@ -238,9 +241,14 @@ module.exports = validate_config = function (lt_config, validation_configs) {
reject(
"Error!! Reporter JSON File has no keys, either remove Key reporter_config_file from lambdatest config or pass some options"
);
}else if (reporter_config.reporterEnabled && reporter_config.reporterEnabled != ""){
if (!reporter_config.reporterEnabled.includes("mochawesome")){
console.log("Warning!! mochawesome reporter config not present. Command log may not be visible on dashboard");
} else if (
reporter_config.reporterEnabled &&
reporter_config.reporterEnabled != ""
) {
if (!reporter_config.reporterEnabled.includes("mochawesome")) {
console.log(
"Warning!! mochawesome reporter config not present. Command log may not be visible on dashboard"
);
}
}
} catch {
Expand All @@ -250,8 +258,10 @@ module.exports = validate_config = function (lt_config, validation_configs) {
reject("Error!! Reporter JSON File does not have correct json");
}
}
}else{
console.log("Warning!! Value of reporter_config_file parameter missing. Proceeding with default reporter config")
} else {
console.log(
"Warning!! Value of reporter_config_file parameter missing. Proceeding with default reporter config"
);
}

if (
Expand Down Expand Up @@ -342,17 +352,19 @@ module.exports = validate_config = function (lt_config, validation_configs) {
if ("sys_envs" in lt_config["run_settings"]) {
let sys_envs = lt_config["run_settings"]["sys_envs"];
let envValue;
Object.keys(sys_envs).forEach(function(envKey) {
Object.keys(sys_envs).forEach(function (envKey) {
envValue = sys_envs[envKey];
if (envKey && ! constants.WHITELISTED_ENV_VARS.includes(envKey)){
reject(`Usage of unwanted environment variable detected. Allowed variables are - ${constants.WHITELISTED_ENV_VARS}`);
if (envKey && !constants.WHITELISTED_ENV_VARS.includes(envKey)) {
reject(
`Usage of unwanted environment variable detected. Allowed variables are - ${constants.WHITELISTED_ENV_VARS}`
);
}
if (envValue == undefined || envValue === ""){
if (envValue == undefined || envValue === "") {
reject("Value of environment variable cannot be left blank");
}
})

});
}

resolve(cypress_version);
});
};
277 changes: 137 additions & 140 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,146 +11,143 @@ const argv = require("yargs")
"run",
"run tests on lambdatest",
function (yargs) {
return (
yargs
.option("ccf", {
alias: "cypress-config-file",
describe: "path of the config file",
type: "string",
})
.option("lcf", {
alias: "lambdatest-config-file",
describe: "path of the lambdatest config file",
type: "string",
})
.option("s", {
alias: "specs",
describe: "path of the spec file or directory or pattern",
type: "string",
})
.option("env", {
alias: "environment",
describe: "environment",
type: "string",
})
.option("bn", {
alias: "build-name",
describe: "build name",
type: "string",
})
.option("t", {
alias: "tags",
describe: "test tags",
type: "string",
})
.option("p", {
alias: "parallels",
describe: "no of parellel sessions",
type: "string",
})
.option("envs", {
alias: "env-variables",
describe: "environment variables",
type: "string",
})
.option("tun", {
alias: "tunnel",
describe: "tunnel",
type: "string",
})
.option("tname", {
alias: "tunnel_name",
describe: "tunnel name",
type: "string",
})
.option("brs", {
alias: "browsers",
describe: "browsers to run test format: platform:browser:version",
type: "string",
})
.option("bi", {
alias: "build-identifier",
describe: "Build Identifier / Build Counter",
type: "string",
})
.option("if", {
alias: "ignore_files",
describe: "Files to ignore in the project zip",
type: "string",
})
.option("sync", {
alias: "sync-mode",
describe: "Sync Build",
type: "string",
})
.option("autostart", {
alias: "tat",
describe: "Tunnel Auto Start",
type: "string",
})
.option("headless", {
alias: "headless-mode",
describe: "Run in headless mode",
type: "boolean",
})
.option("net", {
alias: "network",
describe: "Capture Network logs",
type: "string",
})
.option("eof", {
alias: "exit-on-failure",
describe: "Exit With Code 1 on failure",
type: "string",
})
.option("cy", {
alias: "cypress_settings",
describe: "Pass Cypress Settings",
type: "string",
})
.option("geo", {
alias: "geo_location",
describe: "Pass Geo Country Code",
type: "string",
})
.option("sof", {
alias: "stop_on_failure",
describe:
"Stop other tests if any test in session gets errored out",
type: "bool",
})
.option("ra", {
alias: "reject_unauthorized",
describe:
"Default rejects self signed certificates in external requests",
type: "bool",
})
.option("bt", {
alias: "build-tags",
describe: "build tags",
type: "string",
})
.option("sys-envs", {
alias: "sys-env-variables",
describe: "system environment variables",
type: "string",
})
// .option("npm-f", {
// alias: "npm-force",
// describe: "force npm install",
// type: "bool",
// })
// .option("npm-lpd", {
// alias: "legacy-peer-deps",
// describe: "force npm install",
// type: "bool",
// })
.option("vip", {
alias: "vi-project",
describe: "visual ui project name",
type: "string",
})
);
return yargs
.option("ccf", {
alias: "cypress-config-file",
describe: "path of the config file",
type: "string",
})
.option("lcf", {
alias: "lambdatest-config-file",
describe: "path of the lambdatest config file",
type: "string",
})
.option("s", {
alias: "specs",
describe: "path of the spec file or directory or pattern",
type: "string",
})
.option("env", {
alias: "environment",
describe: "environment",
type: "string",
})
.option("bn", {
alias: "build-name",
describe: "build name",
type: "string",
})
.option("t", {
alias: "tags",
describe: "test tags",
type: "string",
})
.option("p", {
alias: "parallels",
describe: "no of parellel sessions",
type: "string",
})
.option("envs", {
alias: "env-variables",
describe: "environment variables",
type: "string",
})
.option("tun", {
alias: "tunnel",
describe: "tunnel",
type: "string",
})
.option("tname", {
alias: "tunnel_name",
describe: "tunnel name",
type: "string",
})
.option("brs", {
alias: "browsers",
describe: "browsers to run test format: platform:browser:version",
type: "string",
})
.option("bi", {
alias: "build-identifier",
describe: "Build Identifier / Build Counter",
type: "string",
})
.option("if", {
alias: "ignore_files",
describe: "Files to ignore in the project zip",
type: "string",
})
.option("sync", {
alias: "sync-mode",
describe: "Sync Build",
type: "string",
})
.option("autostart", {
alias: "tat",
describe: "Tunnel Auto Start",
type: "string",
})
.option("headless", {
alias: "headless-mode",
describe: "Run in headless mode",
type: "boolean",
})
.option("net", {
alias: "network",
describe: "Capture Network logs",
type: "string",
})
.option("eof", {
alias: "exit-on-failure",
describe: "Exit With Code 1 on failure",
type: "string",
})
.option("cy", {
alias: "cypress_settings",
describe: "Pass Cypress Settings",
type: "string",
})
.option("geo", {
alias: "geo_location",
describe: "Pass Geo Country Code",
type: "string",
})
.option("sof", {
alias: "stop_on_failure",
describe: "Stop other tests if any test in session gets errored out",
type: "bool",
})
.option("ra", {
alias: "reject_unauthorized",
describe:
"Default rejects self signed certificates in external requests",
type: "bool",
})
.option("bt", {
alias: "build-tags",
describe: "build tags",
type: "string",
})
.option("sys-envs", {
alias: "sys-env-variables",
describe: "system environment variables",
type: "string",
})
.option("npm-f", {
alias: "npm-force",
describe: "force npm install",
type: "bool",
})
.option("npm-lpd", {
alias: "legacy-peer-deps",
describe: "force npm install",
type: "bool",
})
.option("vip", {
alias: "vi-project",
describe: "visual ui project name",
type: "string",
});
},
function (argv) {
require("./commands/run")(argv);
Expand Down
Loading