Intro to Scripts
Postman is not only used for manual testing, but we can also do automation testing of API. Postman requests and collections can be applied to dynamic behavior.
In Postman Scripts are the lines of code that allow you to automate an API test. It offers you to write pre-request and test scripts.
In Postman, we can write the tests, pass the data between the requests, and change the parameters. It allows adding test script and pre-request script to a collection, a folder, a request, or a request not attached to a group.
To write the script in Postman, we use Postman Sandbox.
Execution Order of Scripts in Postman
In Postman, the order of script execution for a single request is as follows:
The order of script execution for every request in a collection is as follows:
The scripts should always run according to the following hierarchy for every request in a collection:
The same order will be applied for both pre-request and test scripts.