mocha 5.0.4 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +119 -9
  2. package/bin/_mocha +90 -35
  3. package/bin/options.js +14 -8
  4. package/browser-entry.js +20 -16
  5. package/lib/browser/progress.js +8 -8
  6. package/lib/browser/tty.js +2 -2
  7. package/lib/context.js +11 -9
  8. package/lib/hook.js +7 -9
  9. package/lib/interfaces/bdd.js +12 -13
  10. package/lib/interfaces/common.js +20 -15
  11. package/lib/interfaces/exports.js +2 -7
  12. package/lib/interfaces/qunit.js +6 -10
  13. package/lib/interfaces/tdd.js +7 -11
  14. package/lib/mocha.js +94 -54
  15. package/lib/ms.js +12 -6
  16. package/lib/pending.js +1 -5
  17. package/lib/reporters/base.js +102 -64
  18. package/lib/reporters/doc.js +23 -9
  19. package/lib/reporters/dot.js +14 -8
  20. package/lib/reporters/html.js +81 -41
  21. package/lib/reporters/json-stream.js +16 -9
  22. package/lib/reporters/json.js +47 -12
  23. package/lib/reporters/json.js.orig +128 -0
  24. package/lib/reporters/landing.js +14 -8
  25. package/lib/reporters/list.js +16 -10
  26. package/lib/reporters/markdown.js +18 -12
  27. package/lib/reporters/min.js +9 -3
  28. package/lib/reporters/nyan.js +31 -25
  29. package/lib/reporters/progress.js +13 -7
  30. package/lib/reporters/spec.js +19 -11
  31. package/lib/reporters/tap.js +15 -9
  32. package/lib/reporters/xunit.js +48 -24
  33. package/lib/runnable.js +88 -66
  34. package/lib/runner.js +117 -90
  35. package/lib/suite.js +76 -63
  36. package/lib/test.js +9 -13
  37. package/lib/utils.js +137 -85
  38. package/mocha.js +1914 -1162
  39. package/package.json +462 -299
  40. package/CHANGELOG.md.orig +0 -1736
  41. package/README.md.orig +0 -132
  42. package/bin/.eslintrc.yml +0 -3
  43. package/images/error.png +0 -0
  44. package/images/ok.png +0 -0
  45. package/lib/browser/.eslintrc.yml +0 -4
@@ -1,7 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  /* eslint-env browser */
4
-
4
+ /**
5
+ * @module HTML
6
+ */
5
7
  /**
6
8
  * Module dependencies.
7
9
  */
@@ -34,7 +36,8 @@ exports = module.exports = HTML;
34
36
  * Stats template.
35
37
  */
36
38
 
37
- var statsTemplate = '<ul id="mocha-stats">' +
39
+ var statsTemplate =
40
+ '<ul id="mocha-stats">' +
38
41
  '<li class="progress"><canvas width="40" height="40"></canvas></li>' +
39
42
  '<li class="passes"><a href="javascript:void(0);">passes:</a> <em>0</em></li>' +
40
43
  '<li class="failures"><a href="javascript:void(0);">failures:</a> <em>0</em></li>' +
@@ -46,10 +49,14 @@ var playIcon = '&#x2023;';
46
49
  /**
47
50
  * Initialize a new `HTML` reporter.
48
51
  *
52
+ * @public
53
+ * @class
54
+ * @memberof Mocha.reporters
55
+ * @extends Mocha.reporters.Base
49
56
  * @api public
50
57
  * @param {Runner} runner
51
58
  */
