Javascript 超时超过摩卡咖啡+;续集
我这次考试有个问题。我不知道为什么插入会起作用,但如果我运行测试,我会收到: 错误:超过了15000ms的超时时间。对于异步测试和挂钩,请确保 调用“done()”;如果返回承诺,请确保它已解决 代码Javascript 超时超过摩卡咖啡+;续集,javascript,node.js,mocha.js,sequelize.js,Javascript,Node.js,Mocha.js,Sequelize.js,我这次考试有个问题。我不知道为什么插入会起作用,但如果我运行测试,我会收到: 错误:超过了15000ms的超时时间。对于异步测试和挂钩,请确保 调用“done()”;如果返回承诺,请确保它已解决 代码 describe('CRUD on Product', function () { this.timeout(15000) it('Insert single Product', function (done) { Product.build({ Customer: c
describe('CRUD on Product', function () {
this.timeout(15000)
it('Insert single Product', function (done) {
Product.build({
Customer: customer,
Order: order
}, {
include: [Customer, Order]
}).save(function (mind) {
console.log(mind)
done();
}).catch(function(err){
console.log(err)
done()
})
});
});
如图所示,save
函数不将回调作为参数。它返回一个承诺
describe('CRUD on Product', function () {
this.timeout(15000)
it('Insert single Product', function (done) {
Product.build({
Customer: customer,
Order: order
}, {
include: [Customer, Order]
})
.save()
.then(function (mind) {
console.log(mind)
done();
})
.catch(function(err){
console.log(err)
done()
})
});
});