Managing variables in Postman tests
In Chapter 9, Testing Our Application Endpoints and Components, we built a Postman collection. However, it was a bit ropey as we had to rely on Python to load the new token into the Newman collection. While this was important to use as using Python as glue code between processes is a useful skill, our old version of readying a Newman collection with Python is not the cleanest approach. At the start of our collection, we will add two new requests. The first one will create a user with the following parameters:
Figure 13.1 – Create user Postman request
With the create user request, we get the following JavaScript in the Tests tab in Postman:
pm.test("response is created", function () { pm.response.to.have.status(201); });
With this, the first request of our collection will create the user and throw an error if the request was not successful. Then, we can create the second...