Javascript Sinon存根检查是否使用特定参数调用了外部SOAP调用

Javascript Sinon存根检查是否使用特定参数调用了外部SOAP调用,javascript,node.js,soap,sinon,stub,Javascript,Node.js,Soap,Sinon,Stub,我正在使用Jasmine和sinon测试一些node.js代码。在这个例子中,我使用的是sinon存根 我正在尝试取消对外部服务的SOAP调用,我想知道是否有任何方法可以确保在调用中使用正确的参数 我已经成功地检查了函数在其他情况下是否返回了正确的参数,但不幸的是,这个场景在嵌套回调中,所以我不确定如何执行 下面是我的代码片段(我正试图测试“client.ExternalService.HttpPort.actualCall”是否被我期望的“args”变量调用): 如上所述,我正在尝试编写一个测

我正在使用Jasmine和sinon测试一些node.js代码。在这个例子中,我使用的是sinon存根

我正在尝试取消对外部服务的SOAP调用,我想知道是否有任何方法可以确保在调用中使用正确的参数

我已经成功地检查了函数在其他情况下是否返回了正确的参数,但不幸的是,这个场景在嵌套回调中,所以我不确定如何执行

下面是我的代码片段(我正试图测试“client.ExternalService.HttpPort.actualCall”是否被我期望的“args”变量调用):

如上所述,我正在尝试编写一个测试,以确保actualCall使用预期的“args”变量(确保传入的正文格式正确,以便传递给外部调用)。我可以通过删除soap.createClient并使用sinon.assert.calledWith()非常轻松地为url执行此操作,如下所示:

describe('The function', function(){
let service;
let externalServiceStub;
let externalRequest = helper.myExternalRequestObject;

describe('should use the correct URL',function(){
    beforeEach(function(){
        service = new ExternalServiceCaller(tools);
        externalServiceStub = sinon.stub(soap, 'createClient');
    });
    it ('and uses the correct URL when successful', function(){
        let url = tools.config.get('blah.my.url');
        service.callExternalService(myExternalRequestObject, callback => {});
        sinon.assert.calledWith(externalServiceStub, url);
        externalServiceStub.restore();
    });
});
不幸的是,我不知道如何检查是否使用我期望的“args”变量调用了actualCall。我可以使用一个假对象来检查它,但我不确定在这个场景中首先应该如何进行检查

我查看了soap存根,但是没有太多文档,而且这个示例对我来说没有意义

任何帮助都将不胜感激。:)

describe('The function', function(){
let service;
let externalServiceStub;
let externalRequest = helper.myExternalRequestObject;

describe('should use the correct URL',function(){
    beforeEach(function(){
        service = new ExternalServiceCaller(tools);
        externalServiceStub = sinon.stub(soap, 'createClient');
    });
    it ('and uses the correct URL when successful', function(){
        let url = tools.config.get('blah.my.url');
        service.callExternalService(myExternalRequestObject, callback => {});
        sinon.assert.calledWith(externalServiceStub, url);
        externalServiceStub.restore();
    });
});