CAVEAT: This worked for Chrome not for Firefox, I didn't try Edge. I have no idea whether this will work for anyone else, but as it did for me after I looked at this very thread, I'll add it in.
I am using the more recent Cypress config format and I found that adding the browserPermissions object to the first level env variable inside the config didn't work. It does, however, appear to work if I instead add the configuration inside the e2e object:
const { defineConfig } = require('cypress');
const { cypressBrowserPermissionsPlugin } = require('cypress-browser-permissions');
module.exports = defineConfig({
// ...other configs
e2e: {
setupNodeEvents(on, config) {
config = cypressBrowserPermissionsPlugin(on, config);
config.env.browserPermissions = {
geolocation: 'allow',
};
return config;
}
}
});
NOTE: I had to stop and restart the Cypress process (restarting the browser window, as it does on save, isn't sufficient). I will also say that once I did this settings were forced and unchangeable in the browser settings page(s). So I'm not entirely sure this is how you should go about it, just that I now do not get prompted for geolocation permissions.