Challenge: Testing APIs
Explore how to build effective Postman test collections for APIs, including both successful and error scenario tests. Understand how to employ Chai.js for assertions and run these using Postman and Newman to validate API responses thoroughly.
Exercise
For this exercise, you’re required to create a Postman test collection for the Credit-Check API we built previously. After creating a new collection and adding both happy- and sad-path tests, run them to validate the API.
Write the Credit-Check Postman test collection
First, fire up the Postman client and create a new collection called “Credit-Check”. Then create the following two test entries:
Happy-path: Test the home resource
- Request URL:
http://localhost:8181/