mocha 3.0.2 → 3.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 (53) hide show
  1. package/CHANGELOG.md +103 -0
  2. package/LICENSE +1 -1
  3. package/README.md +2 -2
  4. package/bin/_mocha +170 -104
  5. package/bin/mocha +22 -13
  6. package/bin/options.js +7 -5
  7. package/browser-entry.js +43 -22
  8. package/lib/browser/.eslintrc.yaml +4 -0
  9. package/lib/browser/debug.js +6 -3
  10. package/lib/browser/events.js +11 -9
  11. package/lib/browser/progress.js +9 -7
  12. package/lib/browser/tty.js +4 -2
  13. package/lib/context.js +11 -9
  14. package/lib/hook.js +4 -2
  15. package/lib/interfaces/bdd.js +11 -9
  16. package/lib/interfaces/common.js +16 -14
  17. package/lib/interfaces/exports.js +4 -2
  18. package/lib/interfaces/index.js +2 -0
  19. package/lib/interfaces/qunit.js +12 -8
  20. package/lib/interfaces/tdd.js +9 -7
  21. package/lib/mocha.js +36 -34
  22. package/lib/ms.js +12 -10
  23. package/lib/pending.js +2 -1
  24. package/lib/reporters/base.js +52 -50
  25. package/lib/reporters/doc.js +8 -6
  26. package/lib/reporters/dot.js +9 -7
  27. package/lib/reporters/html.js +32 -30
  28. package/lib/reporters/index.js +2 -0
  29. package/lib/reporters/json-stream.js +8 -6
  30. package/lib/reporters/json.js +11 -9
  31. package/lib/reporters/landing.js +8 -6
  32. package/lib/reporters/list.js +13 -11
  33. package/lib/reporters/markdown.js +12 -10
  34. package/lib/reporters/min.js +4 -2
  35. package/lib/reporters/nyan.js +22 -20
  36. package/lib/reporters/progress.js +7 -5
  37. package/lib/reporters/spec.js +17 -15
  38. package/lib/reporters/tap.js +10 -8
  39. package/lib/reporters/xunit.js +14 -12
  40. package/lib/runnable.js +43 -32
  41. package/lib/runner.js +78 -63
  42. package/lib/suite.js +24 -22
  43. package/lib/test.js +4 -2
  44. package/lib/utils.js +115 -90
  45. package/mocha.js +1185 -800
  46. package/package.json +9 -2
  47. package/lib/interfaces/bdd.js.orig +0 -118
  48. package/lib/mocha.js.orig +0 -532
  49. package/lib/runnable.js.orig +0 -378
  50. package/lib/runner.js.orig +0 -934
  51. package/lib/suite.js.orig +0 -418
  52. package/lib/test.js.orig +0 -52
  53. package/lib/utils.js.orig +0 -758
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  /**
2
4
  * Module dependencies.
3
5
  */
@@ -16,7 +18,7 @@ exports = module.exports = JSONReporter;
16
18
  * @api public
17
19
  * @param {Runner} runner
18
20
  */
