我正在使用 Chai http 和 promise。下面的测试应该失败,但它没有调用 then 函数就通过了。如果我添加 done 参数以等待异步函数完成,它会失败(正确)。难道我做错了什么?
it('Returns the correct amount of events', function() {
chai.request(app)
.get('/api/events/count')
.then(function(res) {
throw new Error('why no throw?');
expect(res).to.have.status(200);
expect(res).to.be.json;
})
.catch(function(err) {
throw err;
});
});