I'm trying to run Cypress at CI for several different browsers, including Chrome and Edge. Several tests fail because they're supposed to stub notification requests sent by the website, but the browser doesn't yet have the permission to send notification alerts to the user.
My code in cypress.config.js is as follows, based on the code in Cypress' documentation:
const { defineConfig } = require('cypress')
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
on('before:browser:launch', (browser, launchOptions) => {
switch(browser.family) {
case 'firefox':
launchOptions.preferences.['permissions.default.desktop-notification'] = 1;
break;
case 'chromium':
launchOptions.preferences.default['profile.default_content_settings_values.notifications'] = 1;
launchOptions.preferences.default['profile.managed_default_content_settings.notifications'] = 1;
break;
}
}
return launchOptions;
})
}
}
})
Expected result: In both Firefox and Chromium browsers, the user is not asked to enable notifications, as it should be enabled beforehand.
Actual result: Firefox works as expected, but Chromium browsers still require user interaction to enable notifications.
I've tried looking at other similar questions such as this one (where I got default_content_settings_values from), as well as taking a look at the code in this repo to ensure I have the correct preference names, but to little avail.