Created
March 16, 2020 02:06
-
-
Save jamesfulford/5017e15fe6797b7542262c0b97ae1037 to your computer and use it in GitHub Desktop.
Cypress: Mock Geolocation API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cypress.Commands.add('mockGeolocation', (latitude, longitude) => { | |
cy.window().then(($window) => { | |
cy.stub($window.navigator.geolocation, 'getCurrentPosition', (callback) => { | |
return callback({ coords: { latitude, longitude } }); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment