Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn when writing to 'read only' properties of config #6407

Closed
jennifer-shehane opened this issue Feb 11, 2020 · 3 comments · Fixed by #18896
Closed

Warn when writing to 'read only' properties of config #6407

jennifer-shehane opened this issue Feb 11, 2020 · 3 comments · Fixed by #18896
Assignees
Labels
pkg/driver This is due to an issue in the packages/driver directory topic: plugins ⚙️ type: error message type: unexpected behavior User expected result, but got another

Comments

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Feb 11, 2020

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:

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'))
})

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')
})
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

screen shot 2019-02-11 at 11 52 28 am

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

Versions

4.0.1

@jennifer-shehane jennifer-shehane added type: unexpected behavior User expected result, but got another pkg/driver This is due to an issue in the packages/driver directory stage: ready for work The issue is reproducible and in scope topic: plugins ⚙️ type: error message labels Feb 11, 2020
@jennifer-shehane
Copy link
Member Author

Another related issue trying to overwrite Cypress.config #3422

@jennifer-shehane
Copy link
Member Author

Another strange (maybe related?) issue with trying to overwrite projectId as part of --config flag #6546

@cypress-bot cypress-bot bot added stage: product review and removed stage: needs review The PR code is done & tested, needs review stage: work in progress labels Nov 12, 2021
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review stage: work in progress and removed stage: work in progress stage: needs review The PR code is done & tested, needs review labels Nov 23, 2021
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Dec 3, 2021
@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: needs review The PR code is done & tested, needs review stage: work in progress labels Dec 6, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 21, 2021

Released in 9.2.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v9.2.0, please open a new issue.

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label Dec 21, 2021
@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Dec 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pkg/driver This is due to an issue in the packages/driver directory topic: plugins ⚙️ type: error message type: unexpected behavior User expected result, but got another
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants