bahmutov / cypress-data-session

Cypress command for flexible test data setup

Home Page:https://glebbahmutov.com/blog/cypresss-data-session/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cleanup feature

muratkeremozcan opened this issue · comments

Best to explain the request with an example from a sample repo.

https://github.com/muratkeremozcan/appsyncmasterclass-backend/tree/main/cypress/e2e

The 3 spec files image-upload, tweet, user-profile all spin up a random user and get a token with it. At the end of each spec the user is cleaned up.

This would be a great use case for data session, however we have to delete the user at the end of each spec. If there was a feature to delete the user once, at the end, after all the specs have run, data-session would be more meaningful.

In theory we could try something in an after block in the e2e.ts, but that would require wrangling the variable, which would then also mean a before block would be necessary in the same file. You can imagine how that will be a mess to maintain with JS, multiple files, and common hooks in the e2e ts file. What if not every test requires these, for example the test confirm-user-signup in the repo? All this would be resolved if we could instead deal with the session for cleanup.