-
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
Cypress does not clear cookies
and localStorage
on startup when testIsolation
is false
#28935
Comments
How are you closing the test in this case?
|
@jennifer-shehane I tried both closing Chrome and Cypress "normally" and also doing a This is even worse for cookies that are set by API calls ( |
Just to clarify, this issue only occurs when using before(() => {
console.log('getAllCookies')
cy.getAllCookies()
.then((cookies) => {
console.log(`inside getAllCookies`)
console.dir(cookies, { depth: null })
})
.then(() => {
cy.clearAllCookies().then(() => {
console.log(`after clearAllCookies`)
})
})
.then(() => {
cy.getAllCookies().then((cookies) => {
console.log(`inside getAllCookies (after clearAllCookies)`)
console.dir(cookies, { depth: null })
})
})
.then(() => {
cy.visit(`/`)
})
.then(() => {
cy.getAllCookies().then((cookies) => {
console.log(`inside getAllCookies (after visiting page)`)
console.dir(cookies, { depth: null })
})
})
.then(() => {
throw new Error('stop')
})
}) Of course, in this example, visiting Now, if I stop Cypress, and restart it and run the same test again: We can see that even at startup, before visiting any page, it still has a cookie. I tried closing Cypress by quitting Chrome and Cypress, by using the "Close" button in the Cypress app, and using I think it would be expected that when Cypress starts, it clears all cookies and local storage without having to do it manually or without having to use sessions or test isolation. Otherwise, this means that if any test fails and we restart Cypress, the previous browser state will be persisted, and it's impossible to guarantee reliable tests. Right now, I am planning to use session as a workaround, but I still think that this behavior is probably not expected. I'm also updating the issue with those new details for clarity. |
cookies
and localStorage
on startup when testIsolation
is false
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided. |
This issue has been closed due to inactivity. |
Current behavior
I am starting tests, and I would expect that when launching Chrome is starts without any cookies (and local storage) but it keeps the same infromation as the previous test run.
This issue only seems to happen when setting
testIsolation
tofalse
since otherwisecookies
andlocalStroage
will be cleared before every test.Desired behavior
I would expect that when launching Cypress, the environment starts without any state from previous test runs.
Test code to reproduce
Just install the latest Cypress version, run test on an application that has cookies. Close the test, re-open Cypress and inspect your cookies.
Cypress Version
latest
Node version
v20.5.0
Operating System
macOS 14.2.1
Debug Logs
No response
Other
No response
The text was updated successfully, but these errors were encountered: