Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test Connect / Express middleware?

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?

like image 205
Golo Roden Avatar asked Aug 20 '13 19:08

Golo Roden


1 Answers

supertest does the job, as pointed out by SLaks in the comments.

like image 111
Golo Roden Avatar answered Nov 16 '22 21:11

Golo Roden