fix(mobile): fail a missing installApp path and out-of-range setLocation coordinates as INVALID_ARGUMENT
Merged
KA
3d ago+107+107+012345678901234567890123456789-10-10-01234567890123456789
What
device.installApp(path)with nothing at the path now fails withINVALID_ARGUMENT(exit 1) before any device command. The message names the path the test passed and the absolute path it resolved to.device.setLocation()with a latitude outside -90 to 90, a longitude outside -180 to 180, or a coordinate that isn't a finite number fails the same way, naming the bad value.
Why
- Both are mistakes in the test, like a typo'd build path or a swapped coordinate. agent-device refuses them with
INVALID_ARGS,translateErrormaps that toENGINE_FAILURE, and the run exits 3 as if the simulator broke. - This is the mobile side of #2039 (
setInputFileson a missing path), and it works the same way as the existingsetPermissionandpressRemoteguards. - I didn't map agent-device's
INVALID_ARGStoINVALID_ARGUMENTin general. agent-device uses that code in many places, including for requests the engine builds itself, and those shouldn't be blamed on the test.
How it works
packages/mobile/src/surface.ts:1055:installAppchecksexistsSyncon the resolved path, but only for a path the test passed. With no argument it still installs the target'sapp.appPathwithout a check. A file (.apk,.ipa) and a directory (.app) both pass.packages/mobile/src/device.ts:267:requireCoordinateschecks both coordinates before the Android "location services on" command, so a refused call changes nothing on the device.docs/reference/mobile.mdx: a Throws row for each method, and thesetLocationJSDoc copy. TheinstallApptable also saidAPP_NOT_OPENfor a missing build or areinstallwith no app, butinvalidStatethrowsINVALID_STATEthere, which is what the unit test expects. I fixed that row since the new one sits under it.
Issue
Fixes #2291
Verified
Ran it locally: yes. iPhone 17 simulator, iOS 26.5, agent-device 0.21.42, Node 24.22.3. Target app: { bundleId: 'com.apple.Preferences' }.
| test | main (1642ef238) | this PR |
|---|---|---|
device.installApp('./build/Missing.app') | ENGINE_FAILURE: install /…/build/Missing.app failed: App binary not found: /…/build/Missing.app | INVALID_ARGUMENT: device.installApp("./build/Missing.app"): no build at /…/build/Missing.app; the path resolves against the project root |
device.setLocation({ latitude: 152.5, longitude: 21.01 }) | ENGINE_FAILURE: device.setLocation failed: latitude must be a number from -90 to 90 | INVALID_ARGUMENT: device.setLocation: latitude must be a finite number from -90 to 90, got 152.5 |
device.setLocation({ latitude: NaN, … }) | same ENGINE_FAILURE | INVALID_ARGUMENT: … got NaN |
e2e run exit code | 3 | 1 |
- On the branch,
setLocation({ latitude: 52.2297, longitude: 21.0122 })followed byclearLocation()passed.installApp()of a reale2eBenchmark.appsimulator build installeddev.e2e.benchmark. - Two new unit tests in
packages/mobile/tests/unit/engine.test.tsfail on main (ENGINE_FAILURE) and pass here. They check that a refused call sends nothing to the device and that the range edges (-90, 180) still go through. The harness's project root/projectisn't on disk, so the file mocksexistsSyncto treat paths under it as present. Two existing tests now pass/project/b/App.appinstead of/b/App.app. pnpm --filter @e2e-dev/mobile test(653 passed) andpnpm checkpass.- Not run: Android on an emulator (none on this Mac). The Android
setLocationpath is covered by the unit test only.
Checklist
- Changeset added (
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only. - Breaking change: title carries
!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md). - Docs updated in the same PR: the
docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it. - Contract change: emitted
.d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures. - Engine contract change (
e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.