【问题标题】:Timeout exceeded Mocha + Sequelize超时超时 Mocha + Sequelize
【发布时间】:2017-06-23 14:00:21
【问题描述】:

我在这个测试中有一个问题。我不知道为什么插入有效,但如果我运行测试,我会收到:

错误:超过 15000 毫秒的超时。对于异步测试和钩子,确保 “完成()”被调用;如果返回 Promise,请确保它已解决。

代码

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()
    })
  });
});

【问题讨论】:

    标签: javascript node.js mocha.js sequelize.js


    【解决方案1】:

    如图是这个tutorialsave函数没有回调作为参数。它返回一个promise

    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()
        })
      });
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-07
      • 2017-04-15
      相关资源
      最近更新 更多