Cypress session validation failure results in a 'existingSession.setup is not a function' error
See original GitHub issueCurrent 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
it('fails the session setup on the second run', () => {
var validateFlag = false
cy.session('test', () => {
validateFlag = true
cy.log('setup')
},
{
validate() {
cy.log('validate')
if (validateFlag) {
return true
}
else {
return false
}
},
})
});
Cypress Version
8.2.0
Other
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:10
- Comments:14 (5 by maintainers)
Top Results From Across the Web
session - Cypress Documentation
If validation fails after restoring a session, setup will re-run. ... Run any Cypress command that fails if the user is not logged...
Read more >Test fail when using Cypress session - Stack Overflow
After I execute the code, I always got an error: (uncaught exception) TypeError: Cannot read properties of null (reading 'style') TypeError The ...
Read more >End-to-End Testing with Cypress and Auth0
Learn how to programmatically authenticate against Auth0 in your Cypress tests in a manner that adheres to both Cypress and Auth0 best practices....
Read more >Flexible Cypress Data Setup And Validation - Gleb Bahmutov
Setting up, caching, and re-creating the test data using cypress-data-session plugin. This post will introduce you to a very powerful way of ...
Read more >Dependents (89) - @okta/okta-auth-js - npm
The Okta Auth SDK. Latest version: 7.0.1, last published: 10 days ago. Start using @okta/okta-auth-js in your project by running `npm i ...
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 FreeTop 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
Top GitHub Comments
Same issue here. Providing the
validate
function is useless until this is fixed. I know this is an experimental feature (and a great one at that!) but would love this issue prioritized 😃 Thanks!Hello @Bkucera - is the change propose by Bahmutov, or another fix for this issue, planned to be introduce in an upcoming release? Thank you, Alex