I've used nock in the past ( https://github.com/nock/nock ) to mock web requests for unit testing and ensuring that those requests are making it out with correct params etc.I'm in the position now where I need something similar but an actual webserver.Ideally something where I can define routes before each unit test and then respond to those routes with specific data / functions. I can then do a check to ensure those routes got hit in an after check.Note that I need this webserver to actually listen on a port so I can punt requests to it.Anybody got any ideas on how I could achieve this?At present I'm using mocha and then in a before function before all of the tests I bring up a http.createServer and have a bunch of static routes defined, however this is getting unwieldy, hence trying to get something to dynamically create the routes before each test.
Submitted September 05, 2020 at 02:14PM by CalBoy890
No comments:
Post a Comment