Outline

How Tests are Run in Postman

When constructing a request in Postman, we have the ability to provide a test as part of the request which will get run when the response gets returned from the server. Tests are blocks of javascript code that get run within Postman's sandbox, which is a javascript execution environment that provides some custom helper methods for getting access to the response headers and body, and some external libraries (like Lodash) to help make tests easier to write.

Read the Postman documentation about the Sandbox

The Sandbox documentation lists which commonly used libraries have been included in the environment, along with information on how to access global/environment variables, cookies, and request/response data.

Tests are constructed by defining properties on the tests object within the environment. The name of the property will be the name of the test, and the value of the property will need to be defined as a boolean, which signals whether or not the test has passed.