Skip to content

Commit bcd0b75

Browse files
refactor(device-manager): clean unset prop
1 parent e2db88b commit bcd0b75

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

lib/device-manager.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ export class DeviceManager implements IDeviceManager {
3535
console.log("Default device: ", device);
3636
const token = process.env["DEVICE_TOKEN"] || process.env.npm_config_deviceToken;
3737
if (token) {
38-
device.token = token;
38+
device.token = device.token.replace("emulator-", "");
3939
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;
4344
}
4445

4546
// When isSauceLab specified we simply do nothing;
@@ -164,7 +165,7 @@ export class DeviceManager implements IDeviceManager {
164165
delete args.appiumCaps.density;
165166
delete args.appiumCaps.offsetPixels;
166167

167-
Object.getOwnPropertyNames(device).forEach(prop => !device[prop] && delete device[prop]);
168+
DeviceManager.cleanUnsetProp(device);
168169

169170
return device;
170171
}
@@ -252,4 +253,8 @@ export class DeviceManager implements IDeviceManager {
252253
const appActivity = (device.type === DeviceType.EMULATOR || device.platform === Platform.ANDROID) ? AndroidController.getPackageId(appPath) : IOSController.getIOSPackageId(device.type, appPath);
253254
return appActivity;
254255
}
256+
257+
private static cleanUnsetProp(obj) {
258+
Object.getOwnPropertyNames(obj).forEach(prop => !obj[prop] && delete obj[prop]);
259+
}
255260
}

lib/image-helper.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export declare class ImageHelper {
1010
blockOutAreas: IRectangle[];
1111
imageOutputLimit(): ImageOptions;
1212
thresholdType(): ImageOptions;
13-
threshold(thresholdType: any): 0.01 | 10;
13+
threshold(thresholdType: any): 10 | 0.01;
1414
delta(): number;
1515
static cropImageDefault(_args: INsCapabilities): {
1616
x: number;

0 commit comments

Comments
 (0)