@@ -35,11 +35,12 @@ export class DeviceManager implements IDeviceManager {
35
35
console . log ( "Default device: " , device ) ;
36
36
const token = process . env [ "DEVICE_TOKEN" ] || process . env . npm_config_deviceToken ;
37
37
if ( token ) {
38
- device . token = token ;
38
+ device . token = device . token . replace ( "emulator-" , "" ) ;
39
39
device . name = process . env [ "DEVICE_NAME" ] || device . name ;
40
- const foundDevice = await DeviceController . getDevices ( { token : device . token . replace ( "emulator-" , "" ) } ) [ 0 ] ;
41
- logInfo ( "Device: " , foundDevice ) ;
42
- return foundDevice ;
40
+ DeviceManager . cleanUnsetProp ( device ) ;
41
+ device = await DeviceController . getDevices ( device ) [ 0 ] ;
42
+ logInfo ( "Device: " , device ) ;
43
+ return device ;
43
44
}
44
45
45
46
// When isSauceLab specified we simply do nothing;
@@ -164,7 +165,7 @@ export class DeviceManager implements IDeviceManager {
164
165
delete args . appiumCaps . density ;
165
166
delete args . appiumCaps . offsetPixels ;
166
167
167
- Object . getOwnPropertyNames ( device ) . forEach ( prop => ! device [ prop ] && delete device [ prop ] ) ;
168
+ DeviceManager . cleanUnsetProp ( device ) ;
168
169
169
170
return device ;
170
171
}
@@ -252,4 +253,8 @@ export class DeviceManager implements IDeviceManager {
252
253
const appActivity = ( device . type === DeviceType . EMULATOR || device . platform === Platform . ANDROID ) ? AndroidController . getPackageId ( appPath ) : IOSController . getIOSPackageId ( device . type , appPath ) ;
253
254
return appActivity ;
254
255
}
256
+
257
+ private static cleanUnsetProp ( obj ) {
258
+ Object . getOwnPropertyNames ( obj ) . forEach ( prop => ! obj [ prop ] && delete obj [ prop ] ) ;
259
+ }
255
260
}
0 commit comments