除了更新测试之外,以下一系列测试正在执行。
'describe.only('UsersModel', function() {
describe('#create()', function() {
it('should check create function', function (done) {
var newUser = { firstname: "fname", email: "myemail@gmail.com"};
User.create(newUser)
.then(function(results) {
// some tests
done();
})
.catch(done);
});
});
describe('#find()', function() {
it('should check find function', function (done) {
User.findAll()
.then(function(results) {
// some tests
done();
})
.catch(done);
});
});
describe('#update()', function() {
it('should check update function', function (done) {
User.update()
.then(function(results) {
// some tests
done();
})
.catch(done);
});
});
describe('#destroy()', function() {
it('should check destroy function', function (done) {
User.destroy()
.then(function(results) {
// some tests
done();
})
.catch(done);
});
});
});
> UsersModel
#create()
√ should check create function
#find()
1) should check find function
#update()
2) should check update function
#destroy()
√ should check destroy function
2 passing (46s)
2 failing
1。 UsersModel #find()应该检查find函数:
[Error (E_UNKNOWN) Encountered an unexpected error] Details: Error: In Waterline >= 0.9, findAll() has been deprecated in favor of find().
Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
at null.<anonymous> (C:\Users\acer\AppData\Roaming\npm\node_modules\mocha\lib\runnable.js:189:19)
答案 0 :(得分:1)
你有没看过日志?
1)它表示已弃用find()
而赞成findAll()
。因此,您需要将find()
替换为it('Should check find function', function (done) {
User
.find()
.then(function(results) {
// some tests
done();
})
.catch(done);
});
。
update()
2)接下来。它说“超过2000ms的超时。确保在此测试中调用done()回调”。如何使用参数调用it('Should check update function', function (done) {
User
.update('<USER_ID>', {key: value})
.then(function(results) {
// some tests
done();
})
.catch(done);
});
而不仅仅是空函数?什么是Waterline需要更新?您需要指定要更新的内容等...
{{1}}