While establishing the connection using socket
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done( )" is called; if returning a Promise, ensure it resolves.
Given below is the code reference of the same
beforeEach(function(done) {
var socketOptions = {};
var socket = io.connect("http://localhost:5000", socketOptions);
socket.on('connect', function () {
console.log('Connection Established');
setTimeout(done, 500);
});
socket.on('error', function (err) {
console.log('Connection Error', err);
setTimeout(done, 500);
});
});
While checking the error of socket connection, I'm getting the error mentioned below:
Connection Error { Error: xhr poll error
at XHR.Transport.onError (F:\Projects\SDK\dynamicLocationServer\node_modules\engine.io-client\lib\transport.js:64:13)
at Request.<anonymous> (F:\Projects\SDK\dynamicLocationServer\node_modules\engine.io-client\lib\transports\polling-xhr.js:129:10)
at Request.Emitter.emit (F:\Projects\SDK\dynamicLocationServer\node_modules\engine.io-client\node_modules\component-emitter\index.js:133:20)
at Request.onError (F:\Projects\SDK\dynamicLocationServer\node_modules\engine.io-client\lib\transports\polling-xhr.js:307:8)
at Timeout._onTimeout (F:\Projects\SDK\dynamicLocationServer\node_modules\engine.io-client\lib\transports\polling-xhr.js:254:18)
at tryOnTimeout (timers.js:232:11)
at Timer.listOnTimeout (timers.js:202:5) type: 'TransportError', description:400}
done
is not defined you might need to specify it as argumentbeforeEach(function(done)
– Yury Tarabankodone
outside the socket connect, then it will work. Even if the connection fails, the test case will be resulting as passed. – Subbaconsole.log('Connection Established');
? – Yury Tarabankovar socketOptions = {'transports': ['websocket']};
. Thanks for the help @YuryTarabanko – Subba