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?
supertest does the job, as pointed out by SLaks in the comments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With