[英]Sequelize unit testing with sinon
我正在尝试模拟以下代码:
model.findAndCountAll({
pos: start
}).then((data) => {
this.success(....);
}).error(error => {
this.error(error, this.constants.HTTP_CODE_INTERNAL_SERVER_ERROR)
})
下面是模拟上面的代码的代码:
const findAndCountAll = sinon.stub(model, 'findAndCountAll');
findAndCountAll.withArgs().returns(new Promise((resolve, reject) => {
resolve(data);
}));
如果我从要模拟的代码中删除错误部分,则可以正常工作,否则会出现以下错误:
TypeError: model.findAndCountAll(...).then(...).error is not a function
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.