考慮這個摩卡測試:測試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