I am using strong-soap module to get data from SOAP request.
var soap = require('strong-soap').soap;
soap.createClient(url, options, function (err, client) {
var method = client.GetInfoSOAP;
method(requestQuery, function (err, info) {
// bla bla
}
}
I am getting the required data. Now
I want to write unit test case to mock the SOAP request using sinon stub, but didn't get any success. Any help would be appreciated.
What you want is controlling the
soapobject'screateClient. You can do that using techniques that fall into one of two categories:The Sinon project has a nice page on using link seams through
proxyquire, and I have also detailed how to do DI on the issue tracker.To achieve the first, all you need is to do something like this in the module:
Then in your test code: