Reputation: 150624
Supposed I have a middleware for Connect and / or Express. What's the best way to unit test this middleware?
Of course, I can set up an http server in the unit tests, and load the middleware into this. But supposed that I want to test startup behavior, I need several http servers, which soon gets complicated and unclear (think of using a new port in each single test).
Is there a better way, or is testing it inside a real server the best one can come up with?
Upvotes: 10
Views: 3837
Reputation: 150624
supertest does the job, as pointed out by SLaks in the comments.
Upvotes: 9