-
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
perf(cy.session): keep page state after validation runs #23503
Conversation
Thanks for taking the time to open a PR!
|
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this change. It's always thrown me off when using cy.session()
that the page is reset after the validation and having to visit again. I think this works much more intuitively.
Looks good outside the very minor test comment fix 👍
.visit('/fixtures/generic.html?foo#bar') // yes (1) | ||
.visit('/fixtures/generic.html?foo#foo') // no (2) | ||
.visit('/fixtures/generic.html?bar#bar') // yes (3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.visit('/fixtures/generic.html?foo#bar') // yes (1) | |
.visit('/fixtures/generic.html?foo#foo') // no (2) | |
.visit('/fixtures/generic.html?bar#bar') // yes (3) | |
.visit('/fixtures/generic.html?foo#bar') // yes (1) | |
.visit('/fixtures/generic.html?foo#foo') // no (1) | |
.visit('/fixtures/generic.html?bar#bar') // yes (2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oof good catch: 8d0142f
(#23503)
'page navigation event (before:load)', | ||
) | ||
|
||
expect(emit.thirdCall).to.be.calledWith( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think it reads a bit more consistently with emit.getCall(2)
than emit.thirdCall
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done! 8d0142f
(#23503)
in this way, we have a problem. When some test from this spec have a redirect or visit another page, the session is broken, and local storage cleared. |
@stokrattt Can you elaborate? |
your example at the top of the page implies that in the next it I will not use cy.login? |
@skvale I don't really understand what you are trying to say. Mind sharing an example of what would be the problem? |
|
@stokrattt Thanks for providing an example. The current session is always cleared between tests - this is apart of the test isolation logic implemented in Cypress and ensuring your tests do not rely on one-another. This has been the behavior since the original release of the |
Consider this example, we have simple crawler test suite, I just wanna go over sidebar and navigate to a bunch of pages and just check page title To have this more readable I split it into several it's() to have nice report and know exactly where the page title was changed
but this won't work since each sidebar click changes the url
which is less readable |
@rkhomi This isn't the right place for this discussion since you're feedback isn't related to this change. This appears to be a similar concern as shared here: #17887 (comment) |
User facing changelog
cy.session()
command's behavior has been enhanced to no longer clear the dom after a validation function runs. This means acy.visist()
command is no longer required after runningcy.session()
when a validation function is used; instead the test to continue testing the page visited in the validation function. Addressed #22368.How has the user experience changed?
This change allow for better reusability of cy.session:
PR Tasks
cypress-documentation
?type definitions
?