← all posts
TIL03 Jul 2026·1 min read

supertest accepts the Express app directly, no listen() needed

I used to spin up the server in a beforeAll, pick a random port and pray CI did not collide. I found out supertest accepts the app instance directly — it binds to an ephemeral port per request on its own.

users.test.ts
undefined

The requirement: export the app separately from listen(). That split also makes serverless and load testing easier.

← back to blogBernardo Filipe · 03 Jul 2026