mocha 6.1.0 → 6.1.4

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 (61) hide show
  1. package/CHANGELOG.md +1776 -1751
  2. package/LICENSE +22 -22
  3. package/README.md +105 -105
  4. package/bin/_mocha +10 -10
  5. package/bin/mocha +149 -149
  6. package/bin/options.js +10 -10
  7. package/browser-entry.js +191 -191
  8. package/index.js +3 -3
  9. package/lib/browser/growl.js +168 -168
  10. package/lib/browser/progress.js +119 -119
  11. package/lib/browser/template.html +18 -18
  12. package/lib/browser/tty.js +13 -13
  13. package/lib/cli/cli.js +69 -69
  14. package/lib/cli/commands.js +13 -13
  15. package/lib/cli/config.js +101 -101
  16. package/lib/cli/index.js +9 -9
  17. package/lib/cli/init.js +37 -37
  18. package/lib/cli/node-flags.js +86 -86
  19. package/lib/cli/one-and-dones.js +70 -70
  20. package/lib/cli/options.js +347 -347
  21. package/lib/cli/run-helpers.js +337 -337
  22. package/lib/cli/run-option-metadata.js +76 -76
  23. package/lib/cli/run.js +297 -297
  24. package/lib/context.js +101 -101
  25. package/lib/errors.js +141 -141
  26. package/lib/growl.js +136 -136
  27. package/lib/hook.js +46 -46
  28. package/lib/interfaces/bdd.js +118 -118
  29. package/lib/interfaces/common.js +191 -191
  30. package/lib/interfaces/exports.js +60 -60
  31. package/lib/interfaces/index.js +6 -6
  32. package/lib/interfaces/qunit.js +99 -99
  33. package/lib/interfaces/tdd.js +107 -107
  34. package/lib/mocha.js +843 -843
  35. package/lib/mocharc.json +10 -10
  36. package/lib/pending.js +12 -12
  37. package/lib/reporters/base.js +491 -491
  38. package/lib/reporters/doc.js +85 -85
  39. package/lib/reporters/dot.js +81 -81
  40. package/lib/reporters/html.js +390 -390
  41. package/lib/reporters/index.js +19 -19
  42. package/lib/reporters/json-stream.js +90 -90
  43. package/lib/reporters/json.js +135 -135
  44. package/lib/reporters/landing.js +108 -108
  45. package/lib/reporters/list.js +78 -78
  46. package/lib/reporters/markdown.js +112 -112
  47. package/lib/reporters/min.js +52 -52
  48. package/lib/reporters/nyan.js +276 -276
  49. package/lib/reporters/progress.js +104 -104
  50. package/lib/reporters/spec.js +99 -99
  51. package/lib/reporters/tap.js +294 -294
  52. package/lib/reporters/xunit.js +216 -216
  53. package/lib/runnable.js +496 -496
  54. package/lib/runner.js +1049 -1049
  55. package/lib/stats-collector.js +83 -83
  56. package/lib/suite.js +642 -642
  57. package/lib/test.js +51 -51
  58. package/lib/utils.js +897 -897
  59. package/mocha.css +326 -326
  60. package/mocha.js +8170 -8476
  61. package/package.json +630 -628
