2017-06-23 105 views
0

我在這個測試中遇到問題。我不知道爲什麼插入工作,但如果我運行測試,我收到:Timeout exceeded Mocha + Sequelize

Error: Timeout of 15000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

CODE

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

回答

1

如圖所示這是tutorial,將save功能將不會如回調參數。它返回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() 
    }) 
    }); 
});