list.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * Module dependencies.
  3. */
  4. var Base = require('./base')
  5. , cursor = Base.cursor
  6. , color = Base.color;
  7. /**
  8. * Expose `List`.
  9. */
  10. exports = module.exports = List;
  11. /**
  12. * Initialize a new `List` test reporter.
  13. *
  14. * @param {Runner} runner
  15. * @api public
  16. */
  17. function List(runner) {
  18. Base.call(this, runner);
  19. var self = this
  20. , stats = this.stats
  21. , n = 0;
  22. runner.on('start', function(){
  23. console.log();
  24. });
  25. runner.on('test', function(test){
  26. process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));
  27. });
  28. runner.on('pending', function(test){
  29. var fmt = color('checkmark', ' -')
  30. + color('pending', ' %s');
  31. console.log(fmt, test.fullTitle());
  32. });
  33. runner.on('pass', function(test){
  34. var fmt = color('checkmark', ' '+Base.symbols.dot)
  35. + color('pass', ' %s: ')
  36. + color(test.speed, '%dms');
  37. cursor.CR();
  38. console.log(fmt, test.fullTitle(), test.duration);
  39. });
  40. runner.on('fail', function(test, err){
  41. cursor.CR();
  42. console.log(color('fail', ' %d) %s'), ++n, test.fullTitle());
  43. });
  44. runner.on('end', self.epilogue.bind(self));
  45. }
  46. /**
  47. * Inherit from `Base.prototype`.
  48. */
  49. List.prototype.__proto__ = Base.prototype;