Cleaning session after every test: what's the purpose of multiple tests then? #21645
Replies: 3 comments 4 replies
-
By using independent tests that set up the data they need, you can avoid the situation when one of the tests fails (like "upload material") and the rest cannot run. I would also suggest reading the Best Practices guide, since it talks about the tests that rely on the state left by the previous tests https://on.cypress.io/best-practices |
Beta Was this translation helpful? Give feedback.
-
@dakur If you want to keep the session between tests, play with the
This way, the session will not be cleared between it-s. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I have to admit, I'm a bit confused about the new handling of session – clearing it every time a test function is finished – and I need some direction..
I always understood the spec file as a user scenario/journey and test functions as a features that are tested on this journey. It divided the test into labeled group which prevent big mess. Let's say:
Each test function started in the point where the previous ended (it's user journey) and continued.
Now as the session is cleared, the continuity of tests is broken and I would have to wrap all code in all functions into
cy.session()
(which doesn't seem to be fulfilling the intention of it) or squash all test functions into one which create the big mess again.My question is: am I missing something in the purpose of test functions? In which case would you use more of them? How would you deal with it?
Thank you in advance.
Beta Was this translation helpful? Give feedback.
All reactions