Writing tests in Postman
In this section, we will be implementing functional integration tests using Postman to test our API endpoints. This will test our JSON processing and database access. To do this, we will follow these steps:
- We are going to have to create a test user for our Postman tests. We can do this with the JSON body shown as follows:
{
"name": "maxwell",
"email": "maxwellflitton@gmail.com",
"password": "test"
}
- We need to add a
POST
request to thehttp://127.0.0.1:8000/v1/user/create
URL. Once we have done this, we can use our login endpoint for our Postman tests. Now that we have created our test user, we must get the token from the response header of thePOST
request to thehttp://127.0.0.1:8000/v1/auth/login
URL with the JSON request body:{
"username": "maxwell",
...