I'm new to sails.js and node.js. I'm trying to figure out what's the best way to setup unit testing. In Kraken.js for example, there is already a test/ folder setup upon generate, and it looks like it uses mocha.
But nothing like this comes pre-packaged with sails.js. I'm wondering what's the best way to structure it, which dependencies do I need to add (should I be using karma, jasmine, mocha, protractor, ...), and how to automate everything (ie. to run all tests using "grunt test" I suppose, or should I be running tests on every "npm start"...?)
How have you set up unit testing in your sails.js environment?
SailsJS is using mocha as a main testing framework. I would strongly advise you using the same technology, as it has a lot of features and can be easily integrated with various continuous integration services (e.g. Jenkins).
Official tutorial related to SailsJS unit testing can be found here: Testing your code
For DB fixtures you can use Barrels.
I do not recommend using "grunt test", it created an unnecessary dependency.
Instead uses "npm test" that is already installed on all node.js environment. Or a makefile (make test).
It is usual to place the tests in the "test" directory.
Mocha is a very good test runner (also used by SailJS). I use Mocha with Unit.js (http://unitjs.com) that provides everything I need for unit testing.