Every developer advocates test-driven development, but I am coding a website in NodeJS and I am not testing my app.
This is not because I don’t see any reason. I know it allow me to check at each commit whether my code is right, thus avoiding security flaws.
I don’t do any tests because I don’t know how or what to test. I coded a MVC app with express + mongoose + passport, and I have no idea what to test or how to test. I know it is possible to mock express requests or mongodb, but I don’ find that clean and flexible.
So, what and how to test?
3
If you want to test your code independently of NodeJS, create a service layer or repository layer that contains an API you can call on one side, and Node.JS calls on the other. You can use your stubs or mocks on the methods in that layer, or even swap out the entire implementation of the service layer if that works for you.
What you test is the same as it ever was: methods.
7