Skip to content

Commit

Permalink
AppleSimUtils: wrap open Simulator command with try-catch.
Browse files Browse the repository at this point in the history
  • Loading branch information
asafkorem committed Apr 11, 2022
1 parent b40eef7 commit ec81636
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions detox/src/devices/common/drivers/ios/tools/AppleSimUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class AppleSimUtils {
await this._execSimctl({ cmd: `bootstatus ${udid}`, retries: 1 });

if (!headless) {
await this._openSimulatorApp();
await this._openSimulatorApp(udid);
}

return true;
Expand All @@ -79,8 +79,20 @@ class AppleSimUtils {
return device;
}

async _openSimulatorApp() {
await childProcess.execWithRetriesAndLogs(`open -a Simulator.app`, { retries: 0 });
async _openSimulatorApp(udid) {
try {
await childProcess.execWithRetriesAndLogs(`open -a Simulator --args -CurrentDeviceUDID ${udid}`, { retries: 0 });
} catch (err) {
this._logUnableToOpenSimulator(err);
}
}

_logUnableToOpenSimulator(err) {
log.warn(
`Unable to open the Simulator app. If you are running tests from CI, consider running them with "--headless" ` +
`device configuration (see: https://wix.github.io/Detox/docs/next/api/configuration/#device-configurations).\n` +
`Error received: ${err.toString()}.`
);
}

/***
Expand Down

0 comments on commit ec81636

Please sign in to comment.