API Docs for: 0.9.1
Show:

File: lib/reporter/event.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 EventReporter
  8. * @extends AbstractReporter
  9. * @constructor
  10. *
  11. * @event message Includes all messages
  12. * @event admin Includes all administrative messages
  13. * @event item Includes all item data messages
  14. * @event suite Includes all suite messages
  15. * @event test Includes all test messages
  16. *
  17. * @event start Start of recording
  18. * @event stop Stopping the recording
  19. * @event complete Completion
  20. *
  21. * @event itemData Data assigned to item
  22. * @event itemMessage Message assigned to item
  23. *
  24. * @event suiteStart Start of a suite
  25. * @event suiteEnd End of a suite
  26. *
  27. * @event testStart Start of a test
  28. * @event testFailed Marks test as failed
  29. * @event testError Marks test as having errors
  30. * @event testPassed Marks test as passed
  31. * @event testUndefined Marks test as undefined
  32. * @event testSkipped Marks test as skipped
  33. * @event testIncomplete Marks test as incomplete
  34. */
  35. var EventReporter = AbstractReporter.extend(
  36.  
  37. {
  38. /**
  39. * Initializes the instance
  40. *
  41. * @method initialize
  42. */
  43. initialize: function () {
  44. this.__super();
  45.  
  46. this.on('message', function (areaType, messageType, params) {
  47. this.emit(areaType, messageType, params);
  48. this.emit(messageType, params);
  49. }.bind(this));
  50. },
  51.  
  52.  
  53. /**
  54. * Called when reporting starts
  55. *
  56. * @method start
  57. */
  58. start: function () {
  59. this.emit('message', 'admin', 'start');
  60. },
  61.  
  62. /**
  63. * Called when reporting stops
  64. *
  65. * @method stop
  66. */
  67. stop: function () {
  68. this.emit('message', 'admin', 'stop');
  69. },
  70.  
  71.  
  72. /**
  73. * Reporting is completed
  74. *
  75. * @method complete
  76. */
  77. complete: function () {
  78. this.emit('message', 'admin', 'complete');
  79. },
  80.  
  81.  
  82. /**
  83. * Called when any item has custom data
  84. *
  85. * @method itemData
  86. * @param {string} id
  87. * @param {string} json JSON-data
  88. */
  89. itemData: function (id, json) {
  90. var args = [id, json];
  91. this.emit('message', 'item', 'itemData', args);
  92. },
  93.  
  94. /**
  95. * Called when any item has a custom message
  96. *
  97. * @method itemMessage
  98. * @param {string} id
  99. * @param {string} message
  100. */
  101. itemMessage: function (id, message) {
  102. var args = [id, message];
  103. this.emit('message', 'item', 'itemMessage', args);
  104. },
  105.  
  106.  
  107. /**
  108. * Called when suite starts
  109. *
  110. * @method suiteStart
  111. * @param {string} id
  112. * @param {string} parentId
  113. * @param {string} suiteName
  114. */
  115. suiteStart: function (id, parentId, suiteName) {
  116. var args = [id, parentId, suiteName];
  117. this.emit('message', 'suite', 'suiteStart', args);
  118. },
  119.  
  120. /**
  121. * Called when suite ends
  122. *
  123. * @method suiteEnd
  124. * @param {string} id
  125. */
  126. suiteEnd: function (id) {
  127. var args = [id];
  128. this.emit('message', 'suite', 'suiteEnd', args);
  129. },
  130.  
  131.  
  132. /**
  133. * Called when test starts
  134. *
  135. * @method testStart
  136. * @param {string} id
  137. * @param {string} parentId
  138. * @param {string} testName
  139. */
  140. testStart: function (id, parentId, testName) {
  141. var args = [id, parentId, testName];
  142. this.emit('message', 'test', 'testStart', args);
  143. },
  144.  
  145.  
  146. /**
  147. * Called when test fails
  148. *
  149. * @method testFailed
  150. * @param {string} id
  151. * @param {string} [message]
  152. * @param {string} [reason]
  153. */
  154. testFailed: function (id, message, reason) {
  155. var args = [id, message, reason];
  156. this.emit('message', 'test', 'testFailed', args);
  157. },
  158.  
  159. /**
  160. * Called when test has an error
  161. *
  162. * @method testError
  163. * @param {string} id
  164. * @param {string} [message]
  165. * @param {string} [reason]
  166. */
  167. testError: function (id, message, reason) {
  168. var args = [id, message, reason];
  169. this.emit('message', 'test', 'testError', args);
  170. },
  171.  
  172. /**
  173. * Called when test has passed
  174. *
  175. * @method testPassed
  176. * @param {string} id
  177. */
  178. testPassed: function (id) {
  179. var args = [id];
  180. this.emit('message', 'test', 'testPassed', args);
  181. },
  182.  
  183. /**
  184. * Called when test is undefined
  185. *
  186. * @method testUndefined
  187. * @param {string} id
  188. */
  189. testUndefined: function (id) {
  190. var args = [id];
  191. this.emit('message', 'test', 'testUndefined', args);
  192. },
  193.  
  194. /**
  195. * Called when test is skipped
  196. *
  197. * @method testSkipped
  198. * @param {string} id
  199. * @param {string} [reason]
  200. */
  201. testSkipped: function (id, reason) {
  202. var args = [id, reason];
  203. this.emit('message', 'test', 'testSkipped', args);
  204. },
  205.  
  206. /**
  207. * Called when test is incomplete
  208. *
  209. * @method testIncomplete
  210. * @param {string} id
  211. */
  212. testIncomplete: function (id) {
  213. var args = [id];
  214. this.emit('message', 'test', 'testIncomplete', args);
  215. }
  216. });
  217.  
  218. module.exports = EventReporter;
  219.