How to create a setup and teardown for running test request in postman/newman?

What do you mean by “I need to cleanup my current testcases”, define “cleanup”. Do you mean clear all persisting environment variables from your last run?

If so, here’s how I’m doing something similar:

Here’s how I’m doing it:
image

Looking at the above image, I have a “Hooks: Before Each” collection folder.
What I do is, I want all the requests in that folder to run, and then it’ll go to the “[A1] Create” folder.

Once all the requests in “[A1] Create” have run, I use the setNextRequest command to go back to my “Before Each” folder which clears all environment variables so I’ll have no persisting data from previous test runs. (I also have other requests in this before each hook)

Once all the requests in the Before Each folder have run, I use setNextRequest to go to the “[A2] Overdue” folder instead of naturally going to “[A1] Create”

I keep repeating this so before a collection is run, the environment variables get cleared.
Once the 2nd to last collection has finished running “[A4] Operation: Resolve”, I go to the last collection “[AX] Done” which just clears all environment variables.

I explain this in a bit more detail: