@@ -270,9 +270,7 @@ exports.list = function(failures) {
270270 * Initialize a new `Base` reporter.
271271 *
272272 * All other reporters generally
273- * inherit from this reporter, providing
274- * stats such as test duration, number
275- * of tests passed / failed etc.
273+ * inherit from this reporter.
276274 *
277275 * @memberof Mocha.reporters
278276 * @public
@@ -281,68 +279,31 @@ exports.list = function(failures) {
281279 */
282280
283281function Base ( runner ) {
284- var stats = ( this . stats = {
285- suites : 0 ,
286- tests : 0 ,
287- passes : 0 ,
288- pending : 0 ,
289- failures : 0
290- } ) ;
291282 var failures = ( this . failures = [ ] ) ;
292283
293284 if ( ! runner ) {
294- return ;
285+ throw new TypeError ( 'Missing runner argument' ) ;
295286 }
287+ this . stats = runner . stats ; // assigned so Reporters keep a closer reference
296288 this . runner = runner ;
297289
298- runner . stats = stats ;
299-
300- runner . on ( 'start' , function ( ) {
301- stats . start = new Date ( ) ;
302- } ) ;
303-
304- runner . on ( 'suite' , function ( suite ) {
305- stats . suites = stats . suites || 0 ;
306- suite . root || stats . suites ++ ;
307- } ) ;
308-
309- runner . on ( 'test end' , function ( ) {
310- stats . tests = stats . tests || 0 ;
311- stats . tests ++ ;
312- } ) ;
313-
314290 runner . on ( 'pass' , function ( test ) {
315- stats . passes = stats . passes || 0 ;
316-
317291 if ( test . duration > test . slow ( ) ) {
318292 test . speed = 'slow' ;
319293 } else if ( test . duration > test . slow ( ) / 2 ) {
320294 test . speed = 'medium' ;
321295 } else {
322296 test . speed = 'fast' ;
323297 }
324-
325- stats . passes ++ ;
326298 } ) ;
327299
328300 runner . on ( 'fail' , function ( test , err ) {
329- stats . failures = stats . failures || 0 ;
330- stats . failures ++ ;
331301 if ( showDiff ( err ) ) {
332302 stringifyDiffObjs ( err ) ;
333303 }
334304 test . err = err ;
335305 failures . push ( test ) ;
336306 } ) ;
337-
338- runner . once ( 'end' , function ( ) {
339- stats . end = new Date ( ) ;
340- stats . duration = stats . end - stats . start ;
341- } ) ;
342-
343- runner . on ( 'pending' , function ( ) {
344- stats . pending ++ ;
345- } ) ;
346307}
347308
348309/**
0 commit comments