-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
cy.setCookie fails when there's a __Host- prefix #8261
Comments
For anyone else with this issue, I found a temporary workaround using JavaScript to set the cookie. // TODO do this properly once they fix __Host prefix bug
document.cookie = `__Host-Username=${Cypress.env('username')};secure;path=/`; |
As stated in the MDN docs:
You'll need to pass it('set cookie', () => {
// Works
cy.setCookie('Username', 'example')
// Fails
cy.setCookie('__Host-Username', 'example')
})
it('set cookie with secure flag', () => {
// Works
cy.setCookie('__Host-Username', 'example', {
secure: true
})
}) |
I've noticed Chrome will error when a cookie starts with We should strip the domain property if we're setting a cookie that starts with Firefox doesn't have this issue |
The code for this is done in cypress-io/cypress#8526, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior:
Test fails when there's a
__Host-
prefix in the cookie name. I've attached the error log.error.log
describe('Login', () => {
it('Tries to log in', () => {
// Works
cy.setCookie('Username', 'example');
// Fails
cy.setCookie('__Host-Username', 'example');
});
The text was updated successfully, but these errors were encountered: