Express: an API server

Lesson 08 · 10 min

API tests with supertest

Send a real HTTP request into the app and check the response.

supertest takes app and sends requests to it without listen and without a port. You check the status, headers, and body — exactly what the client will see. HTTP-level tests catch what tests of single functions miss: a forgotten middleware, a wrong status, a leaked field.

Sign in to continue

The rest of this lesson opens after sign up

The first lesson of every course is open without an account. To read on, solve the practice and use Ask, create a free account or log in.