How do you structure the tests for your server applications in Node.js?

Viewed 10266

I'm starting to add tests to our Node.js server apps since we are slowly deploying into production. I have an API with many possible requests to test.

My question is: how do you structure your tests so it doesn't become a big file in which you quickly get lost?

I wrote tests for one API route (I have many other API routes to test) and this is how it looks (in Sublime file overview) :

code hell

And this test doesn't even cover all cases yet.

I'm using mocha, along with should and expect for validation, and superagent for API calls. How would you structure these tests so it doesn't evolve in a hideous big file?

1 Answers
Related