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
package/CHANGELOG.md CHANGED
@@ -1,3 +1,113 @@
1
+ # 5.2.0 / 2018-05-18
2
+
3
+ ## :tada: Enhancements
4
+
5
+ - [#3375]: Add support for comments in `mocha.opts` ([@plroebuck])
6
+
7
+ ## :bug: Fixes
8
+
9
+ - [#3346]: Exit correctly from `before` hooks when using `--bail` ([@outsideris])
10
+
11
+ ## :book: Documentation
12
+
13
+ - [#3328]: Mocha-flavored [API docs](https://mochajs.org/api/)! ([@Munter])
14
+
15
+ ## :nut_and_bolt: Other
16
+
17
+ - [#3330]: Use `Buffer.from()` ([@harrysarson])
18
+ - [#3295]: Remove redundant folder ([@DavNej])
19
+ - [#3356]: Refactoring ([@plroebuck])
20
+
21
+ [#3375]: https://github.com/mochajs/mocha/pull/3375
22
+ [#3346]: https://github.com/mochajs/mocha/pull/3346
23
+ [#3328]: https://github.com/mochajs/mocha/pull/3328
24
+ [#3330]: https://github.com/mochajs/mocha/pull/3330
25
+ [#3295]: https://github.com/mochajs/mocha/pull/3295
26
+ [#3356]: https://github.com/mochajs/mocha/pull/3356
27
+
28
+ [@plroebuck]: https://github.com/plroebuck
29
+ [@harrysarson]: https://github.com/harrysarson
30
+ [@outsideris]: https://github.com/outsideris
31
+ [@Munter]: https://github.com/Munter
32
+
33
+ # 5.1.1 / 2018-04-18
34
+
35
+ ## :bug: Fixes
36
+
37
+ - [#3325]: Revert change which broke `--watch` ([@boneskull])
38
+
39
+ [#3325]: https://github.com/mochajs/mocha/issues/3325
40
+
41
+ # 5.1.0 / 2018-04-12
42
+
43
+ ## :tada: Enhancements
44
+
45
+ - [#3210]: Add `--exclude` option ([@metalex9])
46
+
47
+ ## :bug: Fixes
48
+
49
+ - [#3318]: Fix failures in circular objects in JSON reporter ([@jeversmann], [@boneskull])
50
+
51
+ ## :book: Documentation
52
+
53
+ - [#3323]: Publish actual [API documentation](https://mochajs.org/api/)! ([@dfberry], [@Munter])
54
+ - [#3299]: Improve docs around exclusive tests ([@nicgirault])
55
+
56
+ ## :nut_and_bolt: Other
57
+
58
+ - [#3302], [#3308], [#3310], [#3315], [#3316]: Build matrix improvements ([more info](https://boneskull.com/mocha-and-travis-ci-build-stages/)) ([@outsideris], [@boneskull])
59
+ - [#3272]: Refactor reporter tests ([@jMuzsik])
60
+
61
+ [#3210]: https://github.com/mochajs/mocha/pull/3210
62
+ [#3318]: https://github.com/mochajs/mocha/pull/3318
63
+ [#3323]: https://github.com/mochajs/mocha/pull/3323
64
+ [#3299]: https://github.com/mochajs/mocha/pull/3299
65
+ [#3302]: https://github.com/mochajs/mocha/pull/3302
66
+ [#3308]: https://github.com/mochajs/mocha/pull/3308
67
+ [#3310]: https://github.com/mochajs/mocha/pull/3310
68
+ [#3315]: https://github.com/mochajs/mocha/pull/3315
69
+ [#3316]: https://github.com/mochajs/mocha/pull/3316
70
+ [#3272]: https://github.com/mochajs/mocha/pull/3272
71
+ [@metalex9]: https://github.com/metalex9
72
+ [@jeversmann]: https://github.com/jeversmann
73
+ [@dfberry]: https://github.com/dfberry
74
+ [@nicgirault]: https://github.com/nicgirault
75
+ [@jMuzsik]: https://github.com/jMuzsik
76
+
77
+ # 5.0.5 / 2018-03-22
78
+
79
+ Welcome [@outsideris] to the team!
80
+
81
+ ## :bug: Fixes
82
+
83
+ - [#3096]: Fix `--bail` failing to bail within hooks ([@outsideris])
84
+ - [#3184]: Don't skip too many suites (using `describe.skip()`) ([@outsideris])
85
+
86
+ ## :book: Documentation
87
+
88
+ - [#3133]: Improve docs regarding "pending" behavior ([@ematicipo])
89
+ - [#3276], [#3274]: Fix broken stuff in `CHANGELOG.md` ([@tagoro9], [@honzajavorek])
90
+
91
+ ## :nut_and_bolt: Other
92
+
93
+ - [#3208]: Improve test coverage for AMD users ([@outsideris])
94
+ - [#3267]: Remove vestiges of PhantomJS from CI ([@anishkny])
95
+ - [#2952]: Fix a debug message ([@boneskull])
96
+
97
+ [#3096]: https://github.com/mochajs/mocha/issues/3096
98
+ [#3184]: https://github.com/mochajs/mocha/issues/3184
99
+ [#3133]: https://github.com/mochajs/mocha/issues/3133
100
+ [#3276]: https://github.com/mochajs/mocha/pull/3276
101
+ [#3274]: https://github.com/mochajs/mocha/pull/3274
102
+ [#3208]: https://github.com/mochajs/mocha/issues/3208
103
+ [#2952]: https://github.com/mochajs/mocha/issues/2952
104
+ [#3267]: https://github.com/mochajs/mocha/pull/3267
105
+
106
+ [@ematicipo]: https://github.com/ematicipo
107
+ [@tagoro9]: https://github.com/tagoro9
108
+ [@honzajavorek]: https://github.com/honajavorek
109
+ [@anishkny]: https://github.com/anishkny
110
+
1
111
  # 5.0.4 / 2018-03-07
2
112
 
3
113
  ## :bug: Fixes
@@ -52,7 +162,7 @@ This release fixes a class of tests which report as *false positives*. **Certai
52
162
  **Maintainers of external reporters**: *If* a test of this class is encountered, the `Runner` instance will emit the `end` event *twice*; you *may* need to change your reporter to use `runner.once('end')` intead of `runner.on('end')`.
53
163
  - [#3093]: Fix stack trace reformatting problem ([@outsideris])
54
164
 
55
- ## :nut_and_bolt Other
165
+ ## :nut_and_bolt: Other
56
166
 
57
167
  - [#3248]: Update `browser-stdout` to v1.3.1 ([@honzajavorek])
58
168
 
@@ -87,10 +197,10 @@ Special thanks to [Wallaby.js](https://wallabyjs.com) for their continued suppor
87
197
  [#3119]: https://github.com/mochajs/mocha/issues/3119
88
198
  [#3132]: https://github.com/mochajs/mocha/issues/3132
89
199
  [#3098]: https://github.com/mochajs/mocha/issues/3098
90
- [#3212]: https://github.com/mochajs/mocha/pulls/3212
91
- [#3205]: https://github.com/mochajs/mocha/pulls/3205
92
- [#3224]: https://github.com/mochajs/mocha/pulls/3224
93
- [#3230]: https://github.com/mochajs/mocha/pulls/3230
200
+ [#3212]: https://github.com/mochajs/mocha/pull/3212
201
+ [#3205]: https://github.com/mochajs/mocha/pull/3205
202
+ [#3224]: https://github.com/mochajs/mocha/pull/3224
203
+ [#3230]: https://github.com/mochajs/mocha/pull/3230
94
204
  [@silviom]: https://github.com/silviom
95
205
  [@outsideris]: https://github.com/outsideris
96
206
  [@ArtemGovorov]: https://github.com/ArtemGovorov
@@ -350,9 +460,9 @@ For more info, please [read this article](https://boneskull.com/mocha-v4-nears-r
350
460
  - Various CI-and-test-related fixes and improvements ([@boneskull], [@dasilvacontin], [@PopradiArpad], [@Munter], [@ScottFreeCode])
351
461
  - "Officially" support Node.js 8 ([@elergy])
352
462
 
353
- [#2860]: https://github.com/mochajs/mocha/pulls/2860
354
- [#2696]: https://github.com/mochajs/mocha/pulls/2696
355
- [#2813]: https://github.com/mochajs/mocha/pulls/2813
463
+ [#2860]: https://github.com/mochajs/mocha/pull/2860
464
+ [#2696]: https://github.com/mochajs/mocha/pull/2696
465
+ [#2813]: https://github.com/mochajs/mocha/pull/2813
356
466
  [@charlierudolph]: https://github.com/charlierudolph
357
467
  [@PopradiArpad]: https://github.com/PopradiArpad
358
468
  [@kungapal]: https://github.com/kungapal
@@ -374,7 +484,7 @@ For more info, please [read this article](https://boneskull.com/mocha-v4-nears-r
374
484
  [@makepanic]: https://github.com/makepanic
375
485
  [@Munter]: https://github.com/Munter
376
486
 
377
- [#2778]: https://github.com/mochajs/mocha/pulls/2778
487
+ [#2778]: https://github.com/mochajs/mocha/pull/2778
378
488
  [#2802]: https://github.com/mochajs/mocha/issues/2802
379
489
  [#2820]: https://github.com/mochajs/mocha/pull/2820
380
490
 
package/bin/_mocha CHANGED
@@ -10,6 +10,7 @@
10
10
  const program = require('commander');
11
11
  const path = require('path');
12
12
  const fs = require('fs');
13
+ const minimatch = require('minimatch');
13
14
  const resolve = path.resolve;
14
15
  const exists = fs.existsSync;
15
16
  const Mocha = require('../');
@@ -57,7 +58,7 @@ const exit = code => {
57
58
  // https://github.com/joyent/node/issues/6247 is just one bug example
58
59
  // https://github.com/visionmedia/mocha/issues/333 has a good discussion
59
60
  const done = () => {
60
- if (!(draining--)) {
61
+ if (!draining--) {
61
62
  process.exit(clampedCode);
62
63
  }
63
64
  };
@@ -142,16 +143,23 @@ const requires = [];
142
143
  */
143
144
 
144
145
  const images = {
145
- fail: path.join(__dirname, '..', 'images', 'error.png'),
146
- pass: path.join(__dirname, '..', 'images', 'ok.png')
146
+ fail: path.join(__dirname, '..', 'assets', 'growl', 'error.png'),
147
+ pass: path.join(__dirname, '..', 'assets', 'growl', 'ok.png')
147
148
  };
148
149
 
149
150
  // options
150
151
 
151
152
  program
152
- .version(JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8')).version)
153
+ .version(
154
+ JSON.parse(
155
+ fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8')
156
+ ).version
157
+ )
153
158
  .usage('[debug] [options] [files]')
154
- .option('-A, --async-only', 'force all tests to take a callback (async) or return a promise')
159
+ .option(
160
+ '-A, --async-only',
161
+ 'force all tests to take a callback (async) or return a promise'
162
+ )
155
163
  .option('-c, --colors', 'force enabling of colors')
156
164
  .option('-C, --no-colors', 'force disabling of colors')
157
165
  .option('-G, --growl', 'enable growl notification support')
@@ -167,24 +175,53 @@ program
167
175
  .option('-r, --require <name>', 'require the given module')
168
176
  .option('-s, --slow <ms>', '"slow" test threshold in milliseconds [75]')
169
177
  .option('-t, --timeout <ms>', 'set test-case timeout in milliseconds [2000]')
170
- .option('-u, --ui <name>', `specify user-interface (${interfaceNames.join('|')})`, 'bdd')
178
+ .option(
179
+ '-u, --ui <name>',
180
+ `specify user-interface (${interfaceNames.join('|')})`,
181
+ 'bdd'
182
+ )
171
183
  .option('-w, --watch', 'watch files for changes')
172
184
  .option('--check-leaks', 'check for global variable leaks')
173
185
  .option('--full-trace', 'display the full stack trace')
174
- .option('--compilers <ext>:<module>,...', 'use the given module(s) to compile files', list, [])
186
+ .option(
187
+ '--compilers <ext>:<module>,...',
188
+ 'use the given module(s) to compile files',
189
+ list,
190
+ []
191
+ )
175
192
  .option('--debug-brk', "enable node's debugger breaking on the first line")
176
- .option('--globals <names>', 'allow the given comma-delimited global [names]', list, [])
193
+ .option(
194
+ '--globals <names>',
195
+ 'allow the given comma-delimited global [names]',
196
+ list,
197
+ []
198
+ )
177
199
  .option('--es_staging', 'enable all staged features')
178
- .option('--harmony<_classes,_generators,...>', 'all node --harmony* flags are available')
179
- .option('--preserve-symlinks', 'Instructs the module loader to preserve symbolic links when resolving and caching modules')
200
+ .option(
201
+ '--harmony<_classes,_generators,...>',
202
+ 'all node --harmony* flags are available'
203
+ )
204
+ .option(
205
+ '--preserve-symlinks',
206
+ 'Instructs the module loader to preserve symbolic links when resolving and caching modules'
207
+ )
180
208
  .option('--icu-data-dir', 'include ICU data')
181
- .option('--inline-diffs', 'display actual/expected differences inline within each string')
209
+ .option(
210
+ '--inline-diffs',
211
+ 'display actual/expected differences inline within each string'
212
+ )
182
213
  .option('--no-diff', 'do not show a diff on failure')
183
214
  .option('--inspect', 'activate devtools in chrome')
184
- .option('--inspect-brk', 'activate devtools in chrome and break on the first line')
215
+ .option(
216
+ '--inspect-brk',
217
+ 'activate devtools in chrome and break on the first line'
218
+ )
185
219
  .option('--interfaces', 'display available interfaces')
186
220
  .option('--no-deprecation', 'silence deprecation warnings')
187
- .option('--exit', 'force shutdown of the event loop after test run: mocha will call process.exit')
221
+ .option(
222
+ '--exit',
223
+ 'force shutdown of the event loop after test run: mocha will call process.exit'
224
+ )
188
225
  .option('--no-timeouts', 'disables timeouts, given implicitly with --debug')
189
226
  .option('--no-warnings', 'silence all node process warnings')
190
227
  .option('--opts <path>', 'specify opts path', 'test/mocha.opts')
@@ -194,18 +231,38 @@ program
194
231
  .option('--log-timer-events', 'Time events including external callbacks')
195
232
  .option('--recursive', 'include sub directories')
196
233
  .option('--reporters', 'display available reporters')
197
- .option('--retries <times>', 'set numbers of time to retry a failed test case')
198
- .option('--throw-deprecation', 'throw an exception anytime a deprecated function is used')
234
+ .option(
235
+ '--retries <times>',
236
+ 'set numbers of time to retry a failed test case'
237
+ )
238
+ .option(
239
+ '--throw-deprecation',
240
+ 'throw an exception anytime a deprecated function is used'
241
+ )
199
242
  .option('--trace', 'trace function calls')
200
243
  .option('--trace-deprecation', 'show stack traces on deprecations')
201
244
  .option('--trace-warnings', 'show stack traces on node process warnings')
202
245
  .option('--use_strict', 'enforce strict mode')
203
- .option('--watch-extensions <ext>,...', 'additional extensions to monitor with --watch', list, [])
246
+ .option(
247
+ '--watch-extensions <ext>,...',
248
+ 'additional extensions to monitor with --watch',
249
+ list,
250
+ ['js']
251
+ )
204
252
  .option('--delay', 'wait for async suite definition')
205
253
  .option('--allow-uncaught', 'enable uncaught errors to propagate')
206
254
  .option('--forbid-only', 'causes test marked with only to fail the suite')
207
- .option('--forbid-pending', 'causes pending tests and test marked with skip to fail the suite')
208
- .option('--file <file>', 'include a file to be ran during the suite', collect, []);
255
+ .option(
256
+ '--forbid-pending',
257
+ 'causes pending tests and test marked with skip to fail the suite'
258
+ )
259
+ .option(
260
+ '--file <file>',
261
+ 'include a file to be ran during the suite',
262
+ collect,
263
+ []
264
+ )
265
+ .option('--exclude <file>', 'a file or glob pattern to ignore', collect, []);
209
266
 
210
267
  program._name = 'mocha';
211
268
 
@@ -310,19 +367,6 @@ if (program.reporterOptions !== undefined) {
310
367
 
311
368
  mocha.reporter(program.reporter, reporterOptions);
312
369
 
313
- // load reporter
314
-
315
- let Reporter = null;
316
- try {
317
- Reporter = require(`../lib/reporters/${program.reporter}`);
318
- } catch (err) {
319
- try {
320
- Reporter = require(program.reporter);
321
- } catch (err2) {
322
- throw new Error(`reporter "${program.reporter}" does not exist`);
323
- }
324
- }
325
-
326
370
  // --no-colors
327
371
 
328
372
  if (!program.colors) {
@@ -445,7 +489,7 @@ if (program.forbidPending) mocha.forbidPending();
445
489
 
446
490
  if (program.compilers.length > 0) {
447
491
  require('util').deprecate(() => {},
448
- '"--compilers" will be removed in a future version of Mocha; see https://git.io/vdcSr for more info')();
492
+ '"--compilers" will be removed in a future version of Mocha; see https://git.io/vdcSr for more info')();
449
493
  }
450
494
  const extensions = ['js'];
451
495
  program.compilers.forEach(c => {
@@ -487,13 +531,24 @@ args.forEach(arg => {
487
531
  newFiles = utils.lookupFiles(arg, extensions, program.recursive);
488
532
  } catch (err) {
489
533
  if (err.message.indexOf('cannot resolve path') === 0) {
490
- console.error(`Warning: Could not find any test files matching pattern: ${arg}`);
534
+ console.error(
535
+ `Warning: Could not find any test files matching pattern: ${arg}`
536
+ );
491
537
  return;
492
538
  }
493
539
 
494
540
  throw err;
495
541
  }
496
542
 
543
+ if (typeof newFiles !== 'undefined') {
544
+ if (typeof newFiles === 'string') {
545
+ newFiles = [newFiles];
546
+ }
547
+ newFiles = newFiles.filter(fileName =>
548
+ program.exclude.every(pattern => !minimatch(fileName, pattern))
549
+ );
550
+ }
551
+
497
552
  files = files.concat(newFiles);
498
553
  });
499
554
 
@@ -529,7 +584,7 @@ if (program.watch) {
529
584
  process.exit(130);
530
585
  });
531
586
 
532
- const watchFiles = utils.files(cwd, [ 'js' ].concat(program.watchExtensions));
587
+ const watchFiles = utils.files(cwd, ['js'].concat(program.watchExtensions));
533
588
  let runAgain = false;
534
589
 
535
590
  loadAndRun = () => {
@@ -576,7 +631,7 @@ if (program.watch) {
576
631
  }
577
632
  });
578
633
  } else {
579
- // load
634
+ // load
580
635
 
581
636
  mocha.files = files;
582
637
  runner = mocha.run(program.exit ? exit : exitLater);
package/bin/options.js CHANGED
@@ -16,17 +16,23 @@ module.exports = getOptions;
16
16
  * Get options.
17
17
  */
18
18
 
19
- function getOptions () {
20
- if (process.argv.length === 3 && (process.argv[2] === '-h' || process.argv[2] === '--help')) {
19
+ function getOptions() {
20
+ if (
21
+ process.argv.length === 3 &&
22
+ (process.argv[2] === '-h' || process.argv[2] === '--help')
23
+ ) {
21
24
  return;
22
25
  }
23
26
 
24
- const optsPath = process.argv.indexOf('--opts') === -1
25
- ? 'test/mocha.opts'
26
- : process.argv[process.argv.indexOf('--opts') + 1];
27
+ const optsPath =
28
+ process.argv.indexOf('--opts') === -1
29
+ ? 'test/mocha.opts'
30
+ : process.argv[process.argv.indexOf('--opts') + 1];
27
31
 
28
32
  try {
29
- const opts = fs.readFileSync(optsPath, 'utf8')
33
+ const opts = fs
34
+ .readFileSync(optsPath, 'utf8')
35
+ .replace(/^#.*$/gm, '')
30
36
  .replace(/\\\s/g, '%20')
31
37
  .split(/\s/)
32
38
  .filter(Boolean)
@@ -35,8 +41,8 @@ function getOptions () {
35
41
  process.argv = process.argv
36
42
  .slice(0, 2)
37
43
  .concat(opts.concat(process.argv.slice(2)));
38
- } catch (err) {
39
- // ignore
44
+ } catch (ignore) {
45
+ // NOTE: should console.error() and throw the error
40
46
  }
41
47
 
42
48
  process.env.LOADED_MOCHA_OPTS = true;
package/browser-entry.js CHANGED
@@ -17,7 +17,7 @@ var Mocha = require('./lib/mocha');
17
17
  * @return {undefined}
18
18
  */
19
19
 
20
- var mocha = new Mocha({ reporter: 'html' });
20
+ var mocha = new Mocha({reporter: 'html'});
21
21
 
22
22
  /**
23
23
  * Save timer references to avoid Sinon interfering (see GH-237).
@@ -38,12 +38,12 @@ var originalOnerrorHandler = global.onerror;
38
38
  * Revert to original onerror handler if previously defined.
39
39
  */
40
40
 
41
- process.removeListener = function (e, fn) {
41
+ process.removeListener = function(e, fn) {
42
42
  if (e === 'uncaughtException') {
43
43
  if (originalOnerrorHandler) {
44
44
  global.onerror = originalOnerrorHandler;
45
45
  } else {
46
- global.onerror = function () {};
46
+ global.onerror = function() {};
47
47
  }
48
48
  var i = uncaughtExceptionHandlers.indexOf(fn);
49
49
  if (i !== -1) {
@@ -56,9 +56,9 @@ process.removeListener = function (e, fn) {
56
56
  * Implements uncaughtException listener.
57
57
  */
58
58
 
59
- process.on = function (e, fn) {
59
+ process.on = function(e, fn) {
60
60
  if (e === 'uncaughtException') {
61
- global.onerror = function (err, url, line) {
61
+ global.onerror = function(err, url, line) {
62
62
  fn(new Error(err + ' (' + url + ':' + line + ')'));
63
63
  return !mocha.allowUncaught;
64
64
  };
@@ -74,9 +74,9 @@ mocha.suite.removeAllListeners('pre-require');
74
74
  var immediateQueue = [];
75
75
  var immediateTimeout;
76
76
 
77
- function timeslice () {
77
+ function timeslice() {
78
78
  var immediateStart = new Date().getTime();
79
- while (immediateQueue.length && (new Date().getTime() - immediateStart) < 100) {
79
+ while (immediateQueue.length && new Date().getTime() - immediateStart < 100) {
80
80
  immediateQueue.shift()();
81
81
  }
82
82
  if (immediateQueue.length) {
@@ -90,7 +90,7 @@ function timeslice () {
90
90
  * High-performance override of Runner.immediately.
91
91
  */
92
92
 
93
- Mocha.Runner.immediately = function (callback) {
93
+ Mocha.Runner.immediately = function(callback) {
94
94
  immediateQueue.push(callback);
95
95
  if (!immediateTimeout) {
96
96
  immediateTimeout = setTimeout(timeslice, 0);
@@ -102,8 +102,8 @@ Mocha.Runner.immediately = function (callback) {
102
102
  * This is useful when running tests in a browser because window.onerror will
103
103
  * only receive the 'message' attribute of the Error.
104
104
  */
105
- mocha.throwError = function (err) {
106
- uncaughtExceptionHandlers.forEach(function (fn) {
105
+ mocha.throwError = function(err) {
106
+ uncaughtExceptionHandlers.forEach(function(fn) {
107
107
  fn(err);
108
108
  });
109
109
  throw err;
@@ -114,7 +114,7 @@ mocha.throwError = function (err) {
114
114
  * Normally this would happen in Mocha.prototype.loadFiles.
115
115
  */
116
116
 
117
- mocha.ui = function (ui) {
117
+ mocha.ui = function(ui) {
118
118
  Mocha.prototype.ui.call(this, ui);
119
119
  this.suite.emit('pre-require', global, null, this);
120
120
  return this;
@@ -124,9 +124,9 @@ mocha.ui = function (ui) {
124
124
  * Setup mocha with the given setting options.
125
125
  */
126
126
 
127
- mocha.setup = function (opts) {
127
+ mocha.setup = function(opts) {
128
128
  if (typeof opts === 'string') {
129
- opts = { ui: opts };
129
+ opts = {ui: opts};
130
130
  }
131
131
  for (var opt in opts) {
132
132
  if (opts.hasOwnProperty(opt)) {
@@ -140,7 +140,7 @@ mocha.setup = function (opts) {
140
140
  * Run mocha, returning the Runner.
141
141
  */
142
142
 
143
- mocha.run = function (fn) {
143
+ mocha.run = function(fn) {
144
144
  var options = mocha.options;
145
145
  mocha.globals('location');
146
146
 
@@ -155,10 +155,14 @@ mocha.run = function (fn) {
155
155
  mocha.invert();
156
156
  }
157
157
 
158
- return Mocha.prototype.run.call(mocha, function (err) {
158
+ return Mocha.prototype.run.call(mocha, function(err) {
159
159
  // The DOM Document is not available in Web Workers.
160
160
  var document = global.document;
161
- if (document && document.getElementById('mocha') && options.noHighlighting !== true) {
161
+ if (
162
+ document &&
163
+ document.getElementById('mocha') &&
164
+ options.noHighlighting !== true
165
+ ) {
162
166
  Mocha.utils.highlightTags('code');
163
167
  }
164
168
  if (fn) {
@@ -9,7 +9,7 @@ module.exports = Progress;
9
9
  /**
10
10
  * Initialize a new `Progress` indicator.
11
11
  */
12
- function Progress () {
12
+ function Progress() {
13
13
  this.percent = 0;
14
14
  this.size(0);
15
15
  this.fontSize(11);
@@ -23,7 +23,7 @@ function Progress () {
23
23
  * @param {number} size
24
24
  * @return {Progress} Progress instance.
25
25
  */
26
- Progress.prototype.size = function (size) {
26
+ Progress.prototype.size = function(size) {
27
27
  this._size = size;
28
28
  return this;
29
29
  };
@@ -35,7 +35,7 @@ Progress.prototype.size = function (size) {
35
35
  * @param {string} text
36
36
  * @return {Progress} Progress instance.
37
37
  */
38
- Progress.prototype.text = function (text) {
38
+ Progress.prototype.text = function(text) {
39
39
  this._text = text;
40
40
  return this;
41
41
  };
@@ -47,7 +47,7 @@ Progress.prototype.text = function (text) {
47
47
  * @param {number} size
48
48
  * @return {Progress} Progress instance.
49
49
  */
50
- Progress.prototype.fontSize = function (size) {
50
+ Progress.prototype.fontSize = function(size) {
51
51
  this._fontSize = size;
52
52
  return this;
53
53
  };
@@ -58,7 +58,7 @@ Progress.prototype.fontSize = function (size) {
58
58
  * @param {string} family
59
59
  * @return {Progress} Progress instance.
60
60
  */
61
- Progress.prototype.font = function (family) {
61
+ Progress.prototype.font = function(family) {
62
62
  this._font = family;
63
63
  return this;
64
64
  };
@@ -69,7 +69,7 @@ Progress.prototype.font = function (family) {
69
69
  * @param {number} n
70
70
  * @return {Progress} Progress instance.
71
71
  */
72
- Progress.prototype.update = function (n) {
72
+ Progress.prototype.update = function(n) {
73
73
  this.percent = n;
74
74
  return this;
75
75
  };
@@ -80,7 +80,7 @@ Progress.prototype.update = function (n) {
80
80
  * @param {CanvasRenderingContext2d} ctx
81
81
  * @return {Progress} Progress instance.
82
82
  */
83
- Progress.prototype.draw = function (ctx) {
83
+ Progress.prototype.draw = function(ctx) {
84
84
  try {
85
85
  var percent = Math.min(this.percent, 100);
86
86
  var size = this._size;
@@ -112,7 +112,7 @@ Progress.prototype.draw = function (ctx) {
112
112
  var w = ctx.measureText(text).width;
113
113
 
114
114
  ctx.fillText(text, x - w / 2 + 1, y + fontSize / 2 - 1);
115
- } catch (err) {
115
+ } catch (ignore) {
116
116
  // don't fail if we can't render progress
117
117
  }
118
118
  return this;
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- exports.isatty = function isatty () {
3
+ exports.isatty = function isatty() {
4
4
  return true;
5
5
  };
6
6
 
7
- exports.getWindowSize = function getWindowSize () {
7
+ exports.getWindowSize = function getWindowSize() {
8
8
  if ('innerHeight' in global) {
9
9
  return [global.innerHeight, global.innerWidth];
10
10
  }