Shamoon
Shamoon

Reputation: 43501

How can I set up an effective unit testing and scenario testing framework for an Express.js app?

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?

Upvotes: 0

Views: 321

Answers (1)

Peter Lyons
Peter Lyons

Reputation: 146044

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

Upvotes: 2

Related Questions