DEV Community

Discussion on: How to preserve localStorage between Cypress tests

Collapse
 
bendavies99 profile image
Ben Davies

Does this not break the principal that all tests should be isolated units?

Collapse
 
javierbrea profile image
Javier Brea

Yes, but in my experience that principal is not fully applicable to E2E tests. I fully agree with it when talking about unit tests, but E2E tests strongly depend on the application state left by previous tests, if you don't want to perform lots of repeated actions in every test, which may result in huge testing times, and low maintainability.
I usually follow that principle for each Cypress spec file, but not for every test inside it.