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

Cypress.Config() does not perform as a expected. #8160

Closed
everton-nasc opened this issue Jul 31, 2020 · 2 comments
Closed

Cypress.Config() does not perform as a expected. #8160

everton-nasc opened this issue Jul 31, 2020 · 2 comments
Labels
type: duplicate This issue or pull request already exists

Comments

@everton-nasc
Copy link

everton-nasc commented Jul 31, 2020

Type of bug / changes

I have a specific test spec scenario where I need to enable the feature chormeWebSecurity as true. By default, I've set chormeWebSecurity as false into the cypress.json file.
Most of our test should have the chrome web security disabled.
I've tried to implement the Cypress.config('chromeWebSecurity', true); but seems the command is enabling the feature, but does not perform as expected. The specific test spec has a graphql request in order to load the features on the page.

Here's the spec example:

Cypress.config('chromeWebSecurity', true); // Setting up security stuff ON
describe('Load graphql stuff Test', () => {
    before(() => {
        cy.cleanAllCookies();
        cy.checkServerStatus();
        cy.login(Cypress.env('email'), Cypress.env('password'));
    });
    beforeEach(() => {
        cy.preserveSession();
    });

    const stuffId = Cypress.env('stuffId');

    it('should visit dashboard', () => {
        cy.visit(`stuff/${stuffId}/stuff/requests?status=0`);
        cy.get('[data-testid="empty-state"]').should('exist');
    });
});

So, here's come the weirdo behaviour (benchmark):

  1. Adding Cypress.config('chromeWebSecurity', true); into the spec file seemed to work:
    Screen Shot 2020-07-31 at 12 07 45 PM
  2. Into the `cypress.json', I have the chrome we security disabled:
    Screen Shot 2020-07-31 at 12 15 22 PM
  3. The test still failing to load the element:
    Timed out retrying: Expected to find element: [data-testid="empty-state"], but never found it.
  4. Removing the entire "chromeWebSecurity": false, line from the cypress.json and the Cypress.config('chromeWebSecurity', true);, it works (but the other specs that needs the chrome feature does not work)..

*Note: Images - removed sensitive company information.

Browser benchmark:
---> The issue happens with Chrome and Edge. Removing the "chromeWebSecurity": false, from cypress.json the test will pass.
---> Electron80 and Firefox are working properly, even with "chromeWebSecurity": false, explicit into cypress.json.

Here's the browser info:

1. Chrome
  - Name: chrome
  - Channel: stable
  - Version: 84.0.4147.105
  - Executable: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
  - Profile: /Users/XPTO/Library/Application Support/Cypress/cy/production/browsers/chrome-stable

2. Edge
  - Name: edge
  - Channel: stable
  - Version: 84.0.522.49
  - Executable: /Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge
  - Profile: /Users/XPTO/Library/Application Support/Cypress/cy/production/browsers/edge-stable

3. Firefox
  - Name: firefox
  - Channel: stable
  - Version: 79.0
  - Executable: /Applications/Firefox.app/Contents/MacOS/firefox-bin
  - Profile: /Users/XPTO/Library/Application Support/Cypress/cy/production/browsers/firefox-stable

Cypress Version: 4.11.0
Local Environment and CI has the same issue.

macOS Mojave - Version 10.14.6

@jennifer-shehane
Copy link
Member

This repo is only for issues relating to Cypress documentation. If you want to open an issue on our main project, you can open it here. This issue will be moved to our main repo.

@jennifer-shehane jennifer-shehane transferred this issue from cypress-io/cypress-documentation Aug 3, 2020
@jennifer-shehane
Copy link
Member

Changeing the chromeWebSecurity property requires that the browser restart - so this value is readonly in Cypress.config() and cannot be changed mid-test.

Duplicate of #6407

You could setup this specific test in a single specfile by itself and run it individually with this config.

cypress run --specs=my-special-file.js --config chromeWebSecurity=true
cypress run --specs=**/allotherspecs** --config chromeWebSecurity=false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants