Merge pull request #5770 from jlipps/1.5

don't let getDriverForCaps blow up mysteriously on forgotten platformName
This commit is contained in:
Isaac A. Murchie
2015-10-28 08:32:25 -07:00
2 changed files with 12 additions and 1 deletions

View File

@@ -28,6 +28,10 @@ class AppiumDriver extends BaseDriver {
getDriverForCaps (caps) {
// TODO if this logic ever becomes complex, should probably factor out
// into its own file
if (!caps.platformName || !_.isString(caps.platformName)) {
throw new Error("You must include a platformName capability");
}
if (caps.platformName.toLowerCase() === "fake") {
return FakeDriver;
}
@@ -39,7 +43,8 @@ class AppiumDriver extends BaseDriver {
if (caps.platformName.toLowerCase() === 'ios') {
return IosDriver;
}
throw new Error("Could not find a driver for those caps");
throw new Error("Could not find a driver for those caps. Please double-" +
"check your platformName capability");
}
async getStatus () {

View File

@@ -123,5 +123,11 @@ describe('AppiumDriver', () => {
});
describe('sessionExists', () => {
});
describe('getDriverForCaps', () => {
it('should not blow up if user doesnt provide platformName', () => {
let appium = new AppiumDriver({});
(() => { appium.getDriverForCaps({}); }).should.throw(/platformName/);
});
});
});
});