-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
Current behavior:
Currently only some of the config values are writable at certain points of a run and it is not clear which are and which aren't. The value simply is not read where necessary if it is not writable.
Honestly, I can't even list out which are readable and writable and when because this has never been documented. I could only guess or dig through code.
Cypress.config()
We briefly noted this in the Cypress.config() doc, but it is sadly lacking a full explanation of which are writable and which are not and when. Previous issue for this: #3422
Some confusion:
- Change
userAgentduring test Unable to switch userAgent during test run #2100
The other point of confusion is that it appears to be writable, when it's not at all! For example, the below will log the newly set value for userAgent, but it actually takes no effect on the actual userAgent set.
it('sets userAgent?', function () {
console.log(Cypress.config('userAgent'))
Cypress.config('userAgent', 'foo')
// logs foo but does absolutely nothing!
console.log(Cypress.config('userAgent'))
})- Change
screenshotsFolderduring test screenshotsFolder not working correctly #1525
The test below passes, but Cypress does not indeed change the location of the screenshotsFolder, nor does it throw an error telling you that the screenshotsFolder was not set.
it('screenshots folder not settable', () => {
Cypress.config('screenshotsFolder', 'cypress/screenshots/desktop')
expect(Cypress.config('screenshotsFolder')).to.eq('cypress/screenshots/desktop')
cy.screenshot('homepage_desktop')
})- Change
chromeWebSecurityduring test Cypress.Config() does not perform as a expected. #8160
Cypress.config('chromeWebSecurity', true); // Setting up security stuff ON
describe('Load graphql stuff Test', () => {
it('should visit dashboard', () => {
cy.visit(`stuff/${stuffId}/stuff/requests?status=0`);
cy.get('[data-testid="empty-state"]').should('exist');
});
});Actual saved screenshot location
Plugins Configuration API
Furthermore, we are expanding upon the use of the config object from within the plugins/index.js https://on.cypress.io/configuration-api - where some of this config is not writable and will not be writable at the time of run as part of #5941
This will have config values that are not writable at time that the plugin is read in like configFile and projectRoot.
Desired behavior:
- We should throw when setting these 'non-writable' config values using
Cypress.config - We should throw/warn? when setting 'non-writable' config values within the Plugins Configuration API.
Related issues
- screenshotsFolder not working correctly screenshotsFolder not working correctly #1525
- Cypress.config() does not return the complete configuration Cypress.config() does not return the complete configuration #509
- Cypress.config() inside test does not override "blacklistHosts" value Cypress.config() inside test does not override "blacklistHosts" value #7426
- Unable to switch userAgent during test run Unable to switch userAgent during test run #2100
Versions
4.0.1