52
- function HTML (runner) {
59
+ function HTML(runner) {
53
60
  Base.call(this, runner);
54
61
 
55
62
  var self = this;
@@ -84,10 +91,10 @@ function HTML (runner) {
84
91
  }
85
92
 
86
93
  // pass toggle
87
- on(passesLink, 'click', function (evt) {
94
+ on(passesLink, 'click', function(evt) {
88
95
  evt.preventDefault();
89
96
  unhide();
90
- var name = (/pass/).test(report.className) ? '' : ' pass';
97
+ var name = /pass/.test(report.className) ? '' : ' pass';
91
98
  report.className = report.className.replace(/fail|pass/g, '') + name;
92
99
  if (report.className.trim()) {
93
100
  hideSuitesWithout('test pass');
@@ -95,10 +102,10 @@ function HTML (runner) {
95
102
  });
96
103
 
97
104
  // failure toggle
98
- on(failuresLink, 'click', function (evt) {
105
+ on(failuresLink, 'click', function(evt) {
99
106
  evt.preventDefault();
100
107
  unhide();
101
- var name = (/fail/).test(report.className) ? '' : ' fail';
108
+ var name = /fail/.test(report.className) ? '' : ' fail';
102
109
  report.className = report.className.replace(/fail|pass/g, '') + name;
103
110
  if (report.className.trim()) {
104
111
  hideSuitesWithout('test fail');
@@ -112,14 +119,18 @@ function HTML (runner) {
112
119
  progress.size(40);
113
120
  }
114
121
 
115
- runner.on('suite', function (suite) {
122
+ runner.on('suite', function(suite) {
116
123
  if (suite.root) {
117
124
  return;
118
125
  }
119
126
 
120
127
  // suite
121
128
  var url = self.suiteURL(suite);
122
- var el = fragment('<li class="suite"><h1><a href="%s">%s</a></h1></li>', url, escape(suite.title));
129
+ var el = fragment(
130
+ '<li class="suite"><h1><a href="%s">%s</a></h1></li>',
131
+ url,
132
+ escape(suite.title)
133
+ );
123
134
 
124
135
  // container
125
136
  stack[0].appendChild(el);
@@ -127,7 +138,7 @@ function HTML (runner) {
127
138
  el.appendChild(stack[0]);
128
139
  });
129
140
 
130
- runner.on('suite end', function (suite) {
141
+ runner.on('suite end', function(suite) {
131
142
  if (suite.root) {
132
143
  updateStats();
133
144
  return;
@@ -135,19 +146,27 @@ function HTML (runner) {
135
146
  stack.shift();
136
147
  });
137
148
 
138
- runner.on('pass', function (test) {
149
+ runner.on('pass', function(test) {
139
150
  var url = self.testURL(test);
140
- var markup = '<li class="test pass %e"><h2>%e<span class="duration">%ems</span> ' +
141
- '<a href="%s" class="replay">' + playIcon + '</a></h2></li>';
151
+ var markup =
152
+ '<li class="test pass %e"><h2>%e<span class="duration">%ems</span> ' +
153
+ '<a href="%s" class="replay">' +
154
+ playIcon +
155
+ '</a></h2></li>';
142
156
  var el = fragment(markup, test.speed, test.title, test.duration, url);
143
157
  self.addCodeToggle(el, test.body);
144
158
  appendToStack(el);
145
159
  updateStats();
146
160
  });
147
161
 
148
- runner.on('fail', function (test) {
149
- var el = fragment('<li class="test fail"><h2>%e <a href="%e" class="replay">' + playIcon + '</a></h2></li>',
150
- test.title, self.testURL(test));
162
+ runner.on('fail', function(test) {
163
+ var el = fragment(
164
+ '<li class="test fail"><h2>%e <a href="%e" class="replay">' +
165
+ playIcon +
166
+ '</a></h2></li>',
167
+ test.title,
168
+ self.testURL(test)
169
+ );
151
170
  var stackString; // Note: Includes leading newline
152
171
  var message = test.err.toString();
153
172
 
@@ -162,7 +181,9 @@ function HTML (runner) {
162
181
  if (indexOfMessage === -1) {
163
182
  stackString = test.err.stack;
164
183
  } else {
165
- stackString = test.err.stack.substr(test.err.message.length + indexOfMessage);
184
+ stackString = test.err.stack.substr(
185
+ test.err.message.length + indexOfMessage
186
+ );
166
187
  }
167
188
  } else if (test.err.sourceURL && test.err.line !== undefined) {
168
189
  // Safari doesn't give you a stack. Let's at least provide a source line.
@@ -172,12 +193,21 @@ function HTML (runner) {
172
193
  stackString = stackString || '';
173
194
 
174
195
  if (test.err.htmlMessage && stackString) {
175
- el.appendChild(fragment('<div class="html-error">%s\n<pre class="error">%e</pre></div>',
176
- test.err.htmlMessage, stackString));
196
+ el.appendChild(
197
+ fragment(
198
+ '<div class="html-error">%s\n<pre class="error">%e</pre></div>',
199
+ test.err.htmlMessage,
200
+ stackString
201
+ )
202
+ );
177
203
  } else if (test.err.htmlMessage) {
178
- el.appendChild(fragment('<div class="html-error">%s</div>', test.err.htmlMessage));
204
+ el.appendChild(
205
+ fragment('<div class="html-error">%s</div>', test.err.htmlMessage)
206
+ );
179
207
  } else {
180
- el.appendChild(fragment('<pre class="error">%e%e</pre>', message, stackString));
208
+ el.appendChild(
209
+ fragment('<pre class="error">%e%e</pre>', message, stackString)
210
+ );
181
211
  }
182
212
 
183
213
  self.addCodeToggle(el, test.body);
@@ -185,22 +215,25 @@ function HTML (runner) {
185
215
  updateStats();
186
216
  });
187
217
 
188
- runner.on('pending', function (test) {
189
- var el = fragment('<li class="test pass pending"><h2>%e</h2></li>', test.title);
218
+ runner.on('pending', function(test) {
219
+ var el = fragment(
220
+ '<li class="test pass pending"><h2>%e</h2></li>',
221
+ test.title
222
+ );
190
223
  appendToStack(el);
191
224
  updateStats();
192
225
  });
193
226
 
194
- function appendToStack (el) {
227
+ function appendToStack(el) {
195
228
  // Don't call .appendChild if #mocha-report was already .shift()'ed off the stack.
196
229
  if (stack[0]) {
197
230
  stack[0].appendChild(el);
198
231
  }
199
232
  }
200
233
 
201
- function updateStats () {
234
+ function updateStats() {
202
235
  // TODO: add to stats
203
- var percent = stats.tests / runner.total * 100 | 0;
236
+ var percent = (stats.tests / runner.total * 100) | 0;
204
237
  if (progress) {
205
238
  progress.update(percent).draw(ctx);
206
239
  }
@@ -219,7 +252,7 @@ function HTML (runner) {
219
252
  * @param {string} s
220
253
  * @return {string} A new URL.
221
254
  */
222
- function makeUrl (s) {
255
+ function makeUrl(s) {
223
256
  var search = window.location.search;
224
257
 
225
258
  // Remove previous grep query parameter if present
@@ -227,7 +260,12 @@ function makeUrl (s) {
227
260
  search = search.replace(/[?&]grep=[^&\s]*/g, '').replace(/^&/, '?');
228
261
  }
229
262
 
230
- return window.location.pathname + (search ? search + '&' : '?') + 'grep=' + encodeURIComponent(escapeRe(s));
263
+ return (
264
+ window.location.pathname +
265
+ (search ? search + '&' : '?') +
266
+ 'grep=' +
267
+ encodeURIComponent(escapeRe(s))
268
+ );
231
269
  }
232
270
 
233
271
  /**
@@ -235,7 +273,7 @@ function makeUrl (s) {
235
273
  *
236
274
  * @param {Object} [suite]
237
275
  */
238
- HTML.prototype.suiteURL = function (suite) {
276
+ HTML.prototype.suiteURL = function(suite) {
239
277
  return makeUrl(suite.fullTitle());
240
278
  };
241
279
 
@@ -244,7 +282,7 @@ HTML.prototype.suiteURL = function (suite) {
244
282
  *
245
283
  * @param {Object} [test]
246
284
  */
247
- HTML.prototype.testURL = function (test) {
285
+ HTML.prototype.testURL = function(test) {
248
286
  return makeUrl(test.fullTitle());
249
287
  };
250
288
 
@@ -254,10 +292,10 @@ HTML.prototype.testURL = function (test) {
254
292
  * @param {HTMLLIElement} el
255
293
  * @param {string} contents
256
294
  */
257
- HTML.prototype.addCodeToggle = function (el, contents) {
295
+ HTML.prototype.addCodeToggle = function(el, contents) {
258
296
  var h2 = el.getElementsByTagName('h2')[0];
259
297
 
260
- on(h2, 'click', function () {
298
+ on(h2, 'click', function() {
261
299
  pre.style.display = pre.style.display === 'none' ? 'block' : 'none';
262
300
  });
263
301
 
@@ -271,7 +309,7 @@ HTML.prototype.addCodeToggle = function (el, contents) {
271
309
  *
272
310
  * @param {string} msg
273
311
  */
274
- function error (msg) {
312
+ function error(msg) {
275
313
  document.body.appendChild(fragment('<div id="mocha-error">%s</div>', msg));
276
314
  }
277
315
 
@@ -280,15 +318,17 @@ function error (msg) {
280
318
  *
281
319
  * @param {string} html
282
320
  */
283
- function fragment (html) {
321
+ function fragment(html) {
284
322
  var args = arguments;
285
323
  var div = document.createElement('div');
286
324
  var i = 1;
287
325
 
288
- div.innerHTML = html.replace(/%([se])/g, function (_, type) {
326
+ div.innerHTML = html.replace(/%([se])/g, function(_, type) {
289
327
  switch (type) {
290
- case 's': return String(args[i++]);
291
- case 'e': return escape(args[i++]);
328
+ case 's':
329
+ return String(args[i++]);
330
+ case 'e':
331
+ return escape(args[i++]);
292
332
  // no default
293
333
  }
294
334
  });
@@ -302,7 +342,7 @@ function fragment (html) {
302
342
  *
303
343
  * @param {text} classname
304
344
  */
305
- function hideSuitesWithout (classname) {
345
+ function hideSuitesWithout(classname) {
306
346
  var suites = document.getElementsByClassName('suite');
307
347
  for (var i = 0; i < suites.length; i++) {
308
348
  var els = suites[i].getElementsByClassName(classname);
@@ -315,7 +355,7 @@ function hideSuitesWithout (classname) {
315
355
  /**
316
356
  * Unhide .hidden suites.
317
357
  */
318
- function unhide () {
358
+ function unhide() {
319
359
  var els = document.getElementsByClassName('suite hidden');
320
360
  for (var i = 0; i < els.length; ++i) {
321
361
  els[i].className = els[i].className.replace('suite hidden', 'suite');
@@ -328,7 +368,7 @@ function unhide () {
328
368
  * @param {HTMLElement} el
329
369
  * @param {string} contents
330
370
  */
331
- function text (el, contents) {
371
+ function text(el, contents) {
332
372
  if (el.textContent) {
333
373
  el.textContent = contents;
334
374
  } else {
@@ -339,7 +379,7 @@ function text (el, contents) {
339
379
  /**
340
380
  * Listen on `event` with callback `fn`.
341
381
  */
342
- function on (el, event, fn) {
382
+ function on(el, event, fn) {
343
383
  if (el.addEventListener) {
344
384
  el.addEventListener(event, fn, false);
345
385
  } else {
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
-
2
+ /**
3
+ * @module JSONStream
4
+ */
3
5
  /**
4
6
  * Module dependencies.
5
7
  */
@@ -13,33 +15,38 @@ var Base = require('./base');
13
15
  exports = module.exports = List;
14
16
 
15
17
  /**
16
- * Initialize a new `List` test reporter.
18
+ * Initialize a new `JSONStream` test reporter.
17
19
  *
20
+ * @public
21
+ * @name JSONStream
22
+ * @class JSONStream
23
+ * @memberof Mocha.reporters
24
+ * @extends Mocha.reporters.Base
18
25
  * @api public
19
26
  * @param {Runner} runner
20
27
  */
21
- function List (runner) {
28
+ function List(runner) {
22
29
  Base.call(this, runner);
23
30
 
24
31
  var self = this;
25
32
  var total = runner.total;
26
33
 
27
- runner.on('start', function () {
28
- console.log(JSON.stringify(['start', { total: total }]));
34
+ runner.on('start', function() {
35
+ console.log(JSON.stringify(['start', {total: total}]));
29
36
  });
30
37
 
31
- runner.on('pass', function (test) {
38
+ runner.on('pass', function(test) {
32
39
  console.log(JSON.stringify(['pass', clean(test)]));
33
40
  });
34
41
 
35
- runner.on('fail', function (test, err) {
42
+ runner.on('fail', function(test, err) {
36
43
  test = clean(test);
37
44
  test.err = err.message;
38
45
  test.stack = err.stack || null;
39
46
  console.log(JSON.stringify(['fail', test]));
40
47
  });
41
48
 
42
- runner.once('end', function () {
49
+ runner.once('end', function() {
43
50
  process.stdout.write(JSON.stringify(['end', self.stats]));
44
51
  });
45
52
  }
@@ -52,7 +59,7 @@ function List (runner) {
52
59
  * @param {Object} test
53
60
  * @return {Object}
54
61
  */
55
- function clean (test) {
62
+ function clean(test) {
56
63
  return {
57
64
  title: test.title,
58
65
  fullTitle: test.fullTitle(),
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
-
2
+ /**
3
+ * @module JSON
4
+ */
3
5
  /**
4
6
  * Module dependencies.
5
7
  */
@@ -15,10 +17,14 @@ exports = module.exports = JSONReporter;
15
17
  /**
16
18
  * Initialize a new `JSON` reporter.
17
19
  *
20
+ * @public
21
+ * @class JSON
22
+ * @memberof Mocha.reporters
23
+ * @extends Mocha.reporters.Base
18
24
  * @api public
19
25
  * @param {Runner} runner
20
26
  */
21
- function JSONReporter (runner) {
27
+ function JSONReporter(runner) {
22
28
  Base.call(this, runner);
23
29
 
24
30
  var self = this;
@@ -27,23 +33,23 @@ function JSONReporter (runner) {
27
33
  var failures = [];
28
34
  var passes = [];
29
35
 
30
- runner.on('test end', function (test) {
36
+ runner.on('test end', function(test) {
31
37
  tests.push(test);
32
38
  });
33
39
 
34
- runner.on('pass', function (test) {
40
+ runner.on('pass', function(test) {
35
41
  passes.push(test);
36
42
  });
37
43
 
38
- runner.on('fail', function (test) {
44
+ runner.on('fail', function(test) {
39
45
  failures.push(test);
40
46
  });
41
47
 
42
- runner.on('pending', function (test) {
48
+ runner.on('pending', function(test) {
43
49
  pending.push(test);
44
50
  });
45
51
 
46
- runner.once('end', function () {
52
+ runner.once('end', function() {
47
53
  var obj = {
48
54
  stats: self.stats,
49
55
  tests: tests.map(clean),
@@ -66,26 +72,55 @@ function JSONReporter (runner) {
66
72
  * @param {Object} test
67
73
  * @return {Object}
68
74
  */
69
- function clean (test) {
75
+ function clean(test) {
76
+ var err = test.err || {};
77
+ if (err instanceof Error) {
78
+ err = errorJSON(err);
79
+ }
80
+
70
81
  return {
71
82
  title: test.title,
72
83
  fullTitle: test.fullTitle(),
73
84
  duration: test.duration,
74
85
  currentRetry: test.currentRetry(),
75
- err: errorJSON(test.err || {})
86
+ err: cleanCycles(err)
76
87
  };
77
88
  }
78
89
 
79
90
  /**
80
- * Transform `error` into a JSON object.
91
+ * Replaces any circular references inside `obj` with '[object Object]'
92
+ *
93
+ * @api private
94
+ * @param {Object} obj
95
+ * @return {Object}
96
+ */
97
+ function cleanCycles(obj) {
98
+ var cache = [];
99
+ return JSON.parse(
100
+ JSON.stringify(obj, function(key, value) {
101
+ if (typeof value === 'object' && value !== null) {
102
+ if (cache.indexOf(value) !== -1) {
103
+ // Instead of going in a circle, we'll print [object Object]
104
+ return '' + value;
105
+ }
106
+ cache.push(value);
107
+ }
108
+
109
+ return value;
110
+ })
111
+ );
112
+ }
113
+
114
+ /**
115
+ * Transform an Error object into a JSON object.
81
116
  *
82
117
  * @api private
83
118
  * @param {Error} err
84
119
  * @return {Object}
85
120
  */
86
- function errorJSON (err) {
121
+ function errorJSON(err) {
87
122
  var res = {};
88
- Object.getOwnPropertyNames(err).forEach(function (key) {
123
+ Object.getOwnPropertyNames(err).forEach(function(key) {
89
124
  res[key] = err[key];
90
125
  }, err);
91
126
  return res;
@@ -0,0 +1,128 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Module dependencies.
5
+ */
6
+
7
+ var Base = require('./base');
8
+
9
+ /**
10
+ * Expose `JSON`.
11
+ */
12
+
13
+ exports = module.exports = JSONReporter;
14
+
15
+ /**
16
+ * Initialize a new `JSON` reporter.
17
+ *
18
+ * @api public
19
+ * @param {Runner} runner
20
+ * @param {options} mocha invocation options. Invoking
21
+ * `mocha -R --reporter-options output-file=asdf` yields options like:
22
+ * { ... reporterOptions: { "output-file": "asdf" } ... }
23
+ */
24
+ function JSONReporter (runner, options) {
25
+ <<<<<<< HEAD
26
+ =======
27
+ options = options || {};
28
+ var reptOptions = options.reporterOptions || {};
29
+ >>>>>>> + json ouput controls: output-file, output-object
30
+ Base.call(this, runner);
31
+
32
+ var self = this;
33
+ var tests = [];
34
+ var pending = [];
35
+ var failures = [];
36
+ var passes = [];
37
+
38
+ runner.on('test end', function (test) {
39
+ tests.push(test);
40
+ });
41
+
42
+ runner.on('pass', function (test) {
43
+ passes.push(test);
44
+ });
45
+
46
+ runner.on('fail', function (test) {
47
+ failures.push(test);
48
+ });
49
+
50
+ runner.on('pending', function (test) {
51
+ pending.push(test);
52
+ });
53
+
54
+ runner.once('end', function () {
55
+ var obj = {
56
+ stats: self.stats,
57
+ tests: tests.map(clean),
58
+ pending: pending.map(clean),
59
+ failures: failures.map(clean),
60
+ passes: passes.map(clean)
61
+ };
62
+
63
+ runner.testResults = obj;
64
+ <<<<<<< HEAD
65
+ if ('output-object' in options.reporterOptions) {
66
+ // Pass to reporter with: reporter("json", {"output-object": myObject})
67
+ Object.assign(options.reporterOptions['output-object'], obj);
68
+ } else {
69
+ var text = JSON.stringify(obj, null, 2);
70
+ if ('output-file' in options.reporterOptions) {
71
+ // Direct output with `mocha -R --reporter-options output-file=rpt.json`
72
+ try {
73
+ require('fs').writeFileSync(options.reporterOptions['output-file'], text);
74
+ } catch (e) {
75
+ console.warn('error writing to ' + options.reporterOptions.output + ':', e);
76
+ =======
77
+ if ('output-object' in reptOptions) {
78
+ // Pass to reporter with: reporter("json", {"output-object": myObject})
79
+ Object.assign(reptOptions['output-object'], obj);
80
+ } else {
81
+ var text = JSON.stringify(obj, null, 2);
82
+ if ('output-file' in reptOptions) {
83
+ // Direct output with `mocha -R --reporter-options output-file=rpt.json`
84
+ try {
85
+ require('fs').writeFileSync(reptOptions['output-file'], text);
86
+ } catch (e) {
87
+ console.warn('error writing to ' + reptOptions.output + ':', e);
88
+ >>>>>>> + json ouput controls: output-file, output-object
89
+ }
90
+ } else {
91
+ process.stdout.write(text);
92
+ }
93
+ }
94
+ });
95
+ }
96
+
97
+ /**
98
+ * Return a plain-object representation of `test`
99
+ * free of cyclic properties etc.
100
+ *
101
+ * @api private
102
+ * @param {Object} test
103
+ * @return {Object}
104
+ */
105
+ function clean (test) {
106
+ return {
107
+ title: test.title,
108
+ fullTitle: test.fullTitle(),
109
+ duration: test.duration,
110
+ currentRetry: test.currentRetry(),
111
+ err: errorJSON(test.err || {})
112
+ };
113
+ }
114
+
115
+ /**
116
+ * Transform `error` into a JSON object.
117
+ *
118
+ * @api private
119
+ * @param {Error} err
120
+ * @return {Object}
121
+ */
122
+ function errorJSON (err) {
123
+ var res = {};
124
+ Object.getOwnPropertyNames(err).forEach(function (key) {
125
+ res[key] = err[key];
126
+ }, err);
127
+ return res;
128
+ }
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
-
2
+ /**
3
+ * @module Landing
4
+ */
3
5
  /**
4
6
  * Module dependencies.
5
7
  */
@@ -36,33 +38,37 @@ Base.colors.runway = 90;
36
38
  /**
37
39
  * Initialize a new `Landing` reporter.
38
40
  *
41
+ * @public
42
+ * @class
43
+ * @memberof Mocha.reporters
44
+ * @extends Mocha.reporters.Base
39
45
  * @api public
40
46
  * @param {Runner} runner
41
47
  */
42
- function Landing (runner) {
48
+ function Landing(runner) {
43
49
  Base.call(this, runner);
44
50
 
45
51
  var self = this;
46
- var width = Base.window.width * 0.75 | 0;
52
+ var width = (Base.window.width * 0.75) | 0;
47
53
  var total = runner.total;
48
54
  var stream = process.stdout;
49
55
  var plane = color('plane', '✈');
50
56
  var crashed = -1;
51
57
  var n = 0;
52
58
 
53
- function runway () {
59
+ function runway() {
54
60
  var buf = Array(width).join('-');
55
61
  return ' ' + color('runway', buf);
56
62
  }
57
63
 
58
- runner.on('start', function () {
64
+ runner.on('start', function() {
59
65
  stream.write('\n\n\n ');
60
66
  cursor.hide();
61
67
  });
62
68
 
63
- runner.on('test end', function (test) {
69
+ runner.on('test end', function(test) {
64
70
  // check if the plane crashed
65
- var col = crashed === -1 ? width * ++n / total | 0 : crashed;
71
+ var col = crashed === -1 ? (width * ++n / total) | 0 : crashed;
66
72
 
67
73
  // show the crash
68
74
  if (test.state === 'failed') {
@@ -81,7 +87,7 @@ function Landing (runner) {
81
87
  stream.write('\u001b[0m');
82
88
  });
83
89
 
84
- runner.once('end', function () {
90
+ runner.once('end', function() {
85
91
  cursor.show();
86
92
  console.log();
87
93
  self.epilogue();