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
package/browser-entry.js CHANGED
@@ -1,191 +1,191 @@
1
- 'use strict';
2
-
3
- /* eslint no-unused-vars: off */
4
- /* eslint-env commonjs */
5
-
6
- /**
7
- * Shim process.stdout.
8
- */
9
-
10
- process.stdout = require('browser-stdout')({label: false});
11
-
12
- var Mocha = require('./lib/mocha');
13
-
14
- /**
15
- * Create a Mocha instance.
16
- *
17
- * @return {undefined}
18
- */
19
-
20
- var mocha = new Mocha({reporter: 'html'});
21
-
22
- /**
23
- * Save timer references to avoid Sinon interfering (see GH-237).
24
- */
25
-
26
- var Date = global.Date;
27
- var setTimeout = global.setTimeout;
28
- var setInterval = global.setInterval;
29
- var clearTimeout = global.clearTimeout;
30
- var clearInterval = global.clearInterval;
31
-
32
- var uncaughtExceptionHandlers = [];
33
-
34
- var originalOnerrorHandler = global.onerror;
35
-
36
- /**
37
- * Remove uncaughtException listener.
38
- * Revert to original onerror handler if previously defined.
39
- */
40
-
41
- process.removeListener = function(e, fn) {
42
- if (e === 'uncaughtException') {
43
- if (originalOnerrorHandler) {
44
- global.onerror = originalOnerrorHandler;
45
- } else {
46
- global.onerror = function() {};
47
- }
48
- var i = uncaughtExceptionHandlers.indexOf(fn);
49
- if (i !== -1) {
50
- uncaughtExceptionHandlers.splice(i, 1);
51
- }
52
- }
53
- };
54
-
55
- /**
56
- * Implements uncaughtException listener.
57
- */
58
-
59
- process.on = function(e, fn) {
60
- if (e === 'uncaughtException') {
61
- global.onerror = function(err, url, line) {
62
- fn(new Error(err + ' (' + url + ':' + line + ')'));
63
- return !mocha.allowUncaught;
64
- };
65
- uncaughtExceptionHandlers.push(fn);
66
- }
67
- };
68
-
69
- // The BDD UI is registered by default, but no UI will be functional in the
70
- // browser without an explicit call to the overridden `mocha.ui` (see below).
71
- // Ensure that this default UI does not expose its methods to the global scope.
72
- mocha.suite.removeAllListeners('pre-require');
73
-
74
- var immediateQueue = [];
75
- var immediateTimeout;
76
-
77
- function timeslice() {
78
- var immediateStart = new Date().getTime();
79
- while (immediateQueue.length && new Date().getTime() - immediateStart < 100) {
80
- immediateQueue.shift()();
81
- }
82
- if (immediateQueue.length) {
83
- immediateTimeout = setTimeout(timeslice, 0);
84
- } else {
85
- immediateTimeout = null;
86
- }
87
- }
88
-
89
- /**
90
- * High-performance override of Runner.immediately.
91
- */
92
-
93
- Mocha.Runner.immediately = function(callback) {
94
- immediateQueue.push(callback);
95
- if (!immediateTimeout) {
96
- immediateTimeout = setTimeout(timeslice, 0);
97
- }
98
- };
99
-
100
- /**
101
- * Function to allow assertion libraries to throw errors directly into mocha.
102
- * This is useful when running tests in a browser because window.onerror will
103
- * only receive the 'message' attribute of the Error.
104
- */
105
- mocha.throwError = function(err) {
106
- uncaughtExceptionHandlers.forEach(function(fn) {
107
- fn(err);
108
- });
109
- throw err;
110
- };
111
-
112
- /**
113
- * Override ui to ensure that the ui functions are initialized.
114
- * Normally this would happen in Mocha.prototype.loadFiles.
115
- */
116
-
117
- mocha.ui = function(ui) {
118
- Mocha.prototype.ui.call(this, ui);
119
- this.suite.emit('pre-require', global, null, this);
120
- return this;
121
- };
122
-
123
- /**
124
- * Setup mocha with the given setting options.
125
- */
126
-
127
- mocha.setup = function(opts) {
128
- if (typeof opts === 'string') {
129
- opts = {ui: opts};
130
- }
131
- for (var opt in opts) {
132
- if (opts.hasOwnProperty(opt)) {
133
- this[opt](opts[opt]);
134
- }
135
- }
136
- return this;
137
- };
138
-
139
- /**
140
- * Run mocha, returning the Runner.
141
- */
142
-
143
- mocha.run = function(fn) {
144
- var options = mocha.options;
145
- mocha.globals('location');
146
-
147
- var query = Mocha.utils.parseQuery(global.location.search || '');
148
- if (query.grep) {
149
- mocha.grep(query.grep);
150
- }
151
- if (query.fgrep) {
152
- mocha.fgrep(query.fgrep);
153
- }
154
- if (query.invert) {
155
- mocha.invert();
156
- }
157
-
158
- return Mocha.prototype.run.call(mocha, function(err) {
159
- // The DOM Document is not available in Web Workers.
160
- var document = global.document;
161
- if (
162
- document &&
163
- document.getElementById('mocha') &&
164
- options.noHighlighting !== true
165
- ) {
166
- Mocha.utils.highlightTags('code');
167
- }
168
- if (fn) {
169
- fn(err);
170
- }
171
- });
172
- };
173
-
174
- /**
175
- * Expose the process shim.
176
- * https://github.com/mochajs/mocha/pull/916
177
- */
178
-
179
- Mocha.process = process;
180
-
181
- /**
182
- * Expose mocha.
183
- */
184
-
185
- global.Mocha = Mocha;
186
- global.mocha = mocha;
187
-
188
- // this allows test/acceptance/required-tokens.js to pass; thus,
189
- // you can now do `const describe = require('mocha').describe` in a
190
- // browser context (assuming browserification). should fix #880
191
- module.exports = global;
1
+ 'use strict';
2
+
3
+ /* eslint no-unused-vars: off */
4
+ /* eslint-env commonjs */
5
+
6
+ /**
7
+ * Shim process.stdout.
8
+ */
9
+
10
+ process.stdout = require('browser-stdout')({label: false});
11
+
12
+ var Mocha = require('./lib/mocha');
13
+
14
+ /**
15
+ * Create a Mocha instance.
16
+ *
17
+ * @return {undefined}
18
+ */
19
+
20
+ var mocha = new Mocha({reporter: 'html'});
21
+
22
+ /**
23
+ * Save timer references to avoid Sinon interfering (see GH-237).
24
+ */
25
+
26
+ var Date = global.Date;
27
+ var setTimeout = global.setTimeout;
28
+ var setInterval = global.setInterval;
29
+ var clearTimeout = global.clearTimeout;
30
+ var clearInterval = global.clearInterval;
31
+
32
+ var uncaughtExceptionHandlers = [];
33
+
34
+ var originalOnerrorHandler = global.onerror;
35
+
36
+ /**
37
+ * Remove uncaughtException listener.
38
+ * Revert to original onerror handler if previously defined.
39
+ */
40
+
41
+ process.removeListener = function(e, fn) {
42
+ if (e === 'uncaughtException') {
43
+ if (originalOnerrorHandler) {
44
+ global.onerror = originalOnerrorHandler;
45
+ } else {
46
+ global.onerror = function() {};
47
+ }
48
+ var i = uncaughtExceptionHandlers.indexOf(fn);
49
+ if (i !== -1) {
50
+ uncaughtExceptionHandlers.splice(i, 1);
51
+ }
52
+ }
53
+ };
54
+
55
+ /**
56
+ * Implements uncaughtException listener.
57
+ */
58
+
59
+ process.on = function(e, fn) {
60
+ if (e === 'uncaughtException') {
61
+ global.onerror = function(err, url, line) {
62
+ fn(new Error(err + ' (' + url + ':' + line + ')'));
63
+ return !mocha.allowUncaught;
64
+ };
65
+ uncaughtExceptionHandlers.push(fn);
66
+ }
67
+ };
68
+
69
+ // The BDD UI is registered by default, but no UI will be functional in the
70
+ // browser without an explicit call to the overridden `mocha.ui` (see below).
71
+ // Ensure that this default UI does not expose its methods to the global scope.
72
+ mocha.suite.removeAllListeners('pre-require');
73
+
74
+ var immediateQueue = [];
75
+ var immediateTimeout;
76
+
77
+ function timeslice() {
78
+ var immediateStart = new Date().getTime();
79
+ while (immediateQueue.length && new Date().getTime() - immediateStart < 100) {
80
+ immediateQueue.shift()();
81
+ }
82
+ if (immediateQueue.length) {
83
+ immediateTimeout = setTimeout(timeslice, 0);
84
+ } else {
85
+ immediateTimeout = null;
86
+ }
87
+ }
88
+
89
+ /**
90
+ * High-performance override of Runner.immediately.
91
+ */
92
+
93
+ Mocha.Runner.immediately = function(callback) {
94
+ immediateQueue.push(callback);
95
+ if (!immediateTimeout) {
96
+ immediateTimeout = setTimeout(timeslice, 0);
97
+ }
98
+ };
99
+
100
+ /**
101
+ * Function to allow assertion libraries to throw errors directly into mocha.
102
+ * This is useful when running tests in a browser because window.onerror will
103
+ * only receive the 'message' attribute of the Error.
104
+ */
105
+ mocha.throwError = function(err) {
106
+ uncaughtExceptionHandlers.forEach(function(fn) {
107
+ fn(err);
108
+ });
109
+ throw err;
110
+ };
111
+
112
+ /**
113
+ * Override ui to ensure that the ui functions are initialized.
114
+ * Normally this would happen in Mocha.prototype.loadFiles.
115
+ */
116
+
117
+ mocha.ui = function(ui) {
118
+ Mocha.prototype.ui.call(this, ui);
119
+ this.suite.emit('pre-require', global, null, this);
120
+ return this;
121
+ };
122
+
123
+ /**
124
+ * Setup mocha with the given setting options.
125
+ */
126
+
127
+ mocha.setup = function(opts) {
128
+ if (typeof opts === 'string') {
129
+ opts = {ui: opts};
130
+ }
131
+ for (var opt in opts) {
132
+ if (opts.hasOwnProperty(opt)) {
133
+ this[opt](opts[opt]);
134
+ }
135
+ }
136
+ return this;
137
+ };
138
+
139
+ /**
140
+ * Run mocha, returning the Runner.
141
+ */
142
+
143
+ mocha.run = function(fn) {
144
+ var options = mocha.options;
145
+ mocha.globals('location');
146
+
147
+ var query = Mocha.utils.parseQuery(global.location.search || '');
148
+ if (query.grep) {
149
+ mocha.grep(query.grep);
150
+ }
151
+ if (query.fgrep) {
152
+ mocha.fgrep(query.fgrep);
153
+ }
154
+ if (query.invert) {
155
+ mocha.invert();
156
+ }
157
+
158
+ return Mocha.prototype.run.call(mocha, function(err) {
159
+ // The DOM Document is not available in Web Workers.
160
+ var document = global.document;
161
+ if (
162
+ document &&
163
+ document.getElementById('mocha') &&
164
+ options.noHighlighting !== true
165
+ ) {
166
+ Mocha.utils.highlightTags('code');
167
+ }
168
+ if (fn) {
169
+ fn(err);
170
+ }
171
+ });
172
+ };
173
+
174
+ /**
175
+ * Expose the process shim.
176
+ * https://github.com/mochajs/mocha/pull/916
177
+ */
178
+
179
+ Mocha.process = process;
180
+
181
+ /**
182
+ * Expose mocha.
183
+ */
184
+
185
+ global.Mocha = Mocha;
186
+ global.mocha = mocha;
187
+
188
+ // this allows test/acceptance/required-tokens.js to pass; thus,
189
+ // you can now do `const describe = require('mocha').describe` in a
190
+ // browser context (assuming browserification). should fix #880
191
+ module.exports = global;
package/index.js CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';
2
-
3
- module.exports = require('./lib/mocha');
1
+ 'use strict';
2
+
3
+ module.exports = require('./lib/mocha');