Hi, and welcome to API Testing, SuperTest and Nock. I'm Lewis Prescott.
In this course, you will learn to:
Perform GET and POST requests using SuperTest
Learn how to inspect the JSON response
Mock API calls with Nock
SuperTest is a high level abstraction of HTTP requests, making it perfect for testing APIs.
Nock is a HTTP server mocking package, allowing us to test modules that make HTTP requests.
I will introduce these concepts and set you a couple of exercises so that you can practice what you have learned.
API testing with these tools will give you the confidence that your interactions with your backend services, all your third party integrations are constructed correctly.
If you would like to have a look at the documentation for the NPM packages we are going to use, feel free to check them out. Links have been provided in the resources section.
First thing we need to do is set up our environment.
I'll be using VS Code as my IDE for the exercises, but feel free to use the text editor of your choice.
Hopefully, you have all been through the Introduction to Mocha course with Giri.
If not, no problem.
I've provided a GitHub repository with the framework already set up.
If you'd like to set up the environment from scratch, just run:
And then install these packages:
npm install mocha chai supertest nock express