Sha256: 95d16b7a83eb0292f260e256d1f80d2f55706576e6966bb8031ec1e6fc18801c

Contents?: true

Size: 1.68 KB

Versions: 10

Compression:

Stored size: 1.68 KB

Contents

/**
 * Module dependencies.
 */

var Base = require('./base')
  , cursor = Base.cursor
  , color = Base.color;

/**
 * Expose `Spec`.
 */

exports = module.exports = Spec;

/**
 * Initialize a new `Spec` test reporter.
 *
 * @param {Runner} runner
 * @api public
 */

function Spec(runner) {
  Base.call(this, runner);

  var self = this
    , stats = this.stats
    , indents = 0
    , n = 0;

  function indent() {
    return Array(indents).join('  ')
  }

  runner.on('start', function(){
    console.log();
  });

  runner.on('suite', function(suite){
    ++indents;
    console.log(color('suite', '%s%s'), indent(), suite.title);
  });

  runner.on('suite end', function(suite){
    --indents;
    if (1 == indents) console.log();
  });

  runner.on('test', function(test){
    process.stdout.write(indent() + color('pass', '  ◦ ' + test.title + ': '));
  });

  runner.on('pending', function(test){
    var fmt = indent() + color('pending', '  - %s');
    console.log(fmt, test.title);
  });

  runner.on('pass', function(test){
    if ('fast' == test.speed) {
      var fmt = indent()
        + color('checkmark', '  ✓')
        + color('pass', ' %s ');
      cursor.CR();
      console.log(fmt, test.title);
    } else {
      var fmt = indent()
        + color('checkmark', '  ✓')
        + color('pass', ' %s ')
        + color(test.speed, '(%dms)');
      cursor.CR();
      console.log(fmt, test.title, test.duration);
    }
  });

  runner.on('fail', function(test, err){
    cursor.CR();
    console.log(indent() + color('fail', '  %d) %s'), ++n, test.title);
  });

  runner.on('end', self.epilogue.bind(self));
}

/**
 * Inherit from `Base.prototype`.
 */

Spec.prototype.__proto__ = Base.prototype;

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
stylus-source-0.29.0 vendor/node_modules/mocha/lib/reporters/spec.js
stylus-source-0.28.2 vendor/node_modules/mocha/lib/reporters/spec.js
stylus-source-0.28.1 vendor/node_modules/mocha/lib/reporters/spec.js
stylus-source-0.28.0 vendor/node_modules/mocha/lib/reporters/spec.js
stylus-source-0.27.2 vendor/node_modules/mocha/lib/reporters/spec.js
stylus-source-0.27.1 vendor/node_modules/mocha/lib/reporters/spec.js
stylus-source-0.27.0 vendor/node_modules/mocha/lib/reporters/spec.js
stylus-source-0.26.1 vendor/node_modules/mocha/lib/reporters/spec.js
stylus-source-0.26.0 vendor/node_modules/mocha/lib/reporters/spec.js
stylus-source-0.25.0 vendor/node_modules/mocha/lib/reporters/spec.js