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,104 +1,104 @@
1
- 'use strict';
2
- /**
3
- * @module Progress
4
- */
5
- /**
6
- * Module dependencies.
7
- */
8
-
9
- var Base = require('./base');
10
- var constants = require('../runner').constants;
11
- var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
12
- var EVENT_TEST_END = constants.EVENT_TEST_END;
13
- var EVENT_RUN_END = constants.EVENT_RUN_END;
14
- var inherits = require('../utils').inherits;
15
- var color = Base.color;
16
- var cursor = Base.cursor;
17
-
18
- /**
19
- * Expose `Progress`.
20
- */
21
-
22
- exports = module.exports = Progress;
23
-
24
- /**
25
- * General progress bar color.
26
- */
27
-
28
- Base.colors.progress = 90;
29
-
30
- /**
31
- * Constructs a new `Progress` reporter instance.
32
- *
33
- * @public
34
- * @class
35
- * @memberof Mocha.reporters
36
- * @extends Mocha.reporters.Base
37
- * @param {Runner} runner - Instance triggers reporter actions.
38
- * @param {Object} [options] - runner options
39
- */
40
- function Progress(runner, options) {
41
- Base.call(this, runner, options);
42
-
43
- var self = this;
44
- var width = (Base.window.width * 0.5) | 0;
45
- var total = runner.total;
46
- var complete = 0;
47
- var lastN = -1;
48
-
49
- // default chars
50
- options = options || {};
51
- var reporterOptions = options.reporterOptions || {};
52
-
53
- options.open = reporterOptions.open || '[';
54
- options.complete = reporterOptions.complete || '▬';
55
- options.incomplete = reporterOptions.incomplete || Base.symbols.dot;
56
- options.close = reporterOptions.close || ']';
57
- options.verbose = reporterOptions.verbose || false;
58
-
59
- // tests started
60
- runner.on(EVENT_RUN_BEGIN, function() {
61
- console.log();
62
- cursor.hide();
63
- });
64
-
65
- // tests complete
66
- runner.on(EVENT_TEST_END, function() {
67
- complete++;
68
-
69
- var percent = complete / total;
70
- var n = (width * percent) | 0;
71
- var i = width - n;
72
-
73
- if (n === lastN && !options.verbose) {
74
- // Don't re-render the line if it hasn't changed
75
- return;
76
- }
77
- lastN = n;
78
-
79
- cursor.CR();
80
- process.stdout.write('\u001b[J');
81
- process.stdout.write(color('progress', ' ' + options.open));
82
- process.stdout.write(Array(n).join(options.complete));
83
- process.stdout.write(Array(i).join(options.incomplete));
84
- process.stdout.write(color('progress', options.close));
85
- if (options.verbose) {
86
- process.stdout.write(color('progress', ' ' + complete + ' of ' + total));
87
- }
88
- });
89
-
90
- // tests are complete, output some stats
91
- // and the failures if any
92
- runner.once(EVENT_RUN_END, function() {
93
- cursor.show();
94
- console.log();
95
- self.epilogue();
96
- });
97
- }
98
-
99
- /**
100
- * Inherit from `Base.prototype`.
101
- */
102
- inherits(Progress, Base);
103
-
104
- Progress.description = 'a progress bar';
1
+ 'use strict';
2
+ /**
3
+ * @module Progress
4
+ */
5
+ /**
6
+ * Module dependencies.
7
+ */
8
+
9
+ var Base = require('./base');
10
+ var constants = require('../runner').constants;
11
+ var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
12
+ var EVENT_TEST_END = constants.EVENT_TEST_END;
13
+ var EVENT_RUN_END = constants.EVENT_RUN_END;
14
+ var inherits = require('../utils').inherits;
15
+ var color = Base.color;
16
+ var cursor = Base.cursor;
17
+
18
+ /**
19
+ * Expose `Progress`.
20
+ */
21
+
22
+ exports = module.exports = Progress;
23
+
24
+ /**
25
+ * General progress bar color.
26
+ */
27
+
28
+ Base.colors.progress = 90;
29
+
30
+ /**
31
+ * Constructs a new `Progress` reporter instance.
32
+ *
33
+ * @public
34
+ * @class
35
+ * @memberof Mocha.reporters
36
+ * @extends Mocha.reporters.Base
37
+ * @param {Runner} runner - Instance triggers reporter actions.
38
+ * @param {Object} [options] - runner options
39
+ */
40
+ function Progress(runner, options) {
41
+ Base.call(this, runner, options);
42
+
43
+ var self = this;
44
+ var width = (Base.window.width * 0.5) | 0;
45
+ var total = runner.total;
46
+ var complete = 0;
47
+ var lastN = -1;
48
+
49
+ // default chars
50
+ options = options || {};
51
+ var reporterOptions = options.reporterOptions || {};
52
+
53
+ options.open = reporterOptions.open || '[';
54
+ options.complete = reporterOptions.complete || '▬';
55
+ options.incomplete = reporterOptions.incomplete || Base.symbols.dot;
56
+ options.close = reporterOptions.close || ']';
57
+ options.verbose = reporterOptions.verbose || false;
58
+
59
+ // tests started
60
+ runner.on(EVENT_RUN_BEGIN, function() {
61
+ console.log();
62
+ cursor.hide();
63
+ });
64
+
65
+ // tests complete
66
+ runner.on(EVENT_TEST_END, function() {
67
+ complete++;
68
+
69
+ var percent = complete / total;
70
+ var n = (width * percent) | 0;
71
+ var i = width - n;
72
+
73
+ if (n === lastN && !options.verbose) {
74
+ // Don't re-render the line if it hasn't changed
75
+ return;
76
+ }
77
+ lastN = n;
78
+
79
+ cursor.CR();
80
+ process.stdout.write('\u001b[J');
81
+ process.stdout.write(color('progress', ' ' + options.open));
82
+ process.stdout.write(Array(n).join(options.complete));
83
+ process.stdout.write(Array(i).join(options.incomplete));
84
+ process.stdout.write(color('progress', options.close));
85
+ if (options.verbose) {
86
+ process.stdout.write(color('progress', ' ' + complete + ' of ' + total));
87
+ }
88
+ });
89
+
90
+ // tests are complete, output some stats
91
+ // and the failures if any
92
+ runner.once(EVENT_RUN_END, function() {
93
+ cursor.show();
94
+ console.log();
95
+ self.epilogue();
96
+ });
97
+ }
98
+
99
+ /**
100
+ * Inherit from `Base.prototype`.
101
+ */
102
+ inherits(Progress, Base);
103
+
104
+ Progress.description = 'a progress bar';
@@ -1,99 +1,99 @@
1
- 'use strict';
2
- /**
3
- * @module Spec
4
- */
5
- /**
6
- * Module dependencies.
7
- */
8
-
9
- var Base = require('./base');
10
- var constants = require('../runner').constants;
11
- var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
12
- var EVENT_RUN_END = constants.EVENT_RUN_END;
13
- var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
14
- var EVENT_SUITE_END = constants.EVENT_SUITE_END;
15
- var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
16
- var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
17
- var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
18
- var inherits = require('../utils').inherits;
19
- var color = Base.color;
20
-
21
- /**
22
- * Expose `Spec`.
23
- */
24
-
25
- exports = module.exports = Spec;
26
-
27
- /**
28
- * Constructs a new `Spec` reporter instance.
29
- *
30
- * @public
31
- * @class
32
- * @memberof Mocha.reporters
33
- * @extends Mocha.reporters.Base
34
- * @param {Runner} runner - Instance triggers reporter actions.
35
- * @param {Object} [options] - runner options
36
- */
37
- function Spec(runner, options) {
38
- Base.call(this, runner, options);
39
-
40
- var self = this;
41
- var indents = 0;
42
- var n = 0;
43
-
44
- function indent() {
45
- return Array(indents).join(' ');
46
- }
47
-
48
- runner.on(EVENT_RUN_BEGIN, function() {
49
- console.log();
50
- });
51
-
52
- runner.on(EVENT_SUITE_BEGIN, function(suite) {
53
- ++indents;
54
- console.log(color('suite', '%s%s'), indent(), suite.title);
55
- });
56
-
57
- runner.on(EVENT_SUITE_END, function() {
58
- --indents;
59
- if (indents === 1) {
60
- console.log();
61
- }
62
- });
63
-
64
- runner.on(EVENT_TEST_PENDING, function(test) {
65
- var fmt = indent() + color('pending', ' - %s');
66
- console.log(fmt, test.title);
67
- });
68
-
69
- runner.on(EVENT_TEST_PASS, function(test) {
70
- var fmt;
71
- if (test.speed === 'fast') {
72
- fmt =
73
- indent() +
74
- color('checkmark', ' ' + Base.symbols.ok) +
75
- color('pass', ' %s');
76
- console.log(fmt, test.title);
77
- } else {
78
- fmt =
79
- indent() +
80
- color('checkmark', ' ' + Base.symbols.ok) +
81
- color('pass', ' %s') +
82
- color(test.speed, ' (%dms)');
83
- console.log(fmt, test.title, test.duration);
84
- }
85
- });
86
-
87
- runner.on(EVENT_TEST_FAIL, function(test) {
88
- console.log(indent() + color('fail', ' %d) %s'), ++n, test.title);
89
- });
90
-
91
- runner.once(EVENT_RUN_END, self.epilogue.bind(self));
92
- }
93
-
94
- /**
95
- * Inherit from `Base.prototype`.
96
- */
97
- inherits(Spec, Base);
98
-
99
- Spec.description = 'hierarchical & verbose [default]';
1
+ 'use strict';
2
+ /**
3
+ * @module Spec
4
+ */
5
+ /**
6
+ * Module dependencies.
7
+ */
8
+
9
+ var Base = require('./base');
10
+ var constants = require('../runner').constants;
11
+ var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
12
+ var EVENT_RUN_END = constants.EVENT_RUN_END;
13
+ var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
14
+ var EVENT_SUITE_END = constants.EVENT_SUITE_END;
15
+ var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
16
+ var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
17
+ var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
18
+ var inherits = require('../utils').inherits;
19
+ var color = Base.color;
20
+
21
+ /**
22
+ * Expose `Spec`.
23
+ */
24
+
25
+ exports = module.exports = Spec;
26
+
27
+ /**
28
+ * Constructs a new `Spec` reporter instance.
29
+ *
30
+ * @public
31
+ * @class
32
+ * @memberof Mocha.reporters
33
+ * @extends Mocha.reporters.Base
34
+ * @param {Runner} runner - Instance triggers reporter actions.
35
+ * @param {Object} [options] - runner options
36
+ */
37
+ function Spec(runner, options) {
38
+ Base.call(this, runner, options);
39
+
40
+ var self = this;
41
+ var indents = 0;
42
+ var n = 0;
43
+
44
+ function indent() {
45
+ return Array(indents).join(' ');
46
+ }
47
+
48
+ runner.on(EVENT_RUN_BEGIN, function() {
49
+ console.log();
50
+ });
51
+
52
+ runner.on(EVENT_SUITE_BEGIN, function(suite) {
53
+ ++indents;
54
+ console.log(color('suite', '%s%s'), indent(), suite.title);
55
+ });
56
+
57
+ runner.on(EVENT_SUITE_END, function() {
58
+ --indents;
59
+ if (indents === 1) {
60
+ console.log();
61
+ }
62
+ });
63
+
64
+ runner.on(EVENT_TEST_PENDING, function(test) {
65
+ var fmt = indent() + color('pending', ' - %s');
66
+ console.log(fmt, test.title);
67
+ });
68
+
69
+ runner.on(EVENT_TEST_PASS, function(test) {
70
+ var fmt;
71
+ if (test.speed === 'fast') {
72
+ fmt =
73
+ indent() +
74
+ color('checkmark', ' ' + Base.symbols.ok) +
75
+ color('pass', ' %s');
76
+ console.log(fmt, test.title);
77
+ } else {
78
+ fmt =
79
+ indent() +
80
+ color('checkmark', ' ' + Base.symbols.ok) +
81
+ color('pass', ' %s') +
82
+ color(test.speed, ' (%dms)');
83
+ console.log(fmt, test.title, test.duration);
84
+ }
85
+ });
86
+
87
+ runner.on(EVENT_TEST_FAIL, function(test) {
88
+ console.log(indent() + color('fail', ' %d) %s'), ++n, test.title);
89
+ });
90
+
91
+ runner.once(EVENT_RUN_END, self.epilogue.bind(self));
92
+ }
93
+
94
+ /**
95
+ * Inherit from `Base.prototype`.
96
+ */
97
+ inherits(Spec, Base);
98
+
99
+ Spec.description = 'hierarchical & verbose [default]';