jjzjj

Promisified

全部标签

javascript - 使用 sinon 和 bluebird 对 Promisified 函数进行 Stub

在我要测试的文件中,我有以下代码:varhttpGet=Promise.promisify(require("request").get);httpGet(endpoint,{auth:{bearer:req.body.access_token},json:true}).then(...)现在,在我的测试中,我想确保httpGet被调用一次,并确保参数有效。在被promise之前,我的测试是这样的:beforeEach(function(){request.get=sinon.stub().yields(null,null,{error:"testerror",error_descri

javascript - 使用 sinon 和 bluebird 对 Promisified 函数进行 Stub

在我要测试的文件中,我有以下代码:varhttpGet=Promise.promisify(require("request").get);httpGet(endpoint,{auth:{bearer:req.body.access_token},json:true}).then(...)现在,在我的测试中,我想确保httpGet被调用一次,并确保参数有效。在被promise之前,我的测试是这样的:beforeEach(function(){request.get=sinon.stub().yields(null,null,{error:"testerror",error_descri