appium-webdriveragent
Version:
Package bundling WebDriverAgent
39 lines • 1.75 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.killAllSimulators = killAllSimulators;
exports.shutdownSimulator = shutdownSimulator;
exports.deleteDeviceWithRetry = deleteDeviceWithRetry;
const lodash_1 = __importDefault(require("lodash"));
const node_simctl_1 = require("node-simctl");
const asyncbox_1 = require("asyncbox");
const appium_ios_simulator_1 = require("appium-ios-simulator");
const utils_1 = require("../../../lib/utils");
async function killAllSimulators() {
const simctl = new node_simctl_1.Simctl();
const allDevices = lodash_1.default.flatMap(lodash_1.default.values(await simctl.getDevices()));
const bootedDevices = allDevices.filter((device) => device.state === 'Booted');
for (const { udid } of bootedDevices) {
// It is necessary to stop the corresponding xcodebuild process before killing
// the simulator, otherwise it will be automatically restarted
await (0, utils_1.resetTestProcesses)(udid, true);
simctl.udid = udid;
await simctl.shutdownDevice();
}
await (0, appium_ios_simulator_1.killAllSimulators)();
}
async function shutdownSimulator(device) {
// stop XCTest processes if running to avoid unexpected side effects
await (0, utils_1.resetTestProcesses)(device.udid, true);
await device.shutdown();
}
async function deleteDeviceWithRetry(udid) {
const simctl = new node_simctl_1.Simctl({ udid });
try {
await (0, asyncbox_1.retryInterval)(10, 1000, simctl.deleteDevice.bind(simctl));
}
catch { }
}
//# sourceMappingURL=simulator.js.map