Skip to content

Commit 72770bb

Browse files
Throw exception when a requirment is not fullfilled
1 parent 74d11bb commit 72770bb

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

lib/capabilities-helper.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@ import * as parser from "./parser";
55

66
export function resolveCapabilities(capsLocation: string, runType: string, projectDir: string, verbose: boolean = false): {} {
77
let caps;
8-
let customCapabilitiesConfigs: any = searchCustomCapabilities(capsLocation, projectDir);
8+
let customCapabilitiesConfigs: any;
9+
if (utils.fileExists(capsLocation)) {
10+
customCapabilitiesConfigs = setCustomCapabilities(capsLocation, verbose);
11+
} else {
12+
customCapabilitiesConfigs = searchCustomCapabilities(capsLocation, projectDir);
13+
}
14+
915
if (customCapabilitiesConfigs) {
1016
const customCapabilities = JSON.parse(customCapabilitiesConfigs);
1117
utils.log(customCapabilities, verbose);
1218

1319
caps = customCapabilities[runType];
1420
if (!caps) {
15-
throw new Error("Not suitable runType!!!");
1621
}
1722
} else {
1823
throw new Error("No capabilities found!!!");

lib/ns-capabilities.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export class NsCapabilities implements INsCapabilities {
3939
this._isSauceLab = parser.isSauceLab;
4040
this._appiumCaps = resolveCapabilities(this._appiumCapsLocation, parser.runType, parser.projectDir);
4141
this.resolveAppPath();
42-
this.checkMendatoryCapabiliies()
42+
this.checkMendatoryCapabiliies();
43+
this.throwExceptions();
4344
}
4445

4546
get projectDir() { return this._projectDir; }
@@ -78,19 +79,19 @@ export class NsCapabilities implements INsCapabilities {
7879
this.exceptions.push("The application folder doesn't exist!");
7980
}
8081

81-
if (!this._appiumCaps._runType) {
82+
if (!this._runType) {
8283
this.exceptions.push("Missing runType! Please select one from appium capabilities file!");
8384
}
8485

85-
if (this._appiumCaps.platformName) {
86+
if (!this._appiumCaps.platformName) {
8687
this.exceptions.push("Platform name is missing! Please, check appium capabilities file!");
8788
}
8889

89-
if (this._appiumCaps.platformName) {
90+
if (!this._appiumCaps.platformName) {
9091
this.exceptions.push("Platform version is missing! Please, check appium capabilities file!");
9192
}
9293

93-
if (this._appiumCaps.deviceName && this._appiumCaps.uidid) {
94+
if (!this._appiumCaps.deviceName && !this._appiumCaps.uidid) {
9495
this.exceptions.push("The device name or uidid are missing! Please, check appium capabilities file!");
9596
}
9697
}

0 commit comments

Comments
 (0)