MΓ³dulo 12 Β· Testing the API β LecciΓ³n 2 de 3 Β· ~9 min
End-to-end tests with Supertest
The thin cap: prove the wiring end to end
Unit tests proved the logic. But do the pieces connect? Does GET /walkers actually route to the controller, run the guard, call the service, and serialize JSON? That's what a single e2e test earns its keep proving β the wiring you can't see from any one unit.
The tool is Supertest, and the trick is that it needs no real port. You boot the Nest app in memory, hand Supertest the app's underlying HTTP server object, and it fires requests straight at it. No app.listen(3000), no sockets, no 'port already in use' flakiness β just a fast, real request through the whole stack.