@@ -133,13 +133,15 @@ export class TestBrokerViewModel extends Observable {
133133 this . emitInfoToSocketIfNeeded ( data ) ;
134134 this . emitStartToSocketIfNeeded ( data ) ;
135135
136- this . updateView ( {
137- testsRunning : true ,
138- testsPassed : 0 ,
139- testsFailed : 0 ,
140- testsRan : 0 ,
141- testsTotal : data . total
142- } ) ;
136+ if ( Object . hasOwnProperty . call ( data , "total" ) ) { // data.total only appears when tests are booting up and represent the total number of tests
137+ this . updateView ( {
138+ testsRunning : true ,
139+ testsPassed : 0 ,
140+ testsFailed : 0 ,
141+ testsRan : 0 ,
142+ testsTotal : data . total
143+ } ) ;
144+ }
143145 }
144146
145147 public result ( data ) {
@@ -161,11 +163,18 @@ export class TestBrokerViewModel extends Observable {
161163
162164 delete this . start ;
163165
164- this . emitToSocket ( 'complete' , data || { } , ( ) => {
166+ let acknowledged = false ;
167+ const ackFn = ( ) => {
168+ if ( acknowledged ) {
169+ return ;
170+ }
171+ acknowledged = true ;
165172 console . log ( 'NSUTR: completeAck' ) ;
166173 this . emitToSocket ( 'disconnect' ) ;
167174 setTimeout ( ( ) => killProcess ( ) , 500 ) ;
168- } ) ;
175+ } ;
176+ this . emitToSocket ( 'complete' , data || { } , ackFn ) ;
177+ setTimeout ( ackFn , 1000 ) ; // acknowledge is no longer sent by the karma server, so we use a timeout to ensure it runs
169178 }
170179
171180 public error ( msg : string , url ?: string , line ?: number ) {
@@ -202,7 +211,7 @@ export class TestBrokerViewModel extends Observable {
202211 }
203212 } ;
204213
205- this . updateView ( { serverInfo : `connected to ${ this . baseUrl } ` } ) ;
214+ this . updateView ( { serverInfo : `connected to ${ this . baseUrl } ` } ) ;
206215 let io = require ( '../socket.io' ) ;
207216 const socket = this . socket = io . connect ( this . baseUrl , { forceBase64 : true } ) ;
208217
@@ -236,6 +245,10 @@ export class TestBrokerViewModel extends Observable {
236245
237246 private emitToSocket ( ...args : any [ ] ) {
238247 if ( this . karmaRequestedRun ) {
248+ if ( args . length > 0 && args [ 0 ] === 'disconnect' ) {
249+ this . socket . disconnect ( ) ;
250+ return ;
251+ }
239252 this . socket . emit . apply ( this . socket , arguments ) ;
240253 }
241254 }
@@ -246,7 +259,7 @@ export class TestBrokerViewModel extends Observable {
246259 this . startEmitted = true ;
247260 }
248261 }
249-
262+
250263 private emitInfoToSocketIfNeeded ( data ) {
251264 if ( this . startEmitted ) {
252265 this . emitToSocket ( 'info' , data ) ;
0 commit comments