Each of them has itâs own bodies, pre-request scripts, testsâŠ
During collection running I set some variables. In my case âcollectionVariablesâ. At the end of collection run I want to âcleanâ all variables with â pm.collectionVariables.clear();'.
My question is: Where to put this method/how to organize collection? From logical side itâs not part of any request but I need to run it somehow.
If you know that the 3rd request will always be executed last, put inside the âTestsâ this clean-up part. As an alternative you can add a dummy Clean-up request (point it to example.com or somewhere) and add there any clean-up code that you have.
It depends how you are running the collection. When automating with Newman, this is not an issue anymore.