API Docs for: 0.9.1
Show:

File: lib/reporter/lineSummary.js

  1. // Copyright 2014, Yahoo! Inc.
  2. // Copyrights licensed under the Mit License. See the accompanying LICENSE file for terms.
  3.  
  4. var AbstractReporter = require('../abstractReporter');
  5.  
  6. /**
  7. * @class LineSummaryReporter
  8. * @extends AbstractReporter
  9. * @constructor
  10. */
  11. var LineSummaryReporter = AbstractReporter.extend(
  12.  
  13. {
  14. /**
  15. * Initializes the instance
  16. *
  17. * @method initialize
  18. */
  19. initialize: function () {
  20. this.__super();
  21.  
  22. if (this.getOptions().progress === undefined) {
  23. this.getOptions().progress = false;
  24. }
  25. if (this.getOptions().output === undefined) {
  26. this.getOptions().output = true;
  27. }
  28. },
  29.  
  30.  
  31. /**
  32. * Called when reporting stops
  33. *
  34. * @method stop
  35. */
  36. stop: function () {
  37.  
  38. var outcomes,
  39. failed,
  40. tree;
  41.  
  42. this.__super();
  43.  
  44. tree = this.getContainer().getTree();
  45. outcomes = this.getContainer().gatherTestOutcomes(tree);
  46. failed = (outcomes.error + outcomes.failed) > 0;
  47.  
  48. if (this.useColor()) {
  49. if (failed) {
  50. this.console(undefined, "stop", '\x1B[41m\x1B[37m');
  51. } else {
  52. this.console(undefined, "stop", '\x1B[42m');
  53. }
  54. }
  55.  
  56. this.console(undefined, "stop", (failed ? 'Failed' : 'Success') + " (");
  57. this.console(undefined, "stop", outcomes.tests + " tests");
  58.  
  59. if (outcomes.passed > 0) {
  60. this.console(undefined, "stop", ", " + outcomes.passed + " passed");
  61. }
  62. if (outcomes.failed > 0) {
  63. this.console(undefined, "stop", ", " + outcomes.failed + " failed");
  64. }
  65. if (outcomes.error > 0) {
  66. this.console(undefined, "stop", ", " + outcomes.error + " errors");
  67. }
  68. if (outcomes.skipped > 0) {
  69. this.console(undefined, "stop", ", " + outcomes.skipped + " skipped");
  70. }
  71. if (outcomes.incomplete > 0) {
  72. this.console(undefined, "stop", ", " + outcomes.incomplete + " incomplete");
  73. }
  74. if (outcomes.undef > 0) {
  75. this.console(undefined, "stop", ", " + outcomes.undef + " undefined");
  76. }
  77. this.console(undefined, "stop", ")");
  78.  
  79. if (this.useColor()) {
  80. this.console(undefined, "stop", '\x1B[0m');
  81. }
  82.  
  83. this.console(undefined, "stop", "\n\n");
  84. }
  85. });
  86.  
  87. module.exports = LineSummaryReporter;
  88.