Location
Test geofences, run trackers and location-gated screens with a GPS point, a route or a GPX file played at a speed, from a spec or a suite.
device.location sets the fix the app gets from the platform's location service, so plain expo-location or CLLocationManager code sees it. A route plays fixes at a speed, which is how a geofence or a run tracker gets exercised.
await device.location.set({ lat: 37.3349, lon: -122.009 });
await device.location.route(
[{ lat: 37.3398, lon: -122.009 }, { lat: 37.3349, lon: -122.009 }, { lat: 37.33, lon: -122.009 }],
{ speedMps: 40, intervalS: 1 },
);
await device.location.route({ gpx: "fixtures/commute.gpx" });
await device.location.scenario("city-run"); // "city-run" | "city-bike" | "freeway"
await device.location.clear();| Call | Does |
|---|---|
set({ lat, lon, altM? }) | a point |
route(points | { gpx }, { speedMps?, intervalS?, loop? }) | waypoints, or a GPX file (relative to the working directory), played at a speed. loop is Android only |
scenario(name) | one of the bundled routes |
clear() | iOS clears the simulated location. Android stops the ticker and keeps the last fix (the emulator console cannot unset one) |
Grant the permission up front so the app reads the fix without a prompt: device.permissions.set({ location: "granted" }) (Permissions).
In a suite
conditions: { location: "city-run" },location takes { lat, lon, altM? } or a scenario name. Every spec starts from it.
How a route plays per platform, limitations and warden ui location: Location on a simulator.