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?

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top