Polymer async/promises tests timeout in sauce labs, but not locally

I set up Travis-CI and SL for automated testing. Travis can run WCT locally in shell good, this works perfectly and my tests pass. However when WCT is run with the sauce plugin enabled, and the tests are run on the sauce labs browsers, ONLY the async/promises tests fail this makes no sense…

the test itself (which is an EventListener) is waiting for a JS-event to be fired. I presume the event is never received. The output from WCT is not really helpful. It just complains that the done() method is never called.

Does anyone else experience the same problems with wct and Sauce Labs? If so, does anyone have a solution for these async/promises tests?

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

1 Like