Testing an API with Supertest

Supertest hands a request straight to an Express app, with no server running and no port, so a test can check the status code, the headers and the JSON body that come back, for a GET and for a POST with a body.

By

Updated

Cheat sheet: Testing an API with Supertest
Category
Node.js
Level
Journeyman
Tags
Content-Type, End-to-End Test, nodejs, Supertest, Unit Test (unit-testing), unit testing