Users can add pre-request and test scripts to a collection, a folder, a request within a collection, or a request not saved to a collection.
In Postman, the script execution order for a single request looks like this:
For every request in a collection, scripts will execute in the following order:
For every request in a collection, the scripts will always run according to the following hierarchy: collection-level script (if any), folder-level script (if any), request-level script (if any). Note that this order of execution applies to both pre-request and test scripts.
For example, imagine you had the following collection structured with a single folder and 2 requests within the folder.
If you created log statements in the pre-request and test script sections for the collection, folder, and requests, you would clearly see the execution order in the Postman console.
Debugging scripts can be written under either the Pre-request Script tab or the Tests tab, with helpful messages logged in the Postman Console.