Sha256: 69acaf648d56a35df7dda36800af1bd07bf016ed02c4a0890df087d5882ad212

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

/**
 * Module dependencies.
 */

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

/**
 * Expose `List`.
 */

exports = module.exports = List;

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

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

  var self = this
    , stats = this.stats
    , total = runner.total;

  runner.on('start', function(){
    console.log(JSON.stringify(['start', { total: total }]));
  });

  runner.on('pass', function(test){
    console.log(JSON.stringify(['pass', clean(test)]));
  });

  runner.on('fail', function(test, err){
    test.error = err;
    console.log(JSON.stringify(['fail', clean(test)]));
  });

  runner.on('end', function(){
    process.stdout.write(JSON.stringify(['end', self.stats]));
  });
}

/**
 * Return a plain-object representation of `test`
 * free of cyclic properties etc.
 *
 * @param {Object} test
 * @return {Object}
 * @api private
 */

function clean(test) {
  var obj = {
    title: test.title,
    fullTitle: test.fullTitle(),
    duration: test.duration
  };

  if (test.error) {
    obj.error = {
      message: test.error.message,
      stack: test.error.stack
    };
  }

  return obj;
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stylus-source-0.31.0 vendor/node_modules/mocha/lib/reporters/json-stream.js
stylus-source-0.30.1 vendor/node_modules/mocha/lib/reporters/json-stream.js
stylus-source-0.30.0 vendor/node_modules/mocha/lib/reporters/json-stream.js