might be able to do something using benchmark js but tbh i havent had the best of luck with that lib when I had tried it before a couple of times, i wasn’t quite sure i was getting completely correct results compared to my own custom written benchmarking / timing. but maybe i was mistaken.
and that was only really to benchmark actual code / functions
Bojan
@bojand
Forgot about this lib but could probably be pretty useful to just roll your own test
Good morning. Is there any guidance, or recommended patterns on how to test services written using Mali?
Bojan
@bojand
hello, depends on the context. strictly speaking normally in your setup you can just create your app and start it on OS assign 0 port, and then do your calls to the service in the tests. on teardown close the service. i am ignoring other dependenices like db’s or other services.
this is more like functional / integration testing.
Ferrellio
@_ferrellio_twitter
Got it, thanks for the guidance.
Bojan
@bojand
ideally your handler implementation would just be a function that returns / emits whatever is the payload(s), so then you can just unit test them individually w/o relying on specifics of the transport
Ferrellio
@_ferrellio_twitter
Yeah, that's what I've done so far. Just testing the handlers within unit testing, and services, repositories, etc.
It's still nice to get the end to end assurance. :)
Ferrellio
@_ferrellio_twitter
Hi again - what is the preferred way to catch if app.start cannot bind to the provided port (such as is the case when it is already in use.)?
Bojan
@bojand
hmm that’s a good a good question… the core server doesn’t seem to throw or anything.. just logs it
i’ll have to look into it some more when I have some more time