Question

I'm setting up an Express / AngularJS project. Express will serve the static assets for AngularJS and act as an API server. I want to unit test my express controllers and endpoints.

I may have some scenarios as well that need to be tested (like first create a user, then login, etc). I also want code coverage. Oh, did I mention that it's all in CoffeeScript as well?

I'm using karma and jasmine for my Angular tests. I'd like to stick to similar frameworks for the node.js layer.

Any suggestions on getting started?

Was it helpful?

Solution

supertest is great for this. You should be able to use it with jasmine or mocha easily. supertest-session can help with mocking out a logged-in user.

Have a look at some of these mocha + supertest tests if you need an example: https://github.com/focusaurus/peterlyons.com/tree/master/test/application

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top