We have a webservice which provides real time data for our application. In order to connect to that webservice we use $.connection. Code for that will be like -
this.myConnect = $.connection(myURL);
this.myConnect.start(settingsWhichIncludesACallBack).fail(anotherfunction);
How can I spy on the start and connection method. In other words, I don't want to establish an actual connection to the webService but still would like that my callback (passed as settings) to be call.
I am trying to use Jasmine spies to call fake for $.connection but for obvious reasons it fails on this.myConnect.start as 'not a function' for type error.
I've ran into this same issue before and used this article to create a mock signalR client. I actually copied the exact script from that site and included the mock in my config instead of the actual signalR client. The article has a decent write up on how he used the mock to write unit tests and there is a link at the bottom to some examples of unit tests that the author wrote using the mock client.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With