Line | Hits | Source |
---|---|---|
1 | /*! | |
2 | * | |
3 | * Copyright (c) 2013 Sebastian Golasch | |
4 | * | |
5 | * Permission is hereby granted, free of charge, to any person obtaining a | |
6 | * copy of this software and associated documentation files (the "Software"), | |
7 | * to deal in the Software without restriction, including without limitation | |
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
9 | * and/or sell copies of the Software, and to permit persons to whom the | |
10 | * Software is furnished to do so, subject to the following conditions: | |
11 | * | |
12 | * The above copyright notice and this permission notice shall be included | |
13 | * in all copies or substantial portions of the Software. | |
14 | * | |
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
16 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
21 | * DEALINGS IN THE SOFTWARE. | |
22 | * | |
23 | */ | |
24 | ||
25 | 1 | 'use strict'; |
26 | ||
27 | // int. globals | |
28 | 1 | var reporter = null; |
29 | ||
30 | /** | |
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 | * ``` | |
46 | * | |
47 | * @class Reporter | |
48 | * @constructor | |
49 | * @part Console | |
50 | * @api | |
51 | */ | |
52 | ||
53 | 1 | var Reporter = function (opts) { |
54 | 1 | var loglevel = opts && opts.logLevel ? parseInt(opts.logLevel, 10) : 1; |
55 | 1 | this.level = (loglevel >= -1 && loglevel <= 5) ? loglevel : 1; |
56 | 1 | this.events = opts.events; |
57 | ||
58 | // set color & symbols flags | |
59 | 1 | this.noColor = opts.config.config.noColors; |
60 | 1 | this.noSymbols = opts.config.config.noSymbols; |
61 | ||
62 | 1 | this.importLogModule(); |
63 | 1 | this.startListening(); |
64 | }; | |
65 | ||
66 | /** | |
67 | * @module Reporter | |
68 | */ | |
69 | ||
70 | 1 | module.exports = function (opts) { |
71 | 1 | if (reporter === null) { |
72 | 1 | reporter = new Reporter(opts); |
73 | } | |
74 | ||
75 | 1 | return reporter; |
76 | }; | |
77 | ||
78 | 1 | Reporter.prototype = { |
79 | ||
80 | /** | |
81 | * Imports an output module with the correct log state | |
82 | * | |
83 | * @method importLogModule | |
84 | * @param {object} data | |
85 | * @chainable | |
86 | */ | |
87 | ||
88 | importLogModule: function () { | |
89 | 1 | var logModule = require('./lib/levelbase'); |
90 | 1 | if (this.level !== -1) { |
91 | 1 | logModule = require('./lib/loglevel/level' + this.level); |
92 | } | |
93 | ||
94 | 1 | var methods = Object.keys(logModule.prototype); |
95 | ||
96 | 1 | methods.forEach(function (method) { |
97 | 19 | this[method] = logModule.prototype[method]; |
98 | }.bind(this)); | |
99 | 1 | return this; |
100 | }, | |
101 | ||
102 | /** | |
103 | * Connects to all the event listeners | |
104 | * | |
105 | * @method startListening | |
106 | * @param {object} data | |
107 | * @chainable | |
108 | */ | |
109 | ||
110 | startListening: function () { | |
111 | // assertion & action status | |
112 | 1 | this.events.on('report:assertion', this.outputAssertionResult.bind(this)); |
113 | 1 | this.events.on('report:assertion:status', this.outputAssertionExpectation.bind(this)); |
114 | 1 | this.events.on('report:action', this.outputAction.bind(this)); |
115 | ||
116 | // test status | |
117 | 1 | this.events.on('report:test:finished', this.outputTestFinished.bind(this)); |
118 | 1 | this.events.on('report:test:started', this.outputTestStarted.bind(this)); |
119 | ||
120 | // runner status | |
121 | 1 | this.events.on('report:runner:started', this.outputRunnerStarted.bind(this)); |
122 | 1 | this.events.on('report:runner:finished', this.outputRunnerFinished.bind(this)); |
123 | ||
124 | // session & browser status | |
125 | 1 | this.events.on('report:run:browser', this.outputRunBrowser.bind(this)); |
126 | 1 | this.events.on('report:driver:status', this.outputOSVersion.bind(this)); |
127 | 1 | this.events.on('report:driver:session', this.outputBrowserVersion.bind(this)); |
128 | ||
129 | // remote connections | |
130 | 1 | this.events.on('report:remote:ready', this.remoteConnectionReady.bind(this)); |
131 | 1 | this.events.on('report:remote:established', this.remoteConnectionEstablished.bind(this)); |
132 | 1 | this.events.on('report:remote:closed', this.remoteConnectionClosed.bind(this)); |
133 | ||
134 | // logs | |
135 | 1 | this.events.on('report:log:system', this.outputLogUser.bind(this, 'system')); |
136 | 1 | this.events.on('report:log:driver', this.outputLogUser.bind(this, 'driver')); |
137 | 1 | this.events.on('report:log:browser', this.outputLogUser.bind(this, 'browser')); |
138 | 1 | this.events.on('report:log:user', this.outputLogUser.bind(this, 'user')); |
139 | 1 | this.events.on('report:log:system:webdriver', this.outputLogUser.bind(this, 'webdriver')); |
140 | ||
141 | // errors & warnings | |
142 | 1 | this.events.on('error', this.outputError.bind(this)); |
143 | 1 | this.events.on('warning', this.outputWarning.bind(this)); |
144 | ||
145 | // reports | |
146 | 1 | this.events.on('report:written', this.outputReportWritten.bind(this)); |
147 | ||
148 | 1 | return this; |
149 | } | |
150 | }; | |
151 |
Line | Hits | Source |
---|---|---|
1 | /*! | |
2 | * | |
3 | * Copyright (c) 2013 Sebastian Golasch | |
4 | * | |
5 | * Permission is hereby granted, free of charge, to any person obtaining a | |
6 | * copy of this software and associated documentation files (the "Software"), | |
7 | * to deal in the Software without restriction, including without limitation | |
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
9 | * and/or sell copies of the Software, and to permit persons to whom the | |
10 | * Software is furnished to do so, subject to the following conditions: | |
11 | * | |
12 | * The above copyright notice and this permission notice shall be included | |
13 | * in all copies or substantial portions of the Software. | |
14 | * | |
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
16 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
21 | * DEALINGS IN THE SOFTWARE. | |
22 | * | |
23 | */ | |
24 | ||
25 | 1 | 'use strict'; |
26 | ||
27 | // ext. libs | |
28 | 1 | var clc = require('cli-color'); |
29 | ||
30 | /** | |
31 | * @class LevelBase | |
32 | * @constructor | |
33 | * @param {object} opts | |
34 | */ | |
35 | ||
36 | 1 | var LevelBase = function (opts) { |
37 | 0 | this.noColor = !!(opts && opts.noColor); |
38 | 0 | this.noSymbols = !!(opts && opts.noSymbols); |
39 | }; | |
40 | ||
41 | /** | |
42 | * @module LevelBase | |
43 | */ | |
44 | ||
45 | 1 | module.exports = LevelBase; |
46 | ||
47 | /** | |
48 | * Outputs a string | |
49 | * | |
50 | * @method outputTestStarted | |
51 | * @param {object} data | |
52 | * @chainable | |
53 | */ | |
54 | ||
55 | 1 | LevelBase.prototype.echo = function (message, options) { |
56 | 0 | options = options || {}; |
57 | 0 | var nl = options.nl === false ? '' :'\n'; |
58 | 0 | var coloredOutput = clc; |
59 | 0 | message = options.ec === true ? message + ' ' : message; |
60 | ||
61 | // should a newline be outputted before the current message | |
62 | 0 | if (options.pnl) { |
63 | 0 | console.log(''); |
64 | } | |
65 | ||
66 | // output a message without any colors | |
67 | 0 | if (this.noColor) { |
68 | 0 | process.stdout.write(message + nl); |
69 | 0 | return this; |
70 | } | |
71 | ||
72 | // check if we have a foreground color, then apply | |
73 | 0 | if (options.foreground) { |
74 | 0 | coloredOutput = coloredOutput[options.foreground]; |
75 | } | |
76 | ||
77 | // check if we have a font style, then apply | |
78 | 0 | if (options.style) { |
79 | 0 | coloredOutput = coloredOutput[options.style]; |
80 | } | |
81 | ||
82 | // check if we have a background color, then apply | |
83 | 0 | if (options.background) { |
84 | 0 | coloredOutput = coloredOutput[options.background]; |
85 | } | |
86 | ||
87 | // check if we need to indent the string | |
88 | 0 | if (options.indent) { |
89 | 0 | var indention = 0; |
90 | 0 | for (var i = 0; i <= indention; i++) { |
91 | 0 | indention += ' '; |
92 | } | |
93 | 0 | message = indention + message; |
94 | } | |
95 | ||
96 | // output the message | |
97 | 0 | process.stdout.write(coloredOutput(message + nl)); |
98 | 0 | return this; |
99 | }; | |
100 | ||
101 | /** | |
102 | * Outputs a symbol | |
103 | * | |
104 | * @method outputTestStarted | |
105 | * @param {object} data | |
106 | * @return {string} symbol | |
107 | */ | |
108 | ||
109 | 1 | LevelBase.prototype.symbol = function (symbol) { |
110 | 0 | if (this.noSymbols || process.platform === 'win32') { |
111 | 0 | return symbol; |
112 | } | |
113 | ||
114 | // switch to a nicer UTF-8 symbol | |
115 | 0 | switch (symbol) { |
116 | case '*': | |
117 | 0 | symbol = '✔'; |
118 | 0 | break; |
119 | case 'x': | |
120 | 0 | symbol = '✘'; |
121 | 0 | break; |
122 | case '>': | |
123 | 0 | symbol = '▶'; |
124 | 0 | break; |
125 | case '->': | |
126 | 0 | symbol = '↝'; |
127 | 0 | break; |
128 | case '>>': | |
129 | 0 | symbol = '>>'; |
130 | 0 | break; |
131 | case '<>': | |
132 | 0 | symbol = '☁'; |
133 | 0 | break; |
134 | } | |
135 | ||
136 | 0 | return symbol; |
137 | }; | |
138 | ||
139 | /** | |
140 | * Does nothing | |
141 | * | |
142 | * @method outputRunnerStarted | |
143 | * @param {object} data | |
144 | * @chainable | |
145 | */ | |
146 | ||
147 | 1 | LevelBase.prototype.outputRunnerStarted = function () { |
148 | 0 | return this; |
149 | }; | |
150 | ||
151 | /** | |
152 | * Does nothing | |
153 | * | |
154 | * @method outputTestFinished | |
155 | * @param {object} data | |
156 | * @chainable | |
157 | */ | |
158 | ||
159 | 1 | LevelBase.prototype.outputTestFinished = function () { |
160 | 0 | return this; |
161 | }; | |
162 | ||
163 | /** | |
164 | * Does nothing | |
165 | * | |
166 | * @method outputRunnerFinished | |
167 | * @param {object} data | |
168 | * @chainable | |
169 | */ | |
170 | ||
171 | 1 | LevelBase.prototype.outputRunnerFinished = function () { |
172 | 0 | return this; |
173 | }; | |
174 | ||
175 | /** | |
176 | * Does nothing | |
177 | * | |
178 | * @method outputAssertionResult | |
179 | * @param {object} data | |
180 | * @chainable | |
181 | */ | |
182 | ||
183 | 1 | LevelBase.prototype.outputAssertionResult = function () { |
184 | 0 | return this; |
185 | }; | |
186 | ||
187 | /** | |
188 | * Does nothing | |
189 | * | |
190 | * @method outputRunBrowser | |
191 | * @param {object} browser | |
192 | * @chainable | |
193 | */ | |
194 | ||
195 | 1 | LevelBase.prototype.outputRunBrowser = function () { |
196 | 0 | return this; |
197 | }; | |
198 | ||
199 | /** | |
200 | * Does nothing | |
201 | * | |
202 | * @method outputAction | |
203 | * @chainable | |
204 | */ | |
205 | ||
206 | 1 | LevelBase.prototype.outputAction = function () { |
207 | 0 | return this; |
208 | }; | |
209 | ||
210 | /** | |
211 | * Does nothing | |
212 | * | |
213 | * @method outputAssertionExpectation | |
214 | * @param {object} data | |
215 | * @chainable | |
216 | */ | |
217 | ||
218 | 1 | LevelBase.prototype.outputAssertionExpectation = function () { |
219 | 0 | return this; |
220 | }; | |
221 | ||
222 | /** | |
223 | * Does nothing | |
224 | * | |
225 | * @method outputAction | |
226 | * @param {object} data | |
227 | * @chainable | |
228 | */ | |
229 | ||
230 | 1 | LevelBase.prototype.outputAction = function () { |
231 | 0 | return this; |
232 | }; | |
233 | ||
234 | /** | |
235 | * Does nothing | |
236 | * | |
237 | * @method outputTestStarted | |
238 | * @param {object} data | |
239 | * @chainable | |
240 | */ | |
241 | ||
242 | 1 | LevelBase.prototype.outputTestStarted = function () { |
243 | 0 | return this; |
244 | }; | |
245 | ||
246 | /** | |
247 | * Does nothing | |
248 | * | |
249 | * @method outputLogUser | |
250 | * @param {object} data | |
251 | * @chainable | |
252 | */ | |
253 | ||
254 | 1 | LevelBase.prototype.outputLogUser = function () { |
255 | 0 | return this; |
256 | }; | |
257 | ||
258 | /** | |
259 | * Does nothing | |
260 | * | |
261 | * @method outputBrowserVersion | |
262 | * @param {object} data | |
263 | * @chainable | |
264 | */ | |
265 | ||
266 | 1 | LevelBase.prototype.outputBrowserVersion = function () { |
267 | 0 | return this; |
268 | }; | |
269 | ||
270 | /** | |
271 | * Does nothing | |
272 | * | |
273 | * @method outputOSVersion | |
274 | * @param {object} data | |
275 | * @chainable | |
276 | */ | |
277 | ||
278 | 1 | LevelBase.prototype.outputOSVersion = function () { |
279 | 0 | return this; |
280 | }; | |
281 | ||
282 | /** | |
283 | * Does nothing | |
284 | * | |
285 | * @method outputReportWritten | |
286 | * @param {object} data | |
287 | * @chainable | |
288 | */ | |
289 | ||
290 | 1 | LevelBase.prototype.outputReportWritten = function () { |
291 | 0 | return this; |
292 | }; | |
293 | ||
294 | /** | |
295 | * Does nothing | |
296 | * | |
297 | * @method outputWarning | |
298 | * @param {object} data | |
299 | * @chainable | |
300 | */ | |
301 | ||
302 | 1 | LevelBase.prototype.outputWarning = function () { |
303 | 0 | return this; |
304 | }; | |
305 | ||
306 | /** | |
307 | * Does nothing | |
308 | * | |
309 | * @method outputError | |
310 | * @param {object} data | |
311 | * @chainable | |
312 | */ | |
313 | ||
314 | 1 | LevelBase.prototype.outputError = function () { |
315 | 0 | return this; |
316 | }; | |
317 | ||
318 | /** | |
319 | * Does nothing | |
320 | * | |
321 | * @method remoteConnectionEstablished | |
322 | * @param {object} data | |
323 | * @chainable | |
324 | */ | |
325 | ||
326 | 1 | LevelBase.prototype.remoteConnectionEstablished = function () { |
327 | 0 | return this; |
328 | }; | |
329 | ||
330 | /** | |
331 | * Does nothing | |
332 | * | |
333 | * @method remoteConnectionClosed | |
334 | * @param {object} data | |
335 | * @chainable | |
336 | */ | |
337 | ||
338 | 1 | LevelBase.prototype.remoteConnectionClosed = function () { |
339 | 0 | return this; |
340 | }; | |
341 | ||
342 | /** | |
343 | * Does nothing | |
344 | * | |
345 | * @method remoteConnectionReady | |
346 | * @param {object} data | |
347 | * @chainable | |
348 | */ | |
349 | ||
350 | 1 | LevelBase.prototype.remoteConnectionReady = function () { |
351 | 0 | return this; |
352 | }; | |
353 |
Line | Hits | Source |
---|---|---|
1 | /*! | |
2 | * | |
3 | * Copyright (c) 2013 Sebastian Golasch | |
4 | * | |
5 | * Permission is hereby granted, free of charge, to any person obtaining a | |
6 | * copy of this software and associated documentation files (the "Software"), | |
7 | * to deal in the Software without restriction, including without limitation | |
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
9 | * and/or sell copies of the Software, and to permit persons to whom the | |
10 | * Software is furnished to do so, subject to the following conditions: | |
11 | * | |
12 | * The above copyright notice and this permission notice shall be included | |
13 | * in all copies or substantial portions of the Software. | |
14 | * | |
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
16 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
21 | * DEALINGS IN THE SOFTWARE. | |
22 | * | |
23 | */ | |
24 | ||
25 | 1 | 'use strict'; |
26 | ||
27 | // int. libs | |
28 | 1 | var Log = require('../levelbase'); |
29 | ||
30 | /** | |
31 | * @class LogLevel0 | |
32 | * @constructor | |
33 | * @param {object} opts | |
34 | */ | |
35 | ||
36 | 1 | var LogLevel0 = Log; |
37 | ||
38 | /** | |
39 | * @module LogLevel0 | |
40 | */ | |
41 | ||
42 | 1 | module.exports = LogLevel0; |
43 |
Line | Hits | Source |
---|---|---|
1 | /*! | |
2 | * | |
3 | * Copyright (c) 2013 Sebastian Golasch | |
4 | * | |
5 | * Permission is hereby granted, free of charge, to any person obtaining a | |
6 | * copy of this software and associated documentation files (the "Software"), | |
7 | * to deal in the Software without restriction, including without limitation | |
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
9 | * and/or sell copies of the Software, and to permit persons to whom the | |
10 | * Software is furnished to do so, subject to the following conditions: | |
11 | * | |
12 | * The above copyright notice and this permission notice shall be included | |
13 | * in all copies or substantial portions of the Software. | |
14 | * | |
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
16 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
21 | * DEALINGS IN THE SOFTWARE. | |
22 | * | |
23 | */ | |
24 | ||
25 | 1 | 'use strict'; |
26 | ||
27 | // int. libs | |
28 | 1 | var Log = require('./level0'); |
29 | ||
30 | /** | |
31 | * @class LogLevel1 | |
32 | * @constructor | |
33 | * @param {object} opts | |
34 | */ | |
35 | ||
36 | 1 | var LogLevel1 = Log; |
37 | ||
38 | /** | |
39 | * @module LogLevel1 | |
40 | */ | |
41 | ||
42 | 1 | module.exports = LogLevel1; |
43 | ||
44 | /** | |
45 | * Outputs a browser or user log message | |
46 | * | |
47 | * @method outputLogUser | |
48 | * @param {string} type | |
49 | * @param {string} message | |
50 | * @chainable | |
51 | */ | |
52 | ||
53 | 1 | LogLevel1.prototype.outputLogUser = function (type, message) { |
54 | 0 | if (type === 'browser' || type === 'user') { |
55 | 0 | this.echo(this.symbol('<>'), {nl: false, ec: true, foreground: 'cyan'}); |
56 | 0 | this.echo('[' + type.toUpperCase() + ']', {nl: false, foreground: 'whiteBright', background: 'bgCyanBright'}); |
57 | 0 | this.echo(' ' + message, {foreground: 'cyan'}); |
58 | } | |
59 | 0 | return this; |
60 | }; | |
61 | ||
62 | /** | |
63 | * Outputs a message when the testrunner starts | |
64 | * | |
65 | * @method outputRunnerStarted | |
66 | * @return {LogLevel1} | |
67 | */ | |
68 | ||
69 | 1 | LogLevel1.prototype.outputRunnerStarted = function () { |
70 | 0 | this.echo('Running tests', {foreground: 'magentaBright'}); |
71 | 0 | return this; |
72 | }; | |
73 | ||
74 | /** | |
75 | * Outputs a message when a test is finished | |
76 | * | |
77 | * @method outputTestFinished | |
78 | * @param {object} data | |
79 | * @return {LogLevel1} | |
80 | */ | |
81 | ||
82 | 1 | LogLevel1.prototype.outputTestFinished = function (data) { |
83 | 0 | this.echo('.', {nl: false, foreground: (data.status ? 'greenBright' : 'redBright')}); |
84 | 0 | return this; |
85 | }; | |
86 | ||
87 | /** | |
88 | * Outputs a message when an error occurs | |
89 | * | |
90 | * @method outputError | |
91 | * @param {object} data | |
92 | * @return {LogLevel1} | |
93 | */ | |
94 | ||
95 | 1 | LogLevel1.prototype.outputError = function (data) { |
96 | 0 | this.echo(this.symbol('>>') + ' ERROR:', {nl: false, ec: true, foreground: 'redBright'}); |
97 | 0 | this.echo(String(data), {nl: true, foreground: 'redBright'}); |
98 | 0 | return this; |
99 | }; | |
100 | ||
101 | /** | |
102 | * Outputs a message when a warning occurs | |
103 | * | |
104 | * @method outputWarning | |
105 | * @param {object} data | |
106 | * @return {LogLevel1} | |
107 | */ | |
108 | ||
109 | 1 | LogLevel1.prototype.outputWarning = function (data) { |
110 | 0 | this.echo(this.symbol('>>') + ' WARNING:', {nl: false, ec: true, foreground: 'yellowBright'}); |
111 | 0 | this.echo(String(data), {nl: true, foreground: 'yellowBright'}); |
112 | 0 | return this; |
113 | }; | |
114 | ||
115 | /** | |
116 | * Outputs a message when the testrunner has been finished | |
117 | * | |
118 | * @method outputRunnerFinished | |
119 | * @param {object} data | |
120 | * @return {LogLevel1} | |
121 | */ | |
122 | ||
123 | 1 | LogLevel1.prototype.outputRunnerFinished = function (data) { |
124 | 0 | var elapsedTime = data.elapsedTime; |
125 | 0 | var timeOutput = ''; |
126 | ||
127 | // generate formatted time output | |
128 | 0 | if (elapsedTime.hours > 0) { |
129 | 0 | timeOutput += elapsedTime.hours + ' hrs '; |
130 | } | |
131 | ||
132 | 0 | if (elapsedTime.minutes > 0) { |
133 | 0 | timeOutput += elapsedTime.minutes + ' min '; |
134 | } | |
135 | ||
136 | 0 | timeOutput += Math.round(elapsedTime.seconds * Math.pow(10, 2)) / Math.pow(10, 2) + ' sec'; |
137 | ||
138 | // newline FTW! | |
139 | 0 | this.echo('', {nl: true}); |
140 | ||
141 | // echo the assertion & time status | |
142 | 0 | this.echo(' ' + |
143 | data.assertionsPassed + '/' + data.assertions + ' assertions passed.' + ' Elapsed Time: ' + timeOutput + ' ', | |
144 | {foreground: (data.status ? 'black' : 'whiteBright'), background: (data.status ? 'bgGreenBright' : 'bgRedBright')} | |
145 | ); | |
146 | 0 | return this; |
147 | }; | |
148 | ||
149 | /** | |
150 | * Outputs a message when the remote connection has been established | |
151 | * | |
152 | * @method remoteConnectionEstablished | |
153 | * @param {object} data | |
154 | * @chainable | |
155 | */ | |
156 | ||
157 | 1 | LogLevel1.prototype.remoteConnectionReady = function (data) { |
158 | 0 | this.echo('Remote connection is ready on IP:', {nl: false, ec: true, foreground: 'magentaBright'}); |
159 | 0 | this.echo(data.ip + ':' + data.port, {foreground: 'yellowBright'}); |
160 | 0 | return this; |
161 | }; | |
162 | ||
163 | /** | |
164 | * Outputs a message when the remote connection has been established | |
165 | * | |
166 | * @method remoteConnectionEstablished | |
167 | * @param {object} data | |
168 | * @chainable | |
169 | */ | |
170 | ||
171 | 1 | LogLevel1.prototype.remoteConnectionEstablished = function (data) { |
172 | 0 | this.echo('Starting session:', {nl: false, ec: true, foreground: 'greenBright'}); |
173 | 0 | this.echo(data.browser + ':' + data.id, {foreground: 'cyanBright'}); |
174 | 0 | return this; |
175 | }; | |
176 | ||
177 | /** | |
178 | * Outputs a message when the remote connection has been closed | |
179 | * | |
180 | * @method remoteConnectionClosed | |
181 | * @param {object} data | |
182 | * @chainable | |
183 | */ | |
184 | ||
185 | 1 | LogLevel1.prototype.remoteConnectionClosed = function (data) { |
186 | 0 | this.echo('Closing session:', {nl: false, ec: true, foreground: 'greenBright'}); |
187 | 0 | this.echo(data.browser + ':' + data.id, {foreground: 'cyanBright'}); |
188 | 0 | return this; |
189 | }; | |
190 |