19
- function JSONReporter(runner) {
21
+ function JSONReporter (runner) {
20
22
  Base.call(this, runner);
21
23
 
22
24
  var self = this;
@@ -25,23 +27,23 @@ function JSONReporter(runner) {
25
27
  var failures = [];
26
28
  var passes = [];
27
29
 
28
- runner.on('test end', function(test) {
30
+ runner.on('test end', function (test) {
29
31
  tests.push(test);
30
32
  });
31
33
 
32
- runner.on('pass', function(test) {
34
+ runner.on('pass', function (test) {
33
35
  passes.push(test);
34
36
  });
35
37
 
36
- runner.on('fail', function(test) {
38
+ runner.on('fail', function (test) {
37
39
  failures.push(test);
38
40
  });
39
41
 
40
- runner.on('pending', function(test) {
42
+ runner.on('pending', function (test) {
41
43
  pending.push(test);
42
44
  });
43
45
 
44
- runner.on('end', function() {
46
+ runner.on('end', function () {
45
47
  var obj = {
46
48
  stats: self.stats,
47
49
  tests: tests.map(clean),
@@ -64,7 +66,7 @@ function JSONReporter(runner) {
64
66
  * @param {Object} test
65
67
  * @return {Object}
66
68
  */
67
- function clean(test) {
69
+ function clean (test) {
68
70
  return {
69
71
  title: test.title,
70
72
  fullTitle: test.fullTitle(),
@@ -81,9 +83,9 @@ function clean(test) {
81
83
  * @param {Error} err
82
84
  * @return {Object}
83
85
  */
84
- function errorJSON(err) {
86
+ function errorJSON (err) {
85
87
  var res = {};
86
- Object.getOwnPropertyNames(err).forEach(function(key) {
88
+ Object.getOwnPropertyNames(err).forEach(function (key) {
87
89
  res[key] = err[key];
88
90
  }, err);
89
91
  return res;
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  /**
2
4
  * Module dependencies.
3
5
  */
@@ -37,28 +39,28 @@ Base.colors.runway = 90;
37
39
  * @api public
38
40
  * @param {Runner} runner
39
41
  */
40
- function Landing(runner) {
42
+ function Landing (runner) {
41
43
  Base.call(this, runner);
42
44
 
43
45
  var self = this;
44
- var width = Base.window.width * .75 | 0;
46
+ var width = Base.window.width * 0.75 | 0;
45
47
  var total = runner.total;
46
48
  var stream = process.stdout;
47
49
  var plane = color('plane', '✈');
48
50
  var crashed = -1;
49
51
  var n = 0;
50
52
 
51
- function runway() {
53
+ function runway () {
52
54
  var buf = Array(width).join('-');
53
55
  return ' ' + color('runway', buf);
54
56
  }
55
57
 
56
- runner.on('start', function() {
58
+ runner.on('start', function () {
57
59
  stream.write('\n\n\n ');
58
60
  cursor.hide();
59
61
  });
60
62
 
61
- runner.on('test end', function(test) {
63
+ runner.on('test end', function (test) {
62
64
  // check if the plane crashed
63
65
  var col = crashed === -1 ? width * ++n / total | 0 : crashed;
64
66
 
@@ -79,7 +81,7 @@ function Landing(runner) {
79
81
  stream.write('\u001b[0m');
80
82
  });
81
83
 
82
- runner.on('end', function() {
84
+ runner.on('end', function () {
83
85
  cursor.show();
84
86
  console.log();
85
87
  self.epilogue();
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  /**
2
4
  * Module dependencies.
3
5
  */
@@ -19,35 +21,35 @@ exports = module.exports = List;
19
21
  * @api public
20
22
  * @param {Runner} runner
21
23
  */
22
- function List(runner) {
24
+ function List (runner) {
23
25
  Base.call(this, runner);
24
26
 
25
27
  var self = this;
26
28
  var n = 0;
27
29
 
28
- runner.on('start', function() {
30
+ runner.on('start', function () {
29
31
  console.log();
30
32
  });
31
33
 
32
- runner.on('test', function(test) {
34
+ runner.on('test', function (test) {
33
35
  process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));
34
36
  });
35
37
 
36
- runner.on('pending', function(test) {
37
- var fmt = color('checkmark', ' -')
38
- + color('pending', ' %s');
38
+ runner.on('pending', function (test) {
39
+ var fmt = color('checkmark', ' -') +
40
+ color('pending', ' %s');
39
41
  console.log(fmt, test.fullTitle());
40
42
  });
41
43
 
42
- runner.on('pass', function(test) {
43
- var fmt = color('checkmark', ' ' + Base.symbols.dot)
44
- + color('pass', ' %s: ')
45
- + color(test.speed, '%dms');
44
+ runner.on('pass', function (test) {
45
+ var fmt = color('checkmark', ' ' + Base.symbols.ok) +
46
+ color('pass', ' %s: ') +
47
+ color(test.speed, '%dms');
46
48
  cursor.CR();
47
49
  console.log(fmt, test.fullTitle(), test.duration);
48
50
  });
49
51
 
50
- runner.on('fail', function(test) {
52
+ runner.on('fail', function (test) {
51
53
  cursor.CR();
52
54
  console.log(color('fail', ' %d) %s'), ++n, test.fullTitle());
53
55
  });
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  /**
2
4
  * Module dependencies.
3
5
  */
@@ -23,29 +25,29 @@ exports = module.exports = Markdown;
23
25
  * @api public
24
26
  * @param {Runner} runner
25
27
  */
26
- function Markdown(runner) {
28
+ function Markdown (runner) {
27
29
  Base.call(this, runner);
28
30
 
29
31
  var level = 0;
30
32
  var buf = '';
31
33
 
32
- function title(str) {
34
+ function title (str) {
33
35
  return Array(level).join('#') + ' ' + str;
34
36
  }
35
37
 
36
- function mapTOC(suite, obj) {
38
+ function mapTOC (suite, obj) {
37
39
  var ret = obj;
38
40
  var key = SUITE_PREFIX + suite.title;
39
41
 
40
42
  obj = obj[key] = obj[key] || { suite: suite };
41
- suite.suites.forEach(function(suite) {
43
+ suite.suites.forEach(function (suite) {
42
44
  mapTOC(suite, obj);
43
45
  });
44
46
 
45
47
  return ret;
46
48
  }
47
49
 
48
- function stringifyTOC(obj, level) {
50
+ function stringifyTOC (obj, level) {
49
51
  ++level;
50
52
  var buf = '';
51
53
  var link;
@@ -63,25 +65,25 @@ function Markdown(runner) {
63
65
  return buf;
64
66
  }
65
67
 
66
- function generateTOC(suite) {
68
+ function generateTOC (suite) {
67
69
  var obj = mapTOC(suite, {});
68
70
  return stringifyTOC(obj, 0);
69
71
  }
70
72
 
71
73
  generateTOC(runner.suite);
72
74
 
73
- runner.on('suite', function(suite) {
75
+ runner.on('suite', function (suite) {
74
76
  ++level;
75
77
  var slug = utils.slug(suite.fullTitle());
76
78
  buf += '<a name="' + slug + '"></a>' + '\n';
77
79
  buf += title(suite.title) + '\n';
78
80
  });
79
81
 
80
- runner.on('suite end', function() {
82
+ runner.on('suite end', function () {
81
83
  --level;
82
84
  });
83
85
 
84
- runner.on('pass', function(test) {
86
+ runner.on('pass', function (test) {
85
87
  var code = utils.clean(test.body);
86
88
  buf += test.title + '.\n';
87
89
  buf += '\n```js\n';
@@ -89,7 +91,7 @@ function Markdown(runner) {
89
91
  buf += '```\n\n';
90
92
  });
91
93
 
92
- runner.on('end', function() {
94
+ runner.on('end', function () {
93
95
  process.stdout.write('# TOC\n');
94
96
  process.stdout.write(generateTOC(runner.suite));
95
97
  process.stdout.write(buf);
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  /**
2
4
  * Module dependencies.
3
5
  */
@@ -17,10 +19,10 @@ exports = module.exports = Min;
17
19
  * @api public
18
20
  * @param {Runner} runner
19
21
  */
20
- function Min(runner) {
22
+ function Min (runner) {
21
23
  Base.call(this, runner);
22
24
 
23
- runner.on('start', function() {
25
+ runner.on('start', function () {
24
26
  // clear screen
25
27
  process.stdout.write('\u001b[2J');
26
28
  // set cursor position
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  /**
2
4
  * Module dependencies.
3
5
  */
@@ -18,11 +20,11 @@ exports = module.exports = NyanCat;
18
20
  * @api public
19
21
  */
20
22
 
21
- function NyanCat(runner) {
23
+ function NyanCat (runner) {
22
24
  Base.call(this, runner);
23
25
 
24
26
  var self = this;
25
- var width = Base.window.width * .75 | 0;
27
+ var width = Base.window.width * 0.75 | 0;
26
28
  var nyanCatWidth = this.nyanCatWidth = 11;
27
29
 
28
30
  this.colorIndex = 0;
@@ -33,24 +35,24 @@ function NyanCat(runner) {
33
35
  this.trajectories = [[], [], [], []];
34
36
  this.trajectoryWidthMax = (width - nyanCatWidth);
35
37
 
36
- runner.on('start', function() {
38
+ runner.on('start', function () {
37
39
  Base.cursor.hide();
38
40
  self.draw();
39
41
  });
40
42
 
41
- runner.on('pending', function() {
43
+ runner.on('pending', function () {
42
44
  self.draw();
43
45
  });
44
46
 
45
- runner.on('pass', function() {
47
+ runner.on('pass', function () {
46
48
  self.draw();
47
49
  });
48
50
 
49
- runner.on('fail', function() {
51
+ runner.on('fail', function () {
50
52
  self.draw();
51
53
  });
52
54
 
53
- runner.on('end', function() {
55
+ runner.on('end', function () {
54
56
  Base.cursor.show();
55
57
  for (var i = 0; i < self.numberOfLines; i++) {
56
58
  write('\n');
@@ -70,7 +72,7 @@ inherits(NyanCat, Base);
70
72
  * @api private
71
73
  */
72
74
 
73
- NyanCat.prototype.draw = function() {
75
+ NyanCat.prototype.draw = function () {
74
76
  this.appendRainbow();
75
77
  this.drawScoreboard();
76
78
  this.drawRainbow();
@@ -85,10 +87,10 @@ NyanCat.prototype.draw = function() {
85
87
  * @api private
86
88
  */
87
89
 
88
- NyanCat.prototype.drawScoreboard = function() {
90
+ NyanCat.prototype.drawScoreboard = function () {
89
91
  var stats = this.stats;
90
92
 
91
- function draw(type, n) {
93
+ function draw (type, n) {
92
94
  write(' ');
93
95
  write(Base.color(type, n));
94
96
  write('\n');
@@ -108,7 +110,7 @@ NyanCat.prototype.drawScoreboard = function() {
108
110
  * @api private
109
111
  */
110
112
 
111
- NyanCat.prototype.appendRainbow = function() {
113
+ NyanCat.prototype.appendRainbow = function () {
112
114
  var segment = this.tick ? '_' : '-';
113
115
  var rainbowified = this.rainbowify(segment);
114
116
 
@@ -127,10 +129,10 @@ NyanCat.prototype.appendRainbow = function() {
127
129
  * @api private
128
130
  */
129
131
 
130
- NyanCat.prototype.drawRainbow = function() {
132
+ NyanCat.prototype.drawRainbow = function () {
131
133
  var self = this;
132
134
 
133
- this.trajectories.forEach(function(line) {
135
+ this.trajectories.forEach(function (line) {
134
136
  write('\u001b[' + self.scoreboardWidth + 'C');
135
137
  write(line.join(''));
136
138
  write('\n');
@@ -144,7 +146,7 @@ NyanCat.prototype.drawRainbow = function() {
144
146
  *
145
147
  * @api private
146
148
  */
147
- NyanCat.prototype.drawNyanCat = function() {
149
+ NyanCat.prototype.drawNyanCat = function () {
148
150
  var self = this;
149
151
  var startWidth = this.scoreboardWidth + this.trajectories[0].length;
150
152
  var dist = '\u001b[' + startWidth + 'C';
@@ -180,7 +182,7 @@ NyanCat.prototype.drawNyanCat = function() {
180
182
  * @return {string}
181
183
  */
182
184
 
183
- NyanCat.prototype.face = function() {
185
+ NyanCat.prototype.face = function () {
184
186
  var stats = this.stats;
185
187
  if (stats.failures) {
186
188
  return '( x .x)';
@@ -199,7 +201,7 @@ NyanCat.prototype.face = function() {
199
201
  * @param {number} n
200
202
  */
201
203
 
202
- NyanCat.prototype.cursorUp = function(n) {
204
+ NyanCat.prototype.cursorUp = function (n) {
203
205
  write('\u001b[' + n + 'A');
204
206
  };
205
207
 
@@ -210,7 +212,7 @@ NyanCat.prototype.cursorUp = function(n) {
210
212
  * @param {number} n
211
213
  */
212
214
 
213
- NyanCat.prototype.cursorDown = function(n) {
215
+ NyanCat.prototype.cursorDown = function (n) {
214
216
  write('\u001b[' + n + 'B');
215
217
  };
216
218
 
@@ -220,7 +222,7 @@ NyanCat.prototype.cursorDown = function(n) {
220
222
  * @api private
221
223
  * @return {Array}
222
224
  */
223
- NyanCat.prototype.generateColors = function() {
225
+ NyanCat.prototype.generateColors = function () {
224
226
  var colors = [];
225
227
 
226
228
  for (var i = 0; i < (6 * 7); i++) {
@@ -242,7 +244,7 @@ NyanCat.prototype.generateColors = function() {
242
244
  * @param {string} str
243
245
  * @return {string}
244
246
  */
245
- NyanCat.prototype.rainbowify = function(str) {
247
+ NyanCat.prototype.rainbowify = function (str) {
246
248
  if (!Base.useColors) {
247
249
  return str;
248
250
  }
@@ -256,6 +258,6 @@ NyanCat.prototype.rainbowify = function(str) {
256
258
  *
257
259
  * @param {string} string A message to write to stdout.
258
260
  */
259
- function write(string) {
261
+ function write (string) {
260
262
  process.stdout.write(string);
261
263
  }
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  /**
2
4
  * Module dependencies.
3
5
  */
@@ -26,11 +28,11 @@ Base.colors.progress = 90;
26
28
  * @param {Runner} runner
27
29
  * @param {Object} options
28
30
  */
29
- function Progress(runner, options) {
31
+ function Progress (runner, options) {
30
32
  Base.call(this, runner);
31
33
 
32
34
  var self = this;
33
- var width = Base.window.width * .50 | 0;
35
+ var width = Base.window.width * 0.50 | 0;
34
36
  var total = runner.total;
35
37
  var complete = 0;
36
38
  var lastN = -1;
@@ -44,13 +46,13 @@ function Progress(runner, options) {
44
46
  options.verbose = false;
45
47
 
46
48
  // tests started
47
- runner.on('start', function() {
49
+ runner.on('start', function () {
48
50
  console.log();
49
51
  cursor.hide();
50
52
  });
51
53
 
52
54
  // tests complete
53
- runner.on('test end', function() {
55
+ runner.on('test end', function () {
54
56
  complete++;
55
57
 
56
58
  var percent = complete / total;
@@ -76,7 +78,7 @@ function Progress(runner, options) {
76
78
 
77
79
  // tests are complete, output some stats
78
80
  // and the failures if any
79
- runner.on('end', function() {
81
+ runner.on('end', function () {
80
82
  cursor.show();
81
83
  console.log();
82
84
  self.epilogue();
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  /**
2
4
  * Module dependencies.
3
5
  */
@@ -18,55 +20,55 @@ exports = module.exports = Spec;
18
20
  * @api public
19
21
  * @param {Runner} runner
20
22
  */
21
- function Spec(runner) {
23
+ function Spec (runner) {
22
24
  Base.call(this, runner);
23
25
 
24
26
  var self = this;
25
27
  var indents = 0;
26
28
  var n = 0;
27
29
 
28
- function indent() {
30
+ function indent () {
29
31
  return Array(indents).join(' ');
30
32
  }
31
33
 
32
- runner.on('start', function() {
34
+ runner.on('start', function () {
33
35
  console.log();
34
36
  });
35
37
 
36
- runner.on('suite', function(suite) {
38
+ runner.on('suite', function (suite) {
37
39
  ++indents;
38
40
  console.log(color('suite', '%s%s'), indent(), suite.title);
39
41
  });
40
42
 
41
- runner.on('suite end', function() {
43
+ runner.on('suite end', function () {
42
44
  --indents;
43
45
  if (indents === 1) {
44
46
  console.log();
45
47
  }
46
48
  });
47
49
 
48
- runner.on('pending', function(test) {
50
+ runner.on('pending', function (test) {
49
51
  var fmt = indent() + color('pending', ' - %s');
50
52
  console.log(fmt, test.title);
51
53
  });
52
54
 
53
- runner.on('pass', function(test) {
55
+ runner.on('pass', function (test) {
54
56
  var fmt;
55
57
  if (test.speed === 'fast') {
56
- fmt = indent()
57
- + color('checkmark', ' ' + Base.symbols.ok)
58
- + color('pass', ' %s');
58
+ fmt = indent() +
59
+ color('checkmark', ' ' + Base.symbols.ok) +
60
+ color('pass', ' %s');
59
61
  console.log(fmt, test.title);
60
62
  } else {
61
- fmt = indent()
62
- + color('checkmark', ' ' + Base.symbols.ok)
63
- + color('pass', ' %s')
64
- + color(test.speed, ' (%dms)');
63
+ fmt = indent() +
64
+ color('checkmark', ' ' + Base.symbols.ok) +
65
+ color('pass', ' %s') +
66
+ color(test.speed, ' (%dms)');
65
67
  console.log(fmt, test.title, test.duration);
66
68
  }
67
69
  });
68
70
 
69
- runner.on('fail', function(test) {
71
+ runner.on('fail', function (test) {
70
72
  console.log(indent() + color('fail', ' %d) %s'), ++n, test.title);
71
73
  });
72
74
 
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  /**
2
4
  * Module dependencies.
3
5
  */
@@ -16,32 +18,32 @@ exports = module.exports = TAP;
16
18
  * @api public
17
19
  * @param {Runner} runner
18
20
  */
19
- function TAP(runner) {
21
+ function TAP (runner) {
20
22
  Base.call(this, runner);
21
23
 
22
24
  var n = 1;
23
25
  var passes = 0;
24
26
  var failures = 0;
25
27
 
26
- runner.on('start', function() {
28
+ runner.on('start', function () {
27
29
  var total = runner.grepTotal(runner.suite);
28
30
  console.log('%d..%d', 1, total);
29
31
  });
30
32
 
31
- runner.on('test end', function() {
33
+ runner.on('test end', function () {
32
34
  ++n;
33
35
  });
34
36
 
35
- runner.on('pending', function(test) {
37
+ runner.on('pending', function (test) {
36
38
  console.log('ok %d %s # SKIP -', n, title(test));
37
39
  });
38
40
 
39
- runner.on('pass', function(test) {
41
+ runner.on('pass', function (test) {
40
42
  passes++;
41
43
  console.log('ok %d %s', n, title(test));
42
44
  });
43
45
 
44
- runner.on('fail', function(test, err) {
46
+ runner.on('fail', function (test, err) {
45
47
  failures++;
46
48
  console.log('not ok %d %s', n, title(test));
47
49
  if (err.stack) {
@@ -49,7 +51,7 @@ function TAP(runner) {
49
51
  }
50
52
  });
51
53
 
52
- runner.on('end', function() {
54
+ runner.on('end', function () {
53
55
  console.log('# tests ' + (passes + failures));
54
56
  console.log('# pass ' + passes);
55
57
  console.log('# fail ' + failures);
@@ -63,6 +65,6 @@ function TAP(runner) {
63
65
  * @param {Object} test
64
66
  * @return {String}
65
67
  */
66
- function title(test) {
68
+ function title (test) {
67
69
  return test.fullTitle().replace(/#/g, '');
68
70
  }
@@ -1,3 +1,5 @@
1
+ 'use strict';
2
+
1
3
  /**
2
4
  * Module dependencies.
3
5
  */
@@ -34,14 +36,14 @@ exports = module.exports = XUnit;
34
36
  * @api public
35
37
  * @param {Runner} runner
36
38
  */
37
- function XUnit(runner, options) {
39
+ function XUnit (runner, options) {
38
40
  Base.call(this, runner);
39
41
 
40
42
  var stats = this.stats;
41
43
  var tests = [];
42
44
  var self = this;
43
45
 
44
- if (options.reporterOptions && options.reporterOptions.output) {
46
+ if (options && options.reporterOptions && options.reporterOptions.output) {
45
47
  if (!fs.createWriteStream) {
46
48
  throw new Error('file output not supported in browser');
47
49
  }
@@ -49,19 +51,19 @@ function XUnit(runner, options) {
49
51
  self.fileStream = fs.createWriteStream(options.reporterOptions.output);
50
52
  }
51
53
 
52
- runner.on('pending', function(test) {
54
+ runner.on('pending', function (test) {
53
55
  tests.push(test);
54
56
  });
55
57
 
56
- runner.on('pass', function(test) {
58
+ runner.on('pass', function (test) {
57
59
  tests.push(test);
58
60
  });
59
61
 
60
- runner.on('fail', function(test) {
62
+ runner.on('fail', function (test) {
61
63
  tests.push(test);
62
64
  });
63
65
 
64
- runner.on('end', function() {
66
+ runner.on('end', function () {
65
67
  self.write(tag('testsuite', {
66
68
  name: 'Mocha Tests',
67
69
  tests: stats.tests,
@@ -72,7 +74,7 @@ function XUnit(runner, options) {
72
74
  time: (stats.duration / 1000) || 0
73
75
  }, false));
74
76
 
75
- tests.forEach(function(t) {
77
+ tests.forEach(function (t) {
76
78
  self.test(t);
77
79
  });
78
80
 
@@ -91,9 +93,9 @@ inherits(XUnit, Base);
91
93
  * @param failures
92
94
  * @param {Function} fn
93
95
  */
94
- XUnit.prototype.done = function(failures, fn) {
96
+ XUnit.prototype.done = function (failures, fn) {
95
97
  if (this.fileStream) {
96
- this.fileStream.end(function() {
98
+ this.fileStream.end(function () {
97
99
  fn(failures);
98
100
  });
99
101
  } else {
@@ -106,7 +108,7 @@ XUnit.prototype.done = function(failures, fn) {
106
108
  *
107
109
  * @param {string} line
108
110
  */
109
- XUnit.prototype.write = function(line) {
111
+ XUnit.prototype.write = function (line) {
110
112
  if (this.fileStream) {
111
113
  this.fileStream.write(line + '\n');
112
114
  } else if (typeof process === 'object' && process.stdout) {
@@ -121,7 +123,7 @@ XUnit.prototype.write = function(line) {
121
123
  *
122
124
  * @param {Test} test
123
125
  */
124
- XUnit.prototype.test = function(test) {
126
+ XUnit.prototype.test = function (test) {
125
127
  var attrs = {
126
128
  classname: test.parent.fullTitle(),
127
129
  name: test.title,
@@ -147,7 +149,7 @@ XUnit.prototype.test = function(test) {
147
149
  * @param content
148
150
  * @return {string}
149
151
  */
150
- function tag(name, attrs, close, content) {
152
+ function tag (name, attrs, close, content) {
151
153
  var end = close ? '/>' : '>';
152
154
  var pairs = [];
153
155
  var tag;