28
28
var reporter = null ;
29
29
30
30
/**
31
- * Console reporter
31
+ * Daleks basic reporter, all the lovely colors & symbols you see when running dalek.
32
+ * The reporter will be installed by default.
33
+ *
34
+ * If you would like to use the reporter in addition to another one,
35
+ * you can start dalek with a special command line argument
36
+ *
37
+ * ```bash
38
+ * $ dalek your_test.js -r console,junit
39
+ * ```
40
+ *
41
+ * or you can add it to your Dalekfile
42
+ *
43
+ * ```javascript
44
+ * "reporter": ["console", "junit"]
45
+ * ```
32
46
*
33
47
* @class Reporter
34
48
* @constructor
35
- * @part console
49
+ * @part Console
36
50
* @api
37
51
*/
38
52
@@ -56,56 +70,62 @@ module.exports = function (opts) {
56
70
return reporter ;
57
71
} ;
58
72
59
- /**
60
- * Imports an output module with the correct log state
61
- *
62
- * @method importLogModule
63
- * @param {object } data
64
- * @chainable
65
- */
66
-
67
- Reporter . prototype . importLogModule = function ( ) {
68
- var logModule = require ( './lib/loglevel/level' + this . level ) ;
69
- var methods = Object . keys ( logModule . prototype ) ;
70
-
71
- methods . forEach ( function ( method ) {
72
- this [ method ] = logModule . prototype [ method ] ;
73
- } . bind ( this ) ) ;
74
- return this ;
75
- } ;
76
-
77
- /**
78
- * Connects to all the event listeners
79
- *
80
- * @method startListening
81
- * @param {object } data
82
- * @chainable
83
- */
84
-
85
- Reporter . prototype . startListening = function ( ) {
86
- // assertion & action status
87
- this . events . on ( 'report:assertion' , this . outputAssertionResult . bind ( this ) ) ;
88
- this . events . on ( 'report:assertion:status' , this . outputAssertionExpecation . bind ( this ) ) ;
89
- this . events . on ( 'report:action' , this . outputAction . bind ( this ) ) ;
90
-
91
- // test status
92
- this . events . on ( 'report:test:finished' , this . outputTestFinished . bind ( this ) ) ;
93
- this . events . on ( 'report:test:started' , this . outputTestStarted . bind ( this ) ) ;
94
-
95
- // runner status
96
- this . events . on ( 'report:runner:started' , this . outputRunnerStarted . bind ( this ) ) ;
97
- this . events . on ( 'report:runner:finished' , this . outputRunnerFinished . bind ( this ) ) ;
98
-
99
- // session & browser status
100
- this . events . on ( 'report:run:browser' , this . outputRunBrowser . bind ( this ) ) ;
101
- this . events . on ( 'report:driver:status' , this . outputOSVersion . bind ( this ) ) ;
102
- this . events . on ( 'report:driver:session' , this . outputBrowserVersion . bind ( this ) ) ;
103
-
104
- // logs
105
- this . events . on ( 'report:log:system' , this . outputLogUser . bind ( this , 'system' ) ) ;
106
- this . events . on ( 'report:log:driver' , this . outputLogUser . bind ( this , 'driver' ) ) ;
107
- this . events . on ( 'report:log:browser' , this . outputLogUser . bind ( this , 'browser' ) ) ;
108
- this . events . on ( 'report:log:user' , this . outputLogUser . bind ( this , 'user' ) ) ;
109
-
110
- return this ;
73
+ Reporter . prototype = {
74
+
75
+ /**
76
+ * Imports an output module with the correct log state
77
+ *
78
+ * @method importLogModule
79
+ * @param {object } data
80
+ * @chainable
81
+ */
82
+
83
+ importLogModule : function ( ) {
84
+ var logModule = require ( './lib/loglevel/level' + this . level ) ;
85
+ var methods = Object . keys ( logModule . prototype ) ;
86
+
87
+ methods . forEach ( function ( method ) {
88
+ this [ method ] = logModule . prototype [ method ] ;
89
+ } . bind ( this ) ) ;
90
+ return this ;
91
+ } ,
92
+
93
+ /**
94
+ * Connects to all the event listeners
95
+ *
96
+ * @method startListening
97
+ * @param {object } data
98
+ * @chainable
99
+ */
100
+
101
+ startListening : function ( ) {
102
+ // assertion & action status
103
+ this . events . on ( 'report:assertion' , this . outputAssertionResult . bind ( this ) ) ;
104
+ this . events . on ( 'report:assertion:status' , this . outputAssertionExpecation . bind ( this ) ) ;
105
+ this . events . on ( 'report:action' , this . outputAction . bind ( this ) ) ;
106
+
107
+ // test status
108
+ this . events . on ( 'report:test:finished' , this . outputTestFinished . bind ( this ) ) ;
109
+ this . events . on ( 'report:test:started' , this . outputTestStarted . bind ( this ) ) ;
110
+
111
+ // runner status
112
+ this . events . on ( 'report:runner:started' , this . outputRunnerStarted . bind ( this ) ) ;
113
+ this . events . on ( 'report:runner:finished' , this . outputRunnerFinished . bind ( this ) ) ;
114
+
115
+ // session & browser status
116
+ this . events . on ( 'report:run:browser' , this . outputRunBrowser . bind ( this ) ) ;
117
+ this . events . on ( 'report:driver:status' , this . outputOSVersion . bind ( this ) ) ;
118
+ this . events . on ( 'report:driver:session' , this . outputBrowserVersion . bind ( this ) ) ;
119
+
120
+ // logs
121
+ this . events . on ( 'report:log:system' , this . outputLogUser . bind ( this , 'system' ) ) ;
122
+ this . events . on ( 'report:log:driver' , this . outputLogUser . bind ( this , 'driver' ) ) ;
123
+ this . events . on ( 'report:log:browser' , this . outputLogUser . bind ( this , 'browser' ) ) ;
124
+ this . events . on ( 'report:log:user' , this . outputLogUser . bind ( this , 'user' ) ) ;
125
+
126
+ // written reports
127
+ this . events . on ( 'report:written' , this . outputReportWritten . bind ( this ) ) ;
128
+
129
+ return this ;
130
+ }
111
131
} ;
0 commit comments