cypress: Cookie regression issue in 3.5.0 has not been resolved in 3.6.0

Current behavior:

Like in 3.5.0, the cookie cannot be set in the chrome browser when running cypress.

Desired behavior:

Like in 3.4.1, the cookie can be set in the chrome browser when running cypress.

Steps to reproduce: (app code and test code)

Cypress.Commands.add('adminLogin', ($user, $legacy) => {
	if ($legacy == null) {
		cy.setCookie('UI', 'admin_ui');
	}
	cy.visit('/');
	cy.get('#login_username').type($user.username);
	cy.get('#login_password').type($user.password);
	cy.get('[data-testid=login]').click();
});

//Log into admin
cy.adminLogin(admin);

Versions

3.6.0, Linux mint, chrome

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 29 (11 by maintainers)

Most upvoted comments

@flotwig Much appreciated. However, I don’t believe the issue is fixed. Previously in 3.4.1, I was able to set cookies with no issue. =>

cy.setCookie('UI', 'admin_ui');

Currently, in order to get around this, I need to specify the domain in the options.= >

cy.setCookie('UI', 'admin_ui', { domain: Cypress.env("domain") });

I have the same problem. It works correctly when I use cypress on my local project. But we have also pre-built instance and cypress can’t create cookies there. 3.4.1 works fine. 3.5.0 and 3.6.0 have this problem // windows 10 pro and chrome

@stevemckenzie at this point, it would be most helpful if you could provide a reproducible example of the bug that I can run locally. Unfortunately, my attempts to build one based off of the info in this issue have not been successful.

Feel free to contact me via the email on my profile if your source code is private but you’d like to share it to help reproduce this.

Thank you Zach! For me, the issue is resolved in 3.8.0

Hi people still experiencing issues with cookies in Cypress 3.7.0,

I’ve isolated & fixed a bug introduced in 3.5.0 which makes it so that explicit cookie headers set on cy.visit and cy.request do not work as expected, please check out this issue to see if it matches what you are experiencing: https://github.com/cypress-io/cypress/issues/5894

Hey @jcheo1 and others in this thread, version 3.7.0 of Cypress has been released with some fixes for cookie behavior. Please try it out and see if it fixes your issue.

We are using XSRF-TOKEN in combination with cookies. Since 3.5.0 this is not working any more. Not fixed in 3.6.0, not fixed in 3.6.1 So back to cypress 3.4.1 😦

    const options = {
           method: 'DELETE',
           url: 'api/v1/something-something-something',
           headers: {
             'X-XSRF-TOKEN': 'test123',
             cookie: 'DWD_JWT_TOKEN=' + cookie.value + ';XSRF-TOKEN=test123'
           },
           failOnStatusCode: false
         };
         cy.request(options);