How to use node-simctl - 10 common examples

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-ios-simulator / test / functional / settings-e2e-specs.js View on Github external
before(async function () {
    udid = await simctl.createDevice('ios-simulator testing',
                                      deviceType.device,
                                      deviceType.version,
                                      {timeout: 20000});
    // just need a little more space in the logs
    console.log('\n\n'); // eslint-disable-line no-console
  });
github appium / appium-ios-simulator / test / functional / simulator-e2e-specs.js View on Github external
after(async function () {
      try {
        await killAllSimulators();
        for (const udid of _.keys(simulatorsMapping)) {
          try {
            await simctl.deleteDevice(udid);
          } catch (err) {
            console.log(`Error deleting simulator '${udid}': ${err.message}`); // eslint-disable-line
          }
        }
      } finally {
        simulatorsMapping = {};
      }
    });
    beforeEach(killAllSimulators);
github appium / appium-ios-simulator / test / functional / simulator-e2e-specs.js View on Github external
it('should find both a data and bundle directory for TestApp', async function () {
      let sim = await getSimulator(udid);
      await sim.run({startupTimeout: LONG_TIMEOUT});

      // install & launch test app
      await installApp(sim, app);
      await simctl.launch(udid, BUNDLE_ID);

      let dirs = await sim.getAppDirs('TestApp', BUNDLE_ID);
      dirs.should.have.length(2);
      dirs[0].should.contain('/Data/');
      dirs[1].should.contain('/Bundle/');

      await sim.getUserInstalledBundleIdsByBundleName('TestApp').should.eventually.not.empty;
    });
github appium / appium-ios-simulator / test / functional / simulator-e2e-specs.js View on Github external
console.log('Application installed'); // eslint-disable-line no-console

      (await sim.isAppInstalled(BUNDLE_ID)).should.be.true;

      // this remains somewhat flakey
      await retryInterval(5, 1000, async () => {
        await simctl.launch(udid, BUNDLE_ID, 1);
      });

      console.log('Application launched'); // eslint-disable-line no-console

      await sim.removeApp(BUNDLE_ID);

      // should not be able to launch anymore
      await simctl.launch(udid, BUNDLE_ID, 1)
        .should.eventually.be.rejectedWith(error);

      (await sim.isAppInstalled(BUNDLE_ID)).should.be.false;

      console.log('Test case finished'); // eslint-disable-line no-console
    });
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-remote-debugger / test / functional / safari-e2e-specs.js View on Github external
before(async function () {
    sim = await getExistingSim(DEVICE_NAME, PLATFORM_VERSION);
    if (!sim) {
      const udid = await createDevice(SIM_NAME, DEVICE_NAME, PLATFORM_VERSION);
      sim = await getSimulator(udid);
      simCreated = true;
    }
    // on certain system, particularly Xcode 11 on Travis, starting the sim fails
    await retry(4, async function () {
      try {
        await sim.run({
          startupTimeout: 60000,
        });
      } catch (err) {
        await sim.shutdown();
        throw err;
      }
    });

    const port = await startHttpServer();
github appium / appium-xcuitest-driver / test / functional / driver / webdriveragent-derived-data-path-e2e-specs.js View on Github external
before(async function () {
    const udid = await createDevice(
      SIM_DEVICE_NAME,
      translateDeviceName(UICATALOG_SIM_CAPS.platformVersion, UICATALOG_SIM_CAPS.deviceName),
      UICATALOG_SIM_CAPS.platformVersion
    );
    baseCaps = Object.assign({}, UICATALOG_SIM_CAPS, {udid});
    caps = Object.assign({
      usePrebuiltWDA: true,
      agentPath: path.join(TEMP_FOLDER, 'WebDriverAgent.xcodeproj'),
      derivedDataPath: path.join(TEMP_FOLDER, 'DerivedData', 'WebDriverAgent')
    }, baseCaps);
    // copy existing WebDriverAgent to the selected derivedDataPath folder
    const wda_path = path.join(process.cwd(), 'WebDriverAgent');
    fs.symlinkSync(wda_path, TEMP_FOLDER);
  });
  after(async function () {
github appium / appium-ios-simulator / test / functional / simulator-e2e-specs.js View on Github external
async function deleteSimulator (udid, version) {
  // only want to get rid of the device if it is present
  let devices = await simctl.getDevices();
  if (!devices[version]) {
    return;
  }
  let devicePresent = devices[version]
    .filter((device) => {
      return device.udid === udid;
    }).length > 0;
  if (devicePresent) {
    await simctl.deleteDevice(udid);
  }
}