Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
});
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
});
// but we just care about launching simulator with chosen UDID
}
if (!fs.existsSync('ios')) {
log.info(`Generating runner iOS project`)
await generateRunner(runnerConfig)
} else {
log.info(`Re-generating runner container`)
await generateContainerForRunner(runnerConfig)
}
const device = answer.device
shell.cd(`${this.path}/ios`)
execSync(`xcodebuild -scheme ErnRunner -destination 'platform=iOS Simulator,name=${device.name}' SYMROOT="${this.path}/ios/build" build`)
await simctl.installApp(device.udid, `${this.path}/ios/build/Debug-iphonesimulator/ErnRunner.app`)
await simctl.launch(device.udid, 'com.yourcompany.ernrunner')
}
await retryInterval(5, 1000, async () => {
await simctl.launch(udid, BUNDLE_ID, 1);
});
async launchApp () {
const APP_LAUNCH_TIMEOUT = 20 * 1000;
this.logEvent('appLaunchAttempted');
await launch(this.opts.device.udid, this.opts.bundleId);
let checkStatus = async () => {
let response = await this.proxyCommand('/status', 'GET');
let currentApp = response.currentApp.bundleID;
if (currentApp !== this.opts.bundleId) {
throw new Error(`${this.opts.bundleId} not in foreground. ${currentApp} is in foreground`);
}
};
log.info(`Waiting for '${this.opts.bundleId}' to be in foreground`);
let retries = parseInt(APP_LAUNCH_TIMEOUT / 200, 10);
await retryInterval(retries, 200, checkStatus);
log.info(`${this.opts.bundleId} is in foreground`);
this.logEvent('appLaunched');
}
export async function launchApplication (deviceUdid: string, bundleId: string) {
return simctl.launch(deviceUdid, bundleId)
}