list.js 1.2 KB

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