On Tue, 27 Dec 2016 07:53:36 GMT, Joshua Hodkinson wrote:

Hey guys,

I'm curious about how to approach unit testing a class being utilized in the web framework, e.g checking routes return the correct content, that auth is being check correctly, etc.

I have seen the createTestHTTPServerRequest and createTestHTTPServerResponse functions, but I'm not entirely sure how to utilize them, does anyone have examples?

Thanks

There are some simple uses in the router unit tests. If you need to send a body, you can pass a MemoryStream to createTestHTTPServerRequest (or any other stream type).

However, this API alone is not particularly convenient when doing more complex tests. There is an open pull request that attempts to implement a nicer API on top. It got stuck in a state of discussion, but should eventually become part of the library. For now, you could manually take the code there and use it for implementing the tests.