Summary
In this chapter, we explored how we can test our Strapi API, and started with a brief introduction to software testing. Then, we started setting up our environment and installed the required libraries for our test.
After we had our environment ready, we started by testing a public endpoint. We used the GET /api/classrooms
endpoint as an example and saw how we can issue an HTTP request to that endpoint and how we can assert that we are getting the expected result.
Finally, we explored how we can test a secure endpoint that requires the user to be authenticated. We created a helper function that created a user with a specific role, then we used that user to issue a JWT token. Afterward, we used the token in our tests, passing it along in the request header, and we were able to test a secure endpoint.
We have covered a variety of topics in this book; technologies, techniques, and best practices, as well as briefly touching on cloud-related topics. We do not expect anybody...