-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Whitelisted cookies preserved over runs, clearCookies() does not clear whitelisted cookies #808
Comments
This session / cookie handling is the worst part of Cypress right now. The API's are horrible, its not explained anywhere, and it's the opposite of what users expect. This issue goes into a lot more detail about it #686 We will not fix the existing Cookie API's and we will instead opt to fix it more comprehensively as outlined above. I'll keep this issue open as a reference in the mean time. |
Also if you want to clear a cookie even if its been preserved you can just do That will blow it away no matter what. |
Thanks Brian! I was a bit unsure whether I was really missing something, but your answer clarifies. I'll keep track of #686. Furthermore just wanted to share that Cypress.io is just amazing - I am just really enthusiastic about it and spreading the message here at the office. It really helps while developing; which is what I try to use it mainly for currently. |
Going to close this then - its referenced in the other issue now. |
On When I try to change defaults to empty array or undefined, still wont delete the cookie.. Cypress.Cookies.defaults({
whitelist: [] / undefined
}); Any other ideas?? Thanks |
And here is my workaround to clear cookies that are set using it("Clear browser cookies and localstorage", function(){
//Visit URL
const host_url = Cypress.env('host_url');
cy.visit(host_url)
// Empty defaults
Cypress.Cookies.defaults({
whitelist: []
});
//Clear localStrage
cy.clearLocalStorage()
//Clear Cookies
cy.clearCookies()
// Set defaults
Cypress.Cookies.defaults({
whitelist: /wordpress_.*|woocommerce_.*|wp_woocommerce_.*/
})
}) |
We released If you have any feedback about |
Operating System:
OSX 10.12.5
Cypress Version:
Cypress package version: 1.0.2
Cypress binary version: 1.0.2
Browser Version:
Canary 64
Is this a Feature or Bug?
Bug
Current behavior:
Having the following test code:
In the current phase my tests keeps failing, because the first run logs in and because I preserve the cookie, it is persisted throughout every test that runs.
Technically I'm not able to clear cookies between runs/during tests.
Desired behavior:
Few suggestions :)
How to reproduce:
Use the above code, start coding on the test and press Save. Cypress will run the test, but preserve the whitelisted cookie even though it says 'clearCookies()'. Also when you use the 'Run all tests'.
Test code:
See above :)
Additional Info (images, stack traces, etc)
The text was updated successfully, but these errors were encountered: