REST API testing using JS

Photo by Nathan Anderson on Unsplash

Required tools

  • request.js — a great HTTP client, that covers 99.9% of API testing needs. It’s easy to use, fast and very functional
  • mocha — a simple and fun testing framework :)
  • chai — BDD / TDD assertion library

Endpoint test suite example

  • POST — for creating a new user
  • GET — for getting the list of created users
  • GET — for getting the user with specified id
  • PUT — for editing user
  • DELETE — for deleting user

Endpoint tests example

  1. Prepare request data (if needed)
  2. Make request
  3. Check response

Test run reports and CI / CD integration

  • If all tests are passed, the QA team receives notification that the build was successful and further testing/release tasks can be done.
  • If some tests are failed, the Dev team receives notification, with all the needed information (environment, logs, test results etc.)

Summary

--

--

--

QA Lead. Love Ukraine, my Family, Javascript and Quality Products.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrii Ievtukhov

Andrii Ievtukhov

QA Lead. Love Ukraine, my Family, Javascript and Quality Products.

More from Medium

Testing with Jest

4 software testing myths you should debunk | Agilitest blog

WebElementFacade In Serenity and WebElement In Selenium

WebElementFacade In Serenity selenium, Serenity vs WebElement In Selenium

Test Ideas — Input Methods