()
| 214 | } |
| 215 | |
| 216 | async function waitForResult(): Promise<RuntimeResultRow> { |
| 217 | const simulatorId = await resolveSimulatorId() |
| 218 | await ensureNativeProject() |
| 219 | await runCommand(`open`, [ |
| 220 | `-a`, |
| 221 | `Simulator`, |
| 222 | `--args`, |
| 223 | `-CurrentDeviceUDID`, |
| 224 | simulatorId, |
| 225 | ]) |
| 226 | await runCommand(`xcrun`, [`simctl`, `boot`, simulatorId]).catch(() => |
| 227 | Promise.resolve(), |
| 228 | ) |
| 229 | await runCommand(`xcrun`, [`simctl`, `bootstatus`, simulatorId, `-b`]) |
| 230 | await runCommand(`xcrun`, [`simctl`, `terminate`, simulatorId, appId]).catch( |
| 231 | () => Promise.resolve(), |
| 232 | ) |
| 233 | await runCommand( |
| 234 | `pnpm`, |
| 235 | [`exec`, `cap`, `run`, `ios`, `--target`, simulatorId, `--no-sync`], |
| 236 | { |
| 237 | cwd: appDirectory, |
| 238 | }, |
| 239 | ) |
| 240 | |
| 241 | const appDataContainer = await resolveAppDataContainer() |
| 242 | const databasePath = resolve( |
| 243 | appDataContainer, |
| 244 | `Documents`, |
| 245 | `${resultsDatabaseName}SQLite.db`, |
| 246 | ) |
| 247 | const deadline = Date.now() + 600_000 |
| 248 | |
| 249 | while (Date.now() < deadline) { |
| 250 | if (existsSync(databasePath)) { |
| 251 | const status = await readSqlScalar( |
| 252 | databasePath, |
| 253 | `SELECT status FROM test_run_results ORDER BY id DESC LIMIT 1;`, |
| 254 | ) |
| 255 | const payloadJson = await readSqlScalar( |
| 256 | databasePath, |
| 257 | `SELECT payload_json FROM test_run_results ORDER BY id DESC LIMIT 1;`, |
| 258 | ) |
| 259 | |
| 260 | if (status && payloadJson) { |
| 261 | return { |
| 262 | status: status as RuntimeResultRow[`status`], |
| 263 | payload: JSON.parse(payloadJson) as RuntimeResultRow[`payload`], |
| 264 | } |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | await new Promise((resolvePromise) => setTimeout(resolvePromise, 1000)) |
| 269 | } |
| 270 | |
| 271 | throw new Error(`Timed out waiting for native iOS e2e result`) |
| 272 | } |
| 273 |
no test coverage detected