diff --git a/client/karma.js b/client/karma.js index 6790a77ac..a0ba6cddf 100644 --- a/client/karma.js +++ b/client/karma.js @@ -41,9 +41,11 @@ function Karma (socket, iframe, opener, navigator, location, document) { } } - // This variable will be set to "true" whenever the socket lost connection and was able to - // reconnect to the Karma server. This will be passed to the Karma server then, so that - // Karma can differentiate between a socket client reconnect and a full browser reconnect. + // To start we will signal the server that we are not reconnecting. If the socket loses + // connection and was able to reconnect to the Karma server we will get a + // second 'connect' event. There we will pass 'true' and that will be passed to the + // Karma server then, so that Karma can differentiate between a socket client + // econnect and a full browser reconnect. var socketReconnect = false this.VERSION = constant.VERSION @@ -306,9 +308,6 @@ function Karma (socket, iframe, opener, navigator, location, document) { info.displayName = displayName } socket.emit('register', info) - }) - - socket.on('reconnect', function () { socketReconnect = true }) } diff --git a/static/karma.js b/static/karma.js index 0c289e0ca..5147441c2 100644 --- a/static/karma.js +++ b/static/karma.js @@ -51,9 +51,11 @@ function Karma (socket, iframe, opener, navigator, location, document) { } } - // This variable will be set to "true" whenever the socket lost connection and was able to - // reconnect to the Karma server. This will be passed to the Karma server then, so that - // Karma can differentiate between a socket client reconnect and a full browser reconnect. + // To start we will signal the server that we are not reconnecting. If the socket loses + // connection and was able to reconnect to the Karma server we will get a + // second 'connect' event. There we will pass 'true' and that will be passed to the + // Karma server then, so that Karma can differentiate between a socket client + // econnect and a full browser reconnect. var socketReconnect = false this.VERSION = constant.VERSION @@ -316,9 +318,6 @@ function Karma (socket, iframe, opener, navigator, location, document) { info.displayName = displayName } socket.emit('register', info) - }) - - socket.on('reconnect', function () { socketReconnect = true }) } diff --git a/test/e2e/reconnecting.feature b/test/e2e/reconnecting.feature index 829cbaec7..246d4e0da 100644 --- a/test/e2e/reconnecting.feature +++ b/test/e2e/reconnecting.feature @@ -21,6 +21,7 @@ Feature: Passing Options When I start Karma Then it passes with: """ + LOG: '============== START TEST ==============' ..... Chrome Headless """ diff --git a/test/e2e/support/reconnecting/test.js b/test/e2e/support/reconnecting/test.js index a3b682e1b..74216c7fe 100644 --- a/test/e2e/support/reconnecting/test.js +++ b/test/e2e/support/reconnecting/test.js @@ -6,27 +6,26 @@ describe('plus', function () { } it('should pass', function () { + // In flaky fails we probably get two starts. + console.log('============== START TEST ==============') expect(1).toBe(1) }) it('should disconnect', function (done) { expect(2).toBe(2) - socket().disconnect() - - done() + setTimeout(() => { + socket().disconnect() + done() + }, 500) }) it('should work', function () { expect(plus(1, 2)).toBe(3) }) - it('should re-connect', function (done) { + it('should re-connect', function () { expect(4).toBe(4) - // Emit reconnect, so Karma will not start new test run after reconnecting. - socket().emit('reconnect') socket().connect() - - done() }) it('should work', function () {