Closed tuzmusic closed 1 year ago
I'm not sure but looks like it doesn't allow to do that. Global browserPermissions in cypress.config.js
take over any test suite permission:
export default defineConfig({
e2e: {
...,
env: {
browserPermissions: {
geolocation: 'allow',
}
},
...
})
it(`It should work`, {
env: {
browserPermissions: {
geolocation: 'block',
}
}
}, () => {
console.log(Cypress.env()) // here geolocation is 'block' but actual permission is always 'allow' for all tests
})
})
Cypress 10.7.0 @kamranayub What am I missing here?
I don't think that will work because launchOptions
are only set when launching the browser. You can't modify launch options after it's been launched.
Instead, you could try passing the CYPRESS_
env override variable values in a separate test script you run separately. Use a different test suite and skip those suites in the other script.
For testing permissions specifically you don't need to disable them 😃 You can mock them.
See this test suite (which has permissions allowed by default at launch, but I test that when they are blocked, the UI still works):
Unless I am missing something, closing for now but definitely willing to reopen if new info comes to light (perhaps with 10.x?).
As far as I can tell from the docs, this allows you to set the permissions before your suite runs. I need the ability to set different permissions for different tests, to test the effect of those different permissions. Does this plugin allow for this?