min.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. 'use strict';
  2. /**
  3. * @typedef {import('../runner.js')} Runner
  4. */
  5. /**
  6. * @module Min
  7. */
  8. /**
  9. * Module dependencies.
  10. */
  11. var Base = require('./base');
  12. var inherits = require('../utils').inherits;
  13. var constants = require('../runner').constants;
  14. var EVENT_RUN_END = constants.EVENT_RUN_END;
  15. var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
  16. /**
  17. * Expose `Min`.
  18. */
  19. exports = module.exports = Min;
  20. /**
  21. * Constructs a new `Min` reporter instance.
  22. *
  23. * @description
  24. * This minimal test reporter is best used with '--watch'.
  25. *
  26. * @public
  27. * @class
  28. * @memberof Mocha.reporters
  29. * @extends Mocha.reporters.Base
  30. * @param {Runner} runner - Instance triggers reporter actions.
  31. * @param {Object} [options] - runner options
  32. */
  33. function Min(runner, options) {
  34. Base.call(this, runner, options);
  35. runner.on(EVENT_RUN_BEGIN, function () {
  36. // clear screen
  37. process.stdout.write('\u001b[2J');
  38. // set cursor position
  39. process.stdout.write('\u001b[1;3H');
  40. });
  41. runner.once(EVENT_RUN_END, this.epilogue.bind(this));
  42. }
  43. /**
  44. * Inherit from `Base.prototype`.
  45. */
  46. inherits(Min, Base);
  47. Min.description = 'essentially just a summary';