How to use the node-simctl.spawn 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-ios-simulator / lib / simulator-xcode-6.js View on Github external
throw new Error(`The keychains backup archive does not exist. ` +
                      `Are you sure it was created before?`);
    }

    if (_.isString(excludePatterns)) {
      excludePatterns = excludePatterns.split(',').map((x) => x.trim());
    }
    const {state} = await this.stat();
    const isServerRunning = state === 'Booted';
    let plistPath;
    if (isServerRunning) {
      plistPath = path.resolve(await this.getLaunchDaemonsRoot(), 'com.apple.securityd.plist');
      if (!await fs.exists(plistPath)) {
        throw new Error(`Cannot clear keychains because '${plistPath}' does not exist`);
      }
      await simctl.spawn(this.udid, ['launchctl', 'unload', plistPath]);
    }
    try {
      await fs.rimraf(this.keychainPath);
      await mkdirp(this.keychainPath);
      const unzipArgs = [
        '-o', this._keychainsBackupPath,
        ...(_.flatMap(excludePatterns.map((x) => ['-x', x]))),
        '-d', '/'
      ];
      log.debug(`Restoring keychains with 'unzip ${unzipArgs.join(' ')}' command`);
      await exec('unzip', unzipArgs);
      await fs.unlink(this._keychainsBackupPath);
      this._keychainsBackupPath = null;
    } finally {
      if (isServerRunning && plistPath) {
        await simctl.spawn(this.udid, ['launchctl', 'load', plistPath]);
github appium / appium-ios-simulator / lib / simulator-xcode-6.js View on Github external
async clearKeychains () {
    const plistPath = path.resolve(await this.getLaunchDaemonsRoot(), 'com.apple.securityd.plist');
    if (!await fs.exists(plistPath)) {
      throw new Error(`Cannot clear keychains because '${plistPath}' does not exist`);
    }
    await simctl.spawn(this.udid, ['launchctl', 'unload', plistPath]);
    try {
      if (await fs.exists(this.keychainPath)) {
        await fs.rimraf(this.keychainPath);
        await mkdirp(this.keychainPath);
      }
    } finally {
      await simctl.spawn(this.udid, ['launchctl', 'load', plistPath]);
    }
  }
github appium / appium-ios-simulator / lib / simulator-xcode-8.js View on Github external
async shake () {
    log.info(`Performing shake gesture on ${this.udid} Simulator`);
    await spawn(this.udid, [
      'notifyutil',
      '-p', 'com.apple.UIKit.SimulatorShake'
    ]);
  }
github appium / appium-ios-simulator / lib / simulator-xcode-9.js View on Github external
async isBiometricEnrolled () {
    const {stdout} = await spawn(this.udid, [
      'notifyutil',
      '-g', ENROLLMENT_NOTIFICATION_RECEIVER
    ]);
    const match = (new RegExp(`${_.escapeRegExp(ENROLLMENT_NOTIFICATION_RECEIVER)}\\s+([01])`))
      .exec(stdout);
    if (!match) {
      throw new Error(`Cannot parse biometric enrollment state from '${stdout}'`);
    }
    log.info(`Current biometric enrolled state for ${this.udid} Simulator: ${match[1]}`);
    return match[1] === '1';
  }
github appium / appium-ios-simulator / lib / simulator-xcode-9.js View on Github external
async enrollBiometric (isEnabled = true) {
    log.debug(`Setting biometric enrolled state for ${this.udid} Simulator to '${isEnabled ? 'enabled' : 'disabled'}'`);
    await spawn(this.udid, [
      'notifyutil',
      '-s', ENROLLMENT_NOTIFICATION_RECEIVER, isEnabled ? '1' : '0'
    ]);
    await spawn(this.udid, [
      'notifyutil',
      '-p', ENROLLMENT_NOTIFICATION_RECEIVER
    ]);
    if (await this.isBiometricEnrolled() !== isEnabled) {
      throw new Error(`Cannot set biometric enrolled state for ${this.udid} Simulator to '${isEnabled ? 'enabled' : 'disabled'}'`);
    }
  }
github appium / appium-ios-simulator / lib / simulator-xcode-9.js View on Github external
async sendBiometricMatch (shouldMatch = true, biometricName = 'touchId') {
    const domainComponent = toBiometricDomainComponent(biometricName);
    const domain = `com.apple.BiometricKit_Sim.${domainComponent}.${shouldMatch ? '' : 'no'}match`;
    await spawn(this.udid, [
      'notifyutil',
      '-p', domain
    ]);
    log.info(`Sent notification ${domain} to ${shouldMatch ? 'match' : 'not match'} ${biometricName} biometric ` +
      `for ${this.udid} Simulator`);
  }