routing-controllers icon indicating copy to clipboard operation
routing-controllers copied to clipboard

Samples should include a test-suite

Open OysteinAmundsen opened this issue 6 years ago • 4 comments

The samples should include a test-runner and unit tests for each controller, demonstrating how one would implement unit testing. I know there are a lot of test frameworks out there, but choose one and a lot of details for all others would fall into place.

This would be a great starting-point for people (like me) who struggles with how to setup i.e. a karma runner for a nodejs typescript project like this.

OysteinAmundsen avatar Jul 18 '17 10:07 OysteinAmundsen

@OysteinAmundsen is this your first node.js/express project?

I haven't thought about this as it's even simplier that testing pure express app - you don't have to mock req and res, you just test controller methods like a normal method from services, etc. Just passing inputs params and asserting outputs. With DI you can easily pass mocked service in controller constructor so you don't have to mock and stub the whole world.

I will accept PRs with good samples 😉

MichalLytek avatar Jul 20 '17 15:07 MichalLytek

Hi.

I'm currently building some simple UTs (with Container injection of mocks etc) cause I'm lacking of those. Maybe I can try to post a PR here once I'm done with that on my project. It will be simple but it's a start ...

gjdass avatar Aug 19 '17 17:08 gjdass

Stale issue message

github-actions[bot] avatar Feb 16 '20 00:02 github-actions[bot]

Any news?

matte0080 avatar Jun 08 '23 08:06 matte0080