@@ -1,52 +1,52 @@
1
- 'use strict';
2
- /**
3
- * @module Min
4
- */
5
- /**
6
- * Module dependencies.
7
- */
8
-
9
- var Base = require('./base');
10
- var inherits = require('../utils').inherits;
11
- var constants = require('../runner').constants;
12
- var EVENT_RUN_END = constants.EVENT_RUN_END;
13
- var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
14
-
15
- /**
16
- * Expose `Min`.
17
- */
18
-
19
- exports = module.exports = Min;
20
-
21
- /**
22
- * Constructs a new `Min` reporter instance.
23
- *
24
- * @description
25
- * This minimal test reporter is best used with '--watch'.
26
- *
27
- * @public
28
- * @class
29
- * @memberof Mocha.reporters
30
- * @extends Mocha.reporters.Base
31
- * @param {Runner} runner - Instance triggers reporter actions.
32
- * @param {Object} [options] - runner options
33
- */
34
- function Min(runner, options) {
35
- Base.call(this, runner, options);
36
-
37
- runner.on(EVENT_RUN_BEGIN, function() {
38
- // clear screen
39
- process.stdout.write('\u001b[2J');
40
- // set cursor position
41
- process.stdout.write('\u001b[1;3H');
42
- });
43
-
44
- runner.once(EVENT_RUN_END, this.epilogue.bind(this));
45
- }
46
-
47
- /**
48
- * Inherit from `Base.prototype`.
49
- */
50
- inherits(Min, Base);
51
-
52
- Min.description = 'essentially just a summary';
1
+ 'use strict';
2
+ /**
3
+ * @module Min
4
+ */
5
+ /**
6
+ * Module dependencies.
7
+ */
8
+
9
+ var Base = require('./base');
10
+ var inherits = require('../utils').inherits;
11
+ var constants = require('../runner').constants;
12
+ var EVENT_RUN_END = constants.EVENT_RUN_END;
13
+ var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
14
+
15
+ /**
16
+ * Expose `Min`.
17
+ */
18
+
19
+ exports = module.exports = Min;
20
+
21
+ /**
22
+ * Constructs a new `Min` reporter instance.
23
+ *
24
+ * @description
25
+ * This minimal test reporter is best used with '--watch'.
26
+ *
27
+ * @public
28
+ * @class
29
+ * @memberof Mocha.reporters
30
+ * @extends Mocha.reporters.Base
31
+ * @param {Runner} runner - Instance triggers reporter actions.
32
+ * @param {Object} [options] - runner options
33
+ */
34
+ function Min(runner, options) {
35
+ Base.call(this, runner, options);
36
+
37
+ runner.on(EVENT_RUN_BEGIN, function() {
38
+ // clear screen
39
+ process.stdout.write('\u001b[2J');
40
+ // set cursor position
41
+ process.stdout.write('\u001b[1;3H');
42
+ });
43
+
44
+ runner.once(EVENT_RUN_END, this.epilogue.bind(this));
45
+ }
46
+
47
+ /**
48
+ * Inherit from `Base.prototype`.
49
+ */
50
+ inherits(Min, Base);
51
+
52
+ Min.description = 'essentially just a summary';
@@ -1,276 +1,276 @@
1
- 'use strict';
2
- /**
3
- * @module Nyan
4
- */
5
- /**
6
- * Module dependencies.
7
- */
8
-
9
- var Base = require('./base');
10
- var constants = require('../runner').constants;
11
- var inherits = require('../utils').inherits;
12
- var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
13
- var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
14
- var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
15
- var EVENT_RUN_END = constants.EVENT_RUN_END;
16
- var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
17
-
18
- /**
19
- * Expose `Dot`.
20
- */
21
-
22
- exports = module.exports = NyanCat;
23
-
24
- /**
25
- * Constructs a new `Nyan` reporter instance.
26
- *
27
- * @public
28
- * @class Nyan
29
- * @memberof Mocha.reporters
30
- * @extends Mocha.reporters.Base
31
- * @param {Runner} runner - Instance triggers reporter actions.
32
- * @param {Object} [options] - runner options
33
- */
34
- function NyanCat(runner, options) {
35
- Base.call(this, runner, options);
36
-
37
- var self = this;
38
- var width = (Base.window.width * 0.75) | 0;
39
- var nyanCatWidth = (this.nyanCatWidth = 11);
40
-
41
- this.colorIndex = 0;
42
- this.numberOfLines = 4;
43
- this.rainbowColors = self.generateColors();
44
- this.scoreboardWidth = 5;
45
- this.tick = 0;
46
- this.trajectories = [[], [], [], []];
47
- this.trajectoryWidthMax = width - nyanCatWidth;
48
-
49
- runner.on(EVENT_RUN_BEGIN, function() {
50
- Base.cursor.hide();
51
- self.draw();
52
- });
53
-
54
- runner.on(EVENT_TEST_PENDING, function() {
55
- self.draw();
56
- });
57
-
58
- runner.on(EVENT_TEST_PASS, function() {
59
- self.draw();
60
- });
61
-
62
- runner.on(EVENT_TEST_FAIL, function() {
63
- self.draw();
64
- });
65
-
66
- runner.once(EVENT_RUN_END, function() {
67
- Base.cursor.show();
68
- for (var i = 0; i < self.numberOfLines; i++) {
69
- write('\n');
70
- }
71
- self.epilogue();
72
- });
73
- }
74
-
75
- /**
76
- * Inherit from `Base.prototype`.
77
- */
78
- inherits(NyanCat, Base);
79
-
80
- /**
81
- * Draw the nyan cat
82
- *
83
- * @private
84
- */
85
-
86
- NyanCat.prototype.draw = function() {
87
- this.appendRainbow();
88
- this.drawScoreboard();
89
- this.drawRainbow();
90
- this.drawNyanCat();
91
- this.tick = !this.tick;
92
- };
93
-
94
- /**
95
- * Draw the "scoreboard" showing the number
96
- * of passes, failures and pending tests.
97
- *
98
- * @private
99
- */
100
-
101
- NyanCat.prototype.drawScoreboard = function() {
102
- var stats = this.stats;
103
-
104
- function draw(type, n) {
105
- write(' ');
106
- write(Base.color(type, n));
107
- write('\n');
108
- }
109
-
110
- draw('green', stats.passes);
111
- draw('fail', stats.failures);
112
- draw('pending', stats.pending);
113
- write('\n');
114
-
115
- this.cursorUp(this.numberOfLines);
116
- };
117
-
118
- /**
119
- * Append the rainbow.
120
- *
121
- * @private
122
- */
123
-
124
- NyanCat.prototype.appendRainbow = function() {
125
- var segment = this.tick ? '_' : '-';
126
- var rainbowified = this.rainbowify(segment);
127
-
128
- for (var index = 0; index < this.numberOfLines; index++) {
129
- var trajectory = this.trajectories[index];
130
- if (trajectory.length >= this.trajectoryWidthMax) {
131
- trajectory.shift();
132
- }
133
- trajectory.push(rainbowified);
134
- }
135
- };
136
-
137
- /**
138
- * Draw the rainbow.
139
- *
140
- * @private
141
- */
142
-
143
- NyanCat.prototype.drawRainbow = function() {
144
- var self = this;
145
-
146
- this.trajectories.forEach(function(line) {
147
- write('\u001b[' + self.scoreboardWidth + 'C');
148
- write(line.join(''));
149
- write('\n');
150
- });
151
-
152
- this.cursorUp(this.numberOfLines);
153
- };
154
-
155
- /**
156
- * Draw the nyan cat
157
- *
158
- * @private
159
- */
160
- NyanCat.prototype.drawNyanCat = function() {
161
- var self = this;
162
- var startWidth = this.scoreboardWidth + this.trajectories[0].length;
163
- var dist = '\u001b[' + startWidth + 'C';
164
- var padding = '';
165
-
166
- write(dist);
167
- write('_,------,');
168
- write('\n');
169
-
170
- write(dist);
171
- padding = self.tick ? ' ' : ' ';
172
- write('_|' + padding + '/\\_/\\ ');
173
- write('\n');
174
-
175
- write(dist);
176
- padding = self.tick ? '_' : '__';
177
- var tail = self.tick ? '~' : '^';
178
- write(tail + '|' + padding + this.face() + ' ');
179
- write('\n');
180
-
181
- write(dist);
182
- padding = self.tick ? ' ' : ' ';
183
- write(padding + '"" "" ');
184
- write('\n');
185
-
186
- this.cursorUp(this.numberOfLines);
187
- };
188
-
189
- /**
190
- * Draw nyan cat face.
191
- *
192
- * @private
193
- * @return {string}
194
- */
195
-
196
- NyanCat.prototype.face = function() {
197
- var stats = this.stats;
198
- if (stats.failures) {
199
- return '( x .x)';
200
- } else if (stats.pending) {
201
- return '( o .o)';
202
- } else if (stats.passes) {
203
- return '( ^ .^)';
204
- }
205
- return '( - .-)';
206
- };
207
-
208
- /**
209
- * Move cursor up `n`.
210
- *
211
- * @private
212
- * @param {number} n
213
- */
214
-
215
- NyanCat.prototype.cursorUp = function(n) {
216
- write('\u001b[' + n + 'A');
217
- };
218
-
219
- /**
220
- * Move cursor down `n`.
221
- *
222
- * @private
223
- * @param {number} n
224
- */
225
-
226
- NyanCat.prototype.cursorDown = function(n) {
227
- write('\u001b[' + n + 'B');
228
- };
229
-
230
- /**
231
- * Generate rainbow colors.
232
- *
233
- * @private
234
- * @return {Array}
235
- */
236
- NyanCat.prototype.generateColors = function() {
237
- var colors = [];
238
-
239
- for (var i = 0; i < 6 * 7; i++) {
240
- var pi3 = Math.floor(Math.PI / 3);
241
- var n = i * (1.0 / 6);
242
- var r = Math.floor(3 * Math.sin(n) + 3);
243
- var g = Math.floor(3 * Math.sin(n + 2 * pi3) + 3);
244
- var b = Math.floor(3 * Math.sin(n + 4 * pi3) + 3);
245
- colors.push(36 * r + 6 * g + b + 16);
246
- }
247
-
248
- return colors;
249
- };
250
-
251
- /**
252
- * Apply rainbow to the given `str`.
253
- *
254
- * @private
255
- * @param {string} str
256
- * @return {string}
257
- */
258
- NyanCat.prototype.rainbowify = function(str) {
259
- if (!Base.useColors) {
260
- return str;
261
- }
262
- var color = this.rainbowColors[this.colorIndex % this.rainbowColors.length];
263
- this.colorIndex += 1;
264
- return '\u001b[38;5;' + color + 'm' + str + '\u001b[0m';
265
- };
266
-
267
- /**
268
- * Stdout helper.
269
- *
270
- * @param {string} string A message to write to stdout.
271
- */
272
- function write(string) {
273
- process.stdout.write(string);
274
- }
275
-
276
- NyanCat.description = '"nyan cat"';
1
+ 'use strict';
2
+ /**
3
+ * @module Nyan
4
+ */
5
+ /**
6
+ * Module dependencies.
7
+ */
8
+
9
+ var Base = require('./base');
10
+ var constants = require('../runner').constants;
11
+ var inherits = require('../utils').inherits;
12
+ var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
13
+ var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
14
+ var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
15
+ var EVENT_RUN_END = constants.EVENT_RUN_END;
16
+ var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
17
+
18
+ /**
19
+ * Expose `Dot`.
20
+ */
21
+
22
+ exports = module.exports = NyanCat;
23
+
24
+ /**
25
+ * Constructs a new `Nyan` reporter instance.
26
+ *
27
+ * @public
28
+ * @class Nyan
29
+ * @memberof Mocha.reporters
30
+ * @extends Mocha.reporters.Base
31
+ * @param {Runner} runner - Instance triggers reporter actions.
32
+ * @param {Object} [options] - runner options
33
+ */
34
+ function NyanCat(runner, options) {
35
+ Base.call(this, runner, options);
36
+
37
+ var self = this;
38
+ var width = (Base.window.width * 0.75) | 0;
39
+ var nyanCatWidth = (this.nyanCatWidth = 11);
40
+
41
+ this.colorIndex = 0;
42
+ this.numberOfLines = 4;
43
+ this.rainbowColors = self.generateColors();
44
+ this.scoreboardWidth = 5;
45
+ this.tick = 0;
46
+ this.trajectories = [[], [], [], []];
47
+ this.trajectoryWidthMax = width - nyanCatWidth;
48
+
49
+ runner.on(EVENT_RUN_BEGIN, function() {
50
+ Base.cursor.hide();
51
+ self.draw();
52
+ });
53
+
54
+ runner.on(EVENT_TEST_PENDING, function() {
55
+ self.draw();
56
+ });
57
+
58
+ runner.on(EVENT_TEST_PASS, function() {
59
+ self.draw();
60
+ });
61
+
62
+ runner.on(EVENT_TEST_FAIL, function() {
63
+ self.draw();
64
+ });
65
+
66
+ runner.once(EVENT_RUN_END, function() {
67
+ Base.cursor.show();
68
+ for (var i = 0; i < self.numberOfLines; i++) {
69
+ write('\n');
70
+ }
71
+ self.epilogue();
72
+ });
73
+ }
74
+
75
+ /**
76
+ * Inherit from `Base.prototype`.
77
+ */
78
+ inherits(NyanCat, Base);
79
+
80
+ /**
81
+ * Draw the nyan cat
82
+ *
83
+ * @private
84
+ */
85
+
86
+ NyanCat.prototype.draw = function() {
87
+ this.appendRainbow();
88
+ this.drawScoreboard();
89
+ this.drawRainbow();
90
+ this.drawNyanCat();
91
+ this.tick = !this.tick;
92
+ };
93
+
94
+ /**
95
+ * Draw the "scoreboard" showing the number
96
+ * of passes, failures and pending tests.
97
+ *
98
+ * @private
99
+ */
100
+
101
+ NyanCat.prototype.drawScoreboard = function() {
102
+ var stats = this.stats;
103
+
104
+ function draw(type, n) {
105
+ write(' ');
106
+ write(Base.color(type, n));
107
+ write('\n');
108
+ }
109
+
110
+ draw('green', stats.passes);
111
+ draw('fail', stats.failures);
112
+ draw('pending', stats.pending);
113
+ write('\n');
114
+
115
+ this.cursorUp(this.numberOfLines);
116
+ };
117
+
118
+ /**
119
+ * Append the rainbow.
120
+ *
121
+ * @private
122
+ */
123
+
124
+ NyanCat.prototype.appendRainbow = function() {
125
+ var segment = this.tick ? '_' : '-';
126
+ var rainbowified = this.rainbowify(segment);
127
+
128
+ for (var index = 0; index < this.numberOfLines; index++) {
129
+ var trajectory = this.trajectories[index];
130
+ if (trajectory.length >= this.trajectoryWidthMax) {
131
+ trajectory.shift();
132
+ }
133
+ trajectory.push(rainbowified);
134
+ }
135
+ };
136
+
137
+ /**
138
+ * Draw the rainbow.
139
+ *
140
+ * @private
141
+ */
142
+
143
+ NyanCat.prototype.drawRainbow = function() {
144
+ var self = this;
145
+
146
+ this.trajectories.forEach(function(line) {
147
+ write('\u001b[' + self.scoreboardWidth + 'C');
148
+ write(line.join(''));
149
+ write('\n');
150
+ });
151
+
152
+ this.cursorUp(this.numberOfLines);
153
+ };
154
+
155
+ /**
156
+ * Draw the nyan cat
157
+ *
158
+ * @private
159
+ */
160
+ NyanCat.prototype.drawNyanCat = function() {
161
+ var self = this;
162
+ var startWidth = this.scoreboardWidth + this.trajectories[0].length;
163
+ var dist = '\u001b[' + startWidth + 'C';
164
+ var padding = '';
165
+
166
+ write(dist);
167
+ write('_,------,');
168
+ write('\n');
169
+
170
+ write(dist);
171
+ padding = self.tick ? ' ' : ' ';
172
+ write('_|' + padding + '/\\_/\\ ');
173
+ write('\n');
174
+
175
+ write(dist);
176
+ padding = self.tick ? '_' : '__';
177
+ var tail = self.tick ? '~' : '^';
178
+ write(tail + '|' + padding + this.face() + ' ');
179
+ write('\n');
180
+
181
+ write(dist);
182
+ padding = self.tick ? ' ' : ' ';
183
+ write(padding + '"" "" ');
184
+ write('\n');
185
+
186
+ this.cursorUp(this.numberOfLines);
187
+ };
188
+
189
+ /**
190
+ * Draw nyan cat face.
191
+ *
192
+ * @private
193
+ * @return {string}
194
+ */
195
+
196
+ NyanCat.prototype.face = function() {
197
+ var stats = this.stats;
198
+ if (stats.failures) {
199
+ return '( x .x)';
200
+ } else if (stats.pending) {
201
+ return '( o .o)';
202
+ } else if (stats.passes) {
203
+ return '( ^ .^)';
204
+ }
205
+ return '( - .-)';
206
+ };
207
+
208
+ /**
209
+ * Move cursor up `n`.
210
+ *
211
+ * @private
212
+ * @param {number} n
213
+ */
214
+
215
+ NyanCat.prototype.cursorUp = function(n) {
216
+ write('\u001b[' + n + 'A');
217
+ };
218
+
219
+ /**
220
+ * Move cursor down `n`.
221
+ *
222
+ * @private
223
+ * @param {number} n
224
+ */
225
+
226
+ NyanCat.prototype.cursorDown = function(n) {
227
+ write('\u001b[' + n + 'B');
228
+ };
229
+
230
+ /**
231
+ * Generate rainbow colors.
232
+ *
233
+ * @private
234
+ * @return {Array}
235
+ */
236
+ NyanCat.prototype.generateColors = function() {
237
+ var colors = [];
238
+
239
+ for (var i = 0; i < 6 * 7; i++) {
240
+ var pi3 = Math.floor(Math.PI / 3);
241
+ var n = i * (1.0 / 6);
242
+ var r = Math.floor(3 * Math.sin(n) + 3);
243
+ var g = Math.floor(3 * Math.sin(n + 2 * pi3) + 3);
244
+ var b = Math.floor(3 * Math.sin(n + 4 * pi3) + 3);
245
+ colors.push(36 * r + 6 * g + b + 16);
246
+ }
247
+
248
+ return colors;
249
+ };
250
+
251
+ /**
252
+ * Apply rainbow to the given `str`.
253
+ *
254
+ * @private
255
+ * @param {string} str
256
+ * @return {string}
257
+ */
258
+ NyanCat.prototype.rainbowify = function(str) {
259
+ if (!Base.useColors) {
260
+ return str;
261
+ }
262
+ var color = this.rainbowColors[this.colorIndex % this.rainbowColors.length];
263
+ this.colorIndex += 1;
264
+ return '\u001b[38;5;' + color + 'm' + str + '\u001b[0m';
265
+ };
266
+
267
+ /**
268
+ * Stdout helper.
269
+ *
270
+ * @param {string} string A message to write to stdout.
271
+ */
272
+ function write(string) {
273
+ process.stdout.write(string);
274
+ }
275
+
276
+ NyanCat.description = '"nyan cat"';