diff --git a/commands/utils/set_args.js b/commands/utils/set_args.js index 7c7c9d0..125cb54 100644 --- a/commands/utils/set_args.js +++ b/commands/utils/set_args.js @@ -434,6 +434,14 @@ function sync_args_from_cmd(args) { lt_config["run_settings"]["npm_via_tunnel"] = false; } + if ("max_duration" in args) { + lt_config["run_settings"]["max_duration"] = parseFloat(args["max_duration"]); + } else { + lt_config["run_settings"]["max_duration"] = parseFloat( + lt_config["run_settings"]["max_duration"] + ); + } + //get specs from current directory if specs are not passed in config or cli if ( (lt_config["run_settings"]["specs"] == undefined || diff --git a/commands/utils/validate.js b/commands/utils/validate.js index 1e63e0d..9db77b7 100644 --- a/commands/utils/validate.js +++ b/commands/utils/validate.js @@ -51,6 +51,20 @@ module.exports = validate_config = function (lt_config, validation_configs) { reject("Error!! Parallels value not correct"); } + //validate max duration + if ("max_duration" in lt_config["run_settings"]){ + let max_duration = lt_config["run_settings"]["max_duration"]; + if (!(max_duration == undefined || + max_duration == null || + isNaN(max_duration))) { + if (Number(max_duration) && Number(max_duration) % 1 !== 0){ + reject("Error!! max_duration should be an Integer between 2 and 240 minutes"); + }else if (parseInt(max_duration) <2 || parseInt(max_duration) > 240){ + reject("Error!! max_duration should be between 2 and 240 minutes"); + } + } + } + //Validate if package.json is having the cypress dependency var cypress_version; if (!fs.existsSync("package.json")) { diff --git a/index.js b/index.js index bbbf13f..f48519b 100644 --- a/index.js +++ b/index.js @@ -187,6 +187,11 @@ const argv = require("yargs") alias: "npm_via_tunnel", describe: "Install npm packages which are behind private VPN. Disclaimer:This will increase the build duration of your tests.", type: "bool", + }) + .option("md", { + alias: "max_duration", + describe: "stops test if it is running more than max_duration minutes.", + type: "string", }); }, function (argv) {