mercredi 21 janvier 2015

Writing unit tests for REST api NodeJS

I have been attempting to unit test my REST api with full crud operations but do not know where to start. I was told to write a nodejs app to make http requests which takes in an options object which can contain host, port, path, method (GET/POST/PUT/Delete), headers.


While doing research of my own I found out using mocha, should, and supertest were good options in order to do so. But have been unable to find good examples on how to write those tests. Any assistance on the matter would be greatly appreciated.


I have my api managing the information in-memory. So I just use object arrays in order to save the information locally.


I am very new to NodeJS but was successful in writing an api that handles nested routes, etc. And in order to improve efficiency when testing it I think unit tests would be a good place to start.


Aucun commentaire:

Enregistrer un commentaire