The most logical practical answer that comes to mind is, Sauce Labs is SSL bumping.
The solution in this case from what you’ve told us, and in my opinion, is to stub the WebSocket connection in a way that such only the wrapper gets tested instead of the wrapper and WebSocket, so in other words, it will only call the wrapper and WebSocket.
The obvious other advantage to stubbing in WebSocket, the Travis build should build a lot faster.
To stub on the WebSocket you will need to call .and.callThrough
rather than returnValue
, in other words you will need to fake the constructor. I’m going to write some JavaScript that you can maybe use in your .travis.yml
that will get you out of this qualm:
let MontanaWS = WebSocket;
let WebSocketStub = stubOn(window, "WebSocket").and.callFake(function(url,protocols){
return new realWS(url,protocols);
});
This is for incoming messages:
let omStub = MontanaWS.createSpy('onmessageCallback');
The last bit I’m going to write is using the send
method to fake the JavaScript constructor, you can do this via:
let sendMontana = stubOn(WebSocket.prototype, "send").and.callFake(function(outMsg){
// this will be doing a process/check of an outgoing message - Montana
// you need to set, setTimeout, or call it immediately - Montana
this.onmessage("Montana from Travis says Hi!");
});
You can theoretically disable SSL bumping, you can do this by adding -B all
to your Sauce Connect Proxy startup commands - but I see for the use case as this may be out of the question.
This should get you going again, let me know if it doesn’t, and I will help you further.
Montana Mendy
Travis CI Staff