Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
log.info(`Successfully restored keychains after full reset`);
} else if (opts.keychainsExcludePatterns || opts.keepKeyChains) {
log.warn('Cannot restore keychains after full reset, because ' +
'the backup operation did not succeed');
}
} else if (opts.bundleId) {
// fastReset or noReset
// Terminate the app under test if it is still running on Simulator
// Termination is not needed if Simulator is not running
if (await device.isRunning()) {
if (opts.enforceSimulatorShutdown) {
await shutdownSimulator(device);
} else {
try {
await terminate(device.udid, opts.bundleId);
} catch (err) {
log.warn(`Reset: failed to terminate Simulator application with id "${opts.bundleId}"`);
}
}
}
if (opts.app) {
log.info('Not scrubbing third party app in anticipation of uninstall');
return;
}
const isSafari = (opts.browserName || '').toLowerCase() === 'safari';
try {
if (isSafari) {
await device.cleanSafari();
} else {
// iOS 8+ does not need basename
await device.scrubCustomApp('', opts.bundleId);
async cleanCustomApp (appFile, appBundleId, scrub = false) {
try {
await terminate(this.udid, appBundleId);
} catch (ign) {
// ignore error
}
await super.cleanCustomApp(appFile, appBundleId, scrub);
}
async cleanSafari (keepPrefs = true) {
try {
if (await this.isRunning()) {
await terminate(this.udid, MOBILE_SAFARI_BUNDLE_ID);
}
} catch (ign) {
// ignore error
}
await super.cleanSafari(keepPrefs);
}