小编joh*_*hiu的帖子

从Sinon.js Stub调用原始函数

我正在尝试拦截与Sinon.js的调用,这样我就可以进行一些日志记录然后执行原始调用.我没有看到用sinon.spy()做到这一点的方法,但我想我可以用sinon.stub()做到这一点.

我提供了一个自定义功能:

sinon.stub(servicecore.ServiceWrapper.prototype, '_invoke', function(method, name, body, headers, callback) {
    console.log('---- ServiceWrapper._invoke called! ----');

// How do I call the original function?

});
Run Code Online (Sandbox Code Playgroud)

我遇到的问题是执行原始函数,所以我的应用程序行为相同.任何的想法?

sinon

21
推荐指数
2
解决办法
9889
查看次数

标签 统计

sinon ×1