Test Examples
As we understood from the previous section, Test scripts are executed after a request has been sent, and the server has received a response.
Here, we will discuss some examples of tests. Most of the examples are available in the snippets of the Postman. We can run multiple tests for a single request.
Environments
Setting an Environment Variable
We can also set a nested object as an environment variable:
Getting an Environment Variable
Clear an Environment Variable
Collection
Setting a Collection Variable
Get a Collection Variable
Clear a Collection Variable
Globals
Setting a Global Variable
Getting a Global Variable
Clear a Global Variable
Response Handling
Search for a String in Response Body
Check if Response Body is equal to a String
Check for a JSON Value
Check if Content-Type header is present
Response Time is less than 200 ms
Status code is 200
Code name contains a string
Successful POST request status code