Cypress · Middle · Question 65 of 77
How do you test geolocation-based features in Cypress?
- 1Use the
--geoflag oncypress run - 2Set the CI machine's location in the BIOS
- 3Stub
navigator.geolocationinonBeforeLoad
Show the answer
Correct answer: Stub navigator.geolocation in onBeforeLoad
Explanation
Stubbing getCurrentPosition to call back with fixed coordinates makes the test deterministic.