setCookie() can't save object anymore
See original GitHub issueSince upgrading my Cypress to 3.6.0 I can’t set cookies that I need to set for my tests. (The application sets them as well.) I need a way to set the cookie.
Current behavior:
When using cy.setCookie()
I get the following error:
CypressError: cy.setCookie() must be passed an RFC-6265-compliant cookie value. You passed:
{"name1":"value1","name2":"value2","name3":"value3","name4":"value4","name5":"value5","name6":"value6"}
(Values have been changed for privacy reasons.)
Desired behavior:
The cookie should be set. It’s the format that is also used by our application.
Steps to reproduce: (app code and test code)
I use the following:
cy.setCookie('cookiename', cookieString, { domain: 'required.domain', });
where
cookieString = {"name1":"value1","name2":"value2","name3":"value3","name4":"value4","name5":"value5","name6":"value6"}
Versions
Cypress 3.6.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:22 (9 by maintainers)
Top Results From Across the Web
JavaScript cookie not saving - Stack Overflow
I meant if there was any errors showing up in the console when you open the page. Also, in your code why do...
Read more >setcookie - Manual - PHP
setcookie() defines a cookie to be sent along with the rest of the HTTP headers. ... This means that the cookie won't be...
Read more >Set-Cookie - HTTP - MDN Web Docs
The Set-Cookie HTTP response header is used to send a cookie from the server to the user agent, so that the user agent...
Read more >Authentication in Svelte using cookies - LogRocket Blog
Create a Svelte app using SvelteKit that implements a cookie for authentication. Build the sign up, sign in, and more.
Read more >Handling Cookies and a Session in a Java Servlet - Baeldung
This method removes the whole session from the web server so we cannot access attributes from it anymore. HttpSession object has more methods, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
there is another workaround for this:
with this method you can set your cookie in any way you need since this bypasses validations done by Cypress.
Workaround
You can suppress this error by using
cy.stub
to stub out the Cypress error function.Add the following to your specs or to your support file: