-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Cypress session validation failure results in a 'existingSession.setup is not a function' error #17805
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
Comments
Thanks, the However the test should still fail, that is expected. In order to prevent an endless loop if your
We should improve the error message to explain this to the user |
@bkucera disabling retries does not seem to make a difference. I understand having a validation continuously fail will ultimately cause the test to fail. I am more concerned about the setup command not being found. |
I can confirm this is an issue. It basically renders the validate function useless 😅 until this is fixed. |
Also hit this problem |
Maybe in cypress/packages/driver/src/cy/commands/sessions.ts Lines 609 to 615 in 2caa5de
We might need to omit |
Ohh, it was a little bit lower in cypress/packages/driver/src/cy/commands/sessions.ts Lines 807 to 810 in 2caa5de
Patching it to be if (serverStoredSession && serverStoredSession.setup === existingSession.setup.toString()) {
lodash__WEBPACK_IMPORTED_MODULE_0___default.a.extend(existingSession,
lodash__WEBPACK_IMPORTED_MODULE_0___default.a.omit(serverStoredSession, 'setup')); fixed my problem |
Hello @bkucera - is the change propose by Bahmutov, or another fix for this issue, planned to be introduce in an upcoming release? |
Had the same issue, any news on this ? |
Same issue here. Providing the |
In my case, since I haven't generally had sessions become invalid in the middle of the run, I can work around it by clearing all sessions at the start of the run. In before(() => {
/**
* Workaround for https://github.com/cypress-io/cypress/issues/17805
* @see https://docs.cypress.io/api/commands/session#Explicitly-clearing-sessions
*/
Cypress.session.clearAllSavedSessions()
}) |
The code for this is done in cypress-io/cypress#21226, 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
While using the new experimental feature sessions in cypress 8.2.0, adding a session validation routine does not seem to work correctly. Specifically, when a session exists, but the validation routine returns false, an error is thrown saying that the setup function does not exist.
Here is a sample block of code that can reproduce this issue:

When running this for the first time:

When re-running this test:

Desired behavior
Cypress should fail the validation, and re-run the setup function as specified in the docs. For some reason, the current code somehow loses the setup function when validation fails.
Test code to reproduce
Cypress Version
8.2.0
Other
No response
The text was updated successfully, but these errors were encountered: