with tools and examples

Photo by Nathan Anderson on Unsplash

Required tools

To set up API testing functionality we’ll need:

  • mocha — a simple and fun testing framework :)
  • chai — BDD / TDD assertion library

Endpoint test suite example

As you may know, each REST API endpoint can have different methods, applied to it.

  • GET — for getting the list of created users
  • PUT — for editing user
  • DELETE — for deleting user

Endpoint tests example

Each API test is always easy to implement because most of the time it’s just about 3 operations:

  1. Make request
  2. Check response

Test run reports and CI / CD integration

CI integration is as easy as possible :)

  • If some tests are failed, the Dev team receives notification, with all the needed information (environment, logs, test results etc.)

Summary

In this article, I’ve shown you an example of how REST API testing can be performed using JS and its free tools.

QA Lead. Love My Family, JavaScript and Quality Products

QA Lead. Love My Family, JavaScript and Quality Products