lib/reporters/tap.js
function TAP(runner, options) {
  Base.call(this, runner, options);

  var self = this;
  var n = 1;

  var tapVersion = '12';
  if (options && options.reporterOptions) {
    if (options.reporterOptions.tapVersion) {
      tapVersion = options.reporterOptions.tapVersion.toString();
    }
  }

  this._producer = createProducer(tapVersion);

  runner.once(EVENT_RUN_BEGIN, function() {
    var ntests = runner.grepTotal(runner.suite);
    self._producer.writeVersion();
    self._producer.writePlan(ntests);
  });

  runner.on(EVENT_TEST_END, function() {
    ++n;
  });

  runner.on(EVENT_TEST_PENDING, function(test) {
    self._producer.writePending(n, test);
  });

  runner.on(EVENT_TEST_PASS, function(test) {
    self._producer.writePass(n, test);
  });

  runner.on(EVENT_TEST_FAIL, function(test, err) {
    self._producer.writeFail(n, test, err);
  });

  runner.once(EVENT_RUN_END, function() {
    self._producer.writeEpilogue(runner.stats);
  });
}
function TAP(runner, options) {
  Base.call(this, runner, options);

  var self = this;
  var n = 1;

  var tapVersion = '12';
  if (options && options.reporterOptions) {
    if (options.reporterOptions.tapVersion) {
      tapVersion = options.reporterOptions.tapVersion.toString();
    }
  }

  this._producer = createProducer(tapVersion);

  runner.once(EVENT_RUN_BEGIN, function() {
    var ntests = runner.grepTotal(runner.suite);
    self._producer.writeVersion();
    self._producer.writePlan(ntests);
  });

  runner.on(EVENT_TEST_END, function() {
    ++n;
  });

  runner.on(EVENT_TEST_PENDING, function(test) {
    self._producer.writePending(n, test);
  });

  runner.on(EVENT_TEST_PASS, function(test) {
    self._producer.writePass(n, test);
  });

  runner.on(EVENT_TEST_FAIL, function(test, err) {
    self._producer.writeFail(n, test, err);
  });

  runner.once(EVENT_RUN_END, function() {
    self._producer.writeEpilogue(runner.stats);
  });
}
function TAP ( runner , options ) { Base . call ( this , runner , options ) ; var self = this ; var n = 1 ; var tapVersion = '12' ; if ( options && options . reporterOptions ) { if ( options . reporterOptions . tapVersion ) { tapVersion = options . reporterOptions . tapVersion . toString ( ) ; } } this . _producer = createProducer ( tapVersion ) ; runner . once ( EVENT_RUN_BEGIN , function ( ) { var ntests = runner . grepTotal ( runner . suite ) ; self . _producer . writeVersion ( ) ; self . _producer . writePlan ( ntests ) ; } ) ; runner . on ( EVENT_TEST_END , function ( ) { ++ n ; } ) ; runner . on ( EVENT_TEST_PENDING , function ( test ) { self . _producer . writePending ( n , test ) ; } ) ; runner . on ( EVENT_TEST_PASS , function ( test ) { self . _producer . writePass ( n , test ) ; } ) ; runner . on ( EVENT_TEST_FAIL , function ( test , err ) { self . _producer . writeFail ( n , test , err ) ; } ) ; runner . once ( EVENT_RUN_END , function ( ) { self . _producer . writeEpilogue ( runner . stats ) ; } ) ; }
Constructs a new `TAP` reporter instance.

@public
@class
@memberof Mocha.reporters
@extends Mocha.reporters.Base
@param {Runner} runner - Instance triggers reporter actions.
@param {Object} [options] - runner options
Constructs a new TAP reporter instance .