Skip to content

Commit 4985cb9

Browse files
committed
fix: Hack to fix a Cannot read property 'token' of undefined error
See NativeScript/nativescript-dev-appium#142
1 parent 93bffcc commit 4985cb9

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

Diff for: generate-screenshots.js

+18-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const argv = require('yargs').argv;
22
const AppiumDriver = require('nativescript-dev-appium').AppiumDriver;
3+
const DeviceManager = require('nativescript-dev-appium').DeviceManager;
34
const fs = require('fs');
45

56
const components = [
@@ -39,13 +40,23 @@ const makeDir = (path) => {
3940
makeDir('screenshots');
4041
makeDir(`screenshots/${argv.runType}`);
4142

42-
AppiumDriver.createAppiumDriver(4723, {
43-
isSauceLab: argv.sauceLab || false,
44-
runType: argv.runType,
45-
appPath: argv.appPath, //'nativescriptvueuitests-debug.apk',
46-
appiumCaps: require('./appium.capabilities.json')[argv.runType],
47-
verbose: argv.verbose || false,
48-
})
43+
const appiumCaps = require('./appium.capabilities.json')[argv.runType];
44+
let args = {
45+
isSauceLab: argv.sauceLab || false,
46+
runType: argv.runType,
47+
appPath: argv.appPath, //'nativescriptvueuitests-debug.apk',
48+
appiumCaps: appiumCaps,
49+
verbose: argv.verbose || false,
50+
}
51+
// Hack to fix a `Cannot read property 'token' of undefined` error
52+
// See https://github.com/NativeScript/nativescript-dev-appium/issues/142
53+
if (args.isAndroid) {
54+
args.device = DeviceManager.getDefaultDevice(args, appiumCaps.avd);
55+
} else {
56+
args.device = DeviceManager.getDefaultDevice(args);
57+
}
58+
59+
AppiumDriver.createAppiumDriver(4723, args)
4960
.then(driver => run(driver))
5061
.then(() => console.log('Buh-Bye...'))
5162
.catch((err) => console.log(err));

0 commit comments

Comments
 (0)