This post will go over how I set up an integration/unit test runner in Postman. The API I will be using is one I made personally and represents a system of bikes, riders, routes, trips, rider packs with its own authentication and roles/permissions system in place.
There are over 30 endpoints, so in this example I’ll be testing 4 endpoints only. These will be /pack (GET), /pack (POST), /pack (DELETE), and /auth/login (POST). What I want to test is a simple flow;
The test for this route will check if it was successful, was completed under acceptable timing and contains a “results” key in the JSON body.
This test will check if the user can create a new pack successfully and within acceptable time. Only authenticated users should be able to use this call successfully.
Lastly I setup a test for the /pack (DELETE) route. This one will expect to fail, even with authentication. This is because the role of the user only has permission to create, view and update /packs. They do not have permission to delete content.