How to use the node-simctl.getDevices function in node-simctl

To help you get started, we’ve selected a few node-simctl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github appium / appium-xcuitest-driver / lib / simulator-management.js View on Github external
async function shutdownOtherSimulators (currentDevice) {
  const allDevices = _.flatMap(_.values(await getDevices()));
  const otherBootedDevices = allDevices.filter((device) => device.udid !== currentDevice.udid && device.state === 'Booted');
  if (_.isEmpty(otherBootedDevices)) {
    log.info('No other running simulators have been detected');
    return;
  }
  log.info(`Detected ${otherBootedDevices.length} other running Simulator${otherBootedDevices.length === 1 ? '' : 's'}.` +
           `Shutting ${otherBootedDevices.length === 1 ? 'it' : 'them'} down...`);
  for (const {udid} of otherBootedDevices) {
    // It is necessary to stop the corresponding xcodebuild process before killing
    // the simulator, otherwise it will be automatically restarted
    await resetTestProcesses(udid, true);
    await shutdown(udid);
  }
}
github appium / appium-xcuitest-driver / test / functional / helpers / simulator.js View on Github external
async function killAllSimulators () {
  if (process.env.CLOUD) {
    return;
  }

  const allDevices = _.flatMap(_.values(await 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 resetTestProcesses(udid, true);
    await shutdown(udid);
  }
  await simKill();
}
github appium / appium-xcuitest-driver / lib / simulator-management.js View on Github external
async function getExistingSim (opts) {
  let appiumTestDevice;

  for (const device of _.values(await getDevices(opts.platformVersion))) {
    if (device.name === opts.deviceName) {
      return await getSimulator(device.udid, {
        platform: device.platform,
        checkExistence: false,
      });
    }

    if (device.name.startsWith(APPIUM_SIM_PREFIX) && device.name.endsWith(opts.deviceName)) {
      appiumTestDevice = device;
      // choose the first booted simulator
      if (device.state === 'Booted') {
        break;
      }
    }
  }
github appium / appium-ios-simulator / lib / utils.js View on Github external
async function getSimulatorInfo (udid) {
  // see the README for github.com/appium/node-simctl for example output of getDevices()
  let devices = await getDevices();

  devices = _.toPairs(devices)
    .map((pair) => pair[1])
    .reduce((a, b) => a.concat(b), []);
  return _.find(devices, (sim) => sim.udid === udid);
}
github appium / appium-remote-debugger / test / functional / safari-e2e-specs.js View on Github external
async function getExistingSim (deviceName, platformVersion) {
  const devices = await getDevices(platformVersion);

  for (const device of _.values(devices)) {
    if (device.name === deviceName) {
      return await getSimulator(device.udid);
    }
  }

  return null;
}
github electrode-io / electrode-native / ern-local-cli / src / lib / miniapp.js View on Github external
throw new Error('react-native-code-push is required for iOS runner :(')
    }

    const runnerConfig = {
      platformPath: Platform.currentPlatformVersionPath,
      plugins: this.nativeDependencies,
      miniapp: {name: this.name, localPath: this.path},
      outFolder: `${this.path}/ios`,
      headless: this.isHeadLess,
      platform: 'ios',
      containerGenWorkingFolder: `${Platform.rootDirectory}/containergen`,
      pluginsConfigurationDirectory: Platform.pluginsConfigurationDirectory,
      reactNativeAarsPath: `${Platform.manifestDirectory}/react-native_aars`
    }

    const iosDevices = await simctl.getDevices()
    let iosDevicesChoices = _.filter(
                                    _.flattenDeep(
                                       _.map(iosDevices, (val, key) => val)
                                        ), (device) => device.name.match(/^iPhone/))
    const inquirerChoices = _.map(iosDevicesChoices, (val, key) => ({
      name: `${val.name} (UDID ${val.udid})`,
      value: val
    }))

    const answer = await inquirer.prompt([{
      type: 'list',
      name: 'device',
      message: 'Choose iOS simulator',
      choices: inquirerChoices
    }])
    try {
github appium / appium-ios-simulator / lib / utils.js View on Github external
async function allSimsAreDown () {
    remainingDevices = [];
    let devices = await getDevices();
    devices = _.flatten(_.values(devices));
    return _.every(devices, (sim) => {
      let state = sim.state.toLowerCase();
      let done = state === 'shutdown' ||
                 state === 'unavailable' ||
                 state === 'disconnected';
      if (!done) {
        remainingDevices.push(`${sim.name} (${sim.sdk}, udid: ${sim.udid}) is still in state '${state}'`);
      }
      return done;
    });
  }
  try {
github appium / appium-ios-simulator / lib / simulator-xcode-6.js View on Github external
async stat () {
    for (let [sdk, deviceArr] of _.toPairs(await simctl.getDevices())) {
      for (let device of deviceArr) {
        if (device.udid === this.udid) {
          device.sdk = sdk;
          return device;
        }
      }
    }

    return {};
  }
github niklasvh / html2canvas / karma.conf.js View on Github external
this.on('start', url => {
            simctl.getDevices().then(devices => {
                const d = devices[args.sdk].find(d => {
                    return d.name === args.name;
                });

                if (!d) {
                    log.error(`No device found for sdk ${args.sdk} with name ${args.name}`);
                    log.info(`Available devices:`, devices);
                    this._process.kill();
                    return;
                }

                return iosSimulator.getSimulator(d.udid).then(device => {
                    return simctl.bootDevice(d.udid).then(() => device);
                }).then(device => {
                    return device.waitForBoot(60 * 5 * 1000).then(() => {
                        return device.openUrl(url);
github electrode-io / electrode-native / ern-util / src / ios.js View on Github external
export async function getiPhoneSimulators () {
  const iosSims = await simctl.getDevices()
  return _.filter(
           _.flattenDeep(
             _.map(iosSims, (val, key) => val)),
        (device) => device.name.match(/^iPhone/))
}