I use supertest to call controllers as a user, to do this, first raise the sails in the before function so that it can be used as a server by supertest.
before(function (done) {
Sails.lift({
log: {
level: 'silent'
},
hooks: {
grunt: false,
},
}, function (err, sails) {
done(err, sails);
});
}
Then initialize supertest with the URL of your sailing application
request = require('supertest');
agent = request.agent(appurl);
/ , , .
it('should do the post and return whatever', function (done) {
agent.post('/controller/function')
.send(the_post_object_with_params)
.end(function (err, res) {
if (err) {
console.log(err);
}
console.log(res.body);
done();
});
}