'MockGeolocation API did not show the "Allow location" popup on browser

I have created the test scripts where in Mock Geolocation API is supposed to be used. The code did not populate the "Allow location" popup. Here's the snippet:

  "navigator.geolocation.getCurrentPosition = success =>  success({ coords: { latitude: 30, 
 longitude: -105, }, timestamp: Date.now() });";

 fixture`blah`.page`google.com`.clientScripts({
  content: mockGeolocationScript,
});

Am I missing something?



Solution 1:[1]

You are right, the "Allow location" dialog doesn't appear when the test is running because it's a native dialog, so the TestCafe framework cannot process it. This behavior is correct.

You correctly mocked the "navigator.geolocation.getCurrentPosition" function, so it should return your mocked data during test execution.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dmitry Os