@@ -133,13 +133,15 @@ export class TestBrokerViewModel extends Observable {
133
133
this . emitInfoToSocketIfNeeded ( data ) ;
134
134
this . emitStartToSocketIfNeeded ( data ) ;
135
135
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
+ }
143
145
}
144
146
145
147
public result ( data ) {
@@ -161,11 +163,18 @@ export class TestBrokerViewModel extends Observable {
161
163
162
164
delete this . start ;
163
165
164
- this . emitToSocket ( 'complete' , data || { } , ( ) => {
166
+ let acknowledged = false ;
167
+ const ackFn = ( ) => {
168
+ if ( acknowledged ) {
169
+ return ;
170
+ }
171
+ acknowledged = true ;
165
172
console . log ( 'NSUTR: completeAck' ) ;
166
173
this . emitToSocket ( 'disconnect' ) ;
167
174
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
169
178
}
170
179
171
180
public error ( msg : string , url ?: string , line ?: number ) {
@@ -202,7 +211,7 @@ export class TestBrokerViewModel extends Observable {
202
211
}
203
212
} ;
204
213
205
- this . updateView ( { serverInfo : `connected to ${ this . baseUrl } ` } ) ;
214
+ this . updateView ( { serverInfo : `connected to ${ this . baseUrl } ` } ) ;
206
215
let io = require ( '../socket.io' ) ;
207
216
const socket = this . socket = io . connect ( this . baseUrl , { forceBase64 : true } ) ;
208
217
@@ -236,6 +245,10 @@ export class TestBrokerViewModel extends Observable {
236
245
237
246
private emitToSocket ( ...args : any [ ] ) {
238
247
if ( this . karmaRequestedRun ) {
248
+ if ( args . length > 0 && args [ 0 ] === 'disconnect' ) {
249
+ this . socket . disconnect ( ) ;
250
+ return ;
251
+ }
239
252
this . socket . emit . apply ( this . socket , arguments ) ;
240
253
}
241
254
}
@@ -246,7 +259,7 @@ export class TestBrokerViewModel extends Observable {
246
259
this . startEmitted = true ;
247
260
}
248
261
}
249
-
262
+
250
263
private emitInfoToSocketIfNeeded ( data ) {
251
264
if ( this . startEmitted ) {
252
265
this . emitToSocket ( 'info' , data ) ;
0 commit comments