API Docs for: 0.9.1
Show:

File: lib/reporter/dot.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 DotReporter
  8. * @extends AbstractReporter
  9. * @constructor
  10. */
  11. var DotReporter = 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 = true;
  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. this.__super();
  38. this.console(undefined, "stop", "\n\n");
  39. },
  40.  
  41.  
  42. /**
  43. * Called when test fails
  44. *
  45. * @method testFailed
  46. * @param {string} id
  47. * @param {string} [message]
  48. * @param {string} [reason]
  49. */
  50. testFailed: function (id, message, reason) {
  51. var begin = '', end = '';
  52.  
  53. this.__super(id, message, reason);
  54.  
  55. if (this.useColor()) {
  56. begin = '\x1B[31m';
  57. end = '\x1B[0m';
  58. }
  59.  
  60. this.console(id, 'end', begin + 'F' + end)
  61. },
  62.  
  63. /**
  64. * Called when test has an error
  65. *
  66. * @method testError
  67. * @param {string} id
  68. * @param {string} [message]
  69. * @param {string} [reason]
  70. */
  71. testError: function (id, message, reason) {
  72. var begin = '', end = '';
  73.  
  74. this.__super(id, message, reason);
  75.  
  76. if (this.useColor()) {
  77. begin = '\x1B[31m';
  78. end = '\x1B[0m';
  79. }
  80.  
  81. this.console(id, 'end', begin + 'E' + end)
  82. },
  83.  
  84. /**
  85. * Called when test has passed
  86. *
  87. * @method testPassed
  88. * @param {string} id
  89. */
  90. testPassed: function (id) {
  91. var begin = '', end = '';
  92.  
  93. this.__super(id);
  94.  
  95. if (this.useColor()) {
  96. begin = '\x1B[32m';
  97. end = '\x1B[0m';
  98. }
  99.  
  100. this.console(id, 'end', begin + '.' + end)
  101. },
  102.  
  103. /**
  104. * Called when test is undefined
  105. *
  106. * @method testUndefined
  107. * @param {string} id
  108. */
  109. testUndefined: function (id) {
  110. var begin = '', end = '';
  111.  
  112. this.__super(id);
  113.  
  114. if (this.useColor()) {
  115. begin = '\x1B[33m';
  116. end = '\x1B[0m';
  117. }
  118.  
  119. this.console(id, 'end', begin + 'U' + end)
  120. },
  121.  
  122. /**
  123. * Called when test is skipped
  124. *
  125. * @method testSkipped
  126. * @param {string} id
  127. * @param {string} [reason]
  128. */
  129. testSkipped: function (id, reason) {
  130. var begin = '', end = '';
  131.  
  132. this.__super(id, reason);
  133.  
  134. if (this.useColor()) {
  135. begin = '\x1B[35m';
  136. end = '\x1B[0m';
  137. }
  138.  
  139. this.console(id, 'end', begin + 'S' + end)
  140. },
  141.  
  142. /**
  143. * Called when test is incomplete
  144. *
  145. * @method testIncomplete
  146. * @param {string} id
  147. */
  148. testIncomplete: function (id) {
  149. var begin = '', end = '';
  150.  
  151. this.__super(id);
  152.  
  153. if (this.useColor()) {
  154. begin = '\x1B[34m';
  155. end = '\x1B[0m';
  156. }
  157.  
  158. this.console(id, 'end', begin + 'I' + end)
  159. }
  160. });
  161.  
  162. module.exports = DotReporter;
  163.