考虑这个摩卡测试:测试sails.js与摩卡咖啡:找不到/ API /服务/为myService
var Sails = require('sails');
describe("Foo Model creation:", function() {
// create a variable to hold the instantiated sails server
var app;
// Global before hook
before(function(done) {
// Lift Sails and start the server
Sails.lift({
log: {
level: 'error'
}
}, function(err, sails) {
app = sails;
done(err, sails);
});
});
// Global after hook
after(function(done) {
app.lower(done);
});
describe("new foo", function() {
var foo;
before(function (cb) {
var fooData = {
name: "test foo to be removed after test"
};
Foo.create(fooData, function (err, newFoo)
if (err) return cb(err);
foo = newFoo;
cb();
});
});
it("must show the name", function() {
foo.must.have.property('name');
});
after(function (cb){
foo.destroy(function (err) {
cb(err);
});
});
});
})
这只是富模型依赖于定义的船帆服务即库代码工作/ API /服务。在这里举起帆时,无法找到这些服务。
有没有办法在摩卡测试期间指示Sails来加载服务?
这应该工作。你使用的是什么版本的Sails? – sgress454