I am trying to test my sails controller. But when i am using this line of code in my UserController.test.js, its throwing an error cannot called address of undefined
var app = sails.hooks.http.app
in bootstrap.test.js , I have declared the sails like this
var sails = require('sails')
before(function(done){
Sails.lift({},function(err,sails){
done(err, sails);
})
})
PS: I have checked that sails.hooks is working fine, only on calling http method its giving me that error.
I am following this link for testing. sails testing
You didn't pass the server. That's why it doesn't work.
var Sails = require('sails'); var sails; before(function(done) { Sails.lift({ }, function(err, server) { sails = server; if (err) return done(err); done(err, sails); }); });
Bye,
ADR.
first you should conf inside the sails.lift, things as:
models: {
connection: 'test',
migrate: 'drop'
}
there are example: https://github.com/bredikhin/sailsjs-mocha-testing-barrels-fixtures-example