0
votes

I need to define set of variables and they shuldn't be mixed with environment variables. At the begining of collection set I define them

pm.globals.set('a', 1);

and clear it athe the end ot tests set

pm.globals.clear();

It works if I have consecutive set of tests. I need something like postman "collection pre-request script", but it is executed before every test. How to set some variables once before collection or folder execution?

1

1 Answers

0
votes

If you'd like to set variables at the collection level then you can define those through the collection settings: https://learning.getpostman.com/docs/postman/environments_and_globals/variables/#defining-collection-variables

If you want to run the same pre-request script for every request in a collection (or folder), that can be done from the collection/folder settings too: https://learning.getpostman.com/docs/postman/scripts/pre_request_scripts/#adding-a-pre-request-script-to-a-collection-or-folder