mocha-compat 3.6.4 → 10.8.2

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 (92) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +61 -110
  3. package/bin/_mocha +10 -0
  4. package/bin/mocha.js +142 -0
  5. package/browser-entry.js +61 -22
  6. package/lib/browser/highlight-tags.js +39 -0
  7. package/lib/browser/parse-query.js +24 -0
  8. package/lib/{template.html → browser/template.html} +7 -5
  9. package/lib/cli/cli.js +89 -0
  10. package/lib/cli/collect-files.js +137 -0
  11. package/lib/cli/commands.js +14 -0
  12. package/lib/cli/config.js +100 -0
  13. package/lib/cli/index.js +3 -0
  14. package/lib/cli/init.js +36 -0
  15. package/lib/cli/lookup-files.js +150 -0
  16. package/lib/cli/node-flags.js +85 -0
  17. package/lib/cli/one-and-dones.js +69 -0
  18. package/lib/cli/options.js +284 -0
  19. package/lib/cli/run-helpers.js +304 -0
  20. package/lib/cli/run-option-metadata.js +116 -0
  21. package/lib/cli/run.js +380 -0
  22. package/lib/cli/watch-run.js +377 -0
  23. package/lib/context.js +16 -42
  24. package/lib/errors.js +563 -0
  25. package/lib/hook.js +50 -9
  26. package/lib/interfaces/bdd.js +28 -29
  27. package/lib/interfaces/common.js +56 -21
  28. package/lib/interfaces/exports.js +4 -7
  29. package/lib/interfaces/qunit.js +10 -11
  30. package/lib/interfaces/tdd.js +15 -15
  31. package/lib/mocha.js +1073 -292
  32. package/lib/mocharc.json +10 -0
  33. package/lib/nodejs/buffered-worker-pool.js +188 -0
  34. package/lib/nodejs/esm-utils.js +106 -0
  35. package/lib/nodejs/file-unloader.js +15 -0
  36. package/lib/nodejs/parallel-buffered-runner.js +433 -0
  37. package/lib/nodejs/reporters/parallel-buffered.js +165 -0
  38. package/lib/nodejs/serializer.js +414 -0
  39. package/lib/nodejs/worker.js +151 -0
  40. package/lib/pending.js +3 -3
  41. package/lib/plugin-loader.js +286 -0
  42. package/lib/reporters/base.js +305 -205
  43. package/lib/reporters/doc.js +52 -21
  44. package/lib/reporters/dot.js +31 -18
  45. package/lib/reporters/html.js +153 -81
  46. package/lib/reporters/json-stream.js +53 -24
  47. package/lib/reporters/json.js +88 -18
  48. package/lib/reporters/landing.js +38 -16
  49. package/lib/reporters/list.js +34 -19
  50. package/lib/reporters/markdown.js +28 -15
  51. package/lib/reporters/min.js +22 -8
  52. package/lib/reporters/nyan.js +62 -58
  53. package/lib/reporters/progress.js +32 -19
  54. package/lib/reporters/spec.js +41 -23
  55. package/lib/reporters/tap.js +255 -32
  56. package/lib/reporters/xunit.js +89 -39
  57. package/lib/runnable.js +233 -148
  58. package/lib/runner.js +679 -380
  59. package/lib/stats-collector.js +83 -0
  60. package/lib/suite.js +376 -112
  61. package/lib/test.js +82 -21
  62. package/lib/utils.js +364 -477
  63. package/mocha.css +183 -54
  64. package/mocha.js +19840 -15846
  65. package/mocha.js.map +1 -0
  66. package/package.json +163 -336
  67. package/{lib/to-iso-string → vendor/serialize-javascript}/LICENSE +8 -6
  68. package/vendor/serialize-javascript/README.md +10 -0
  69. package/vendor/serialize-javascript/index.js +349 -0
  70. package/bin/_mocha-compat +0 -572
  71. package/bin/mocha-compat +0 -87
  72. package/bin/options.js +0 -41
  73. package/bower.json +0 -38
  74. package/images/error.png +0 -0
  75. package/images/ok.png +0 -0
  76. package/lib/browser/.eslintrc.yaml +0 -4
  77. package/lib/browser/debug.js +0 -7
  78. package/lib/browser/events.js +0 -195
  79. package/lib/browser/progress.js +0 -119
  80. package/lib/browser/tty.js +0 -13
  81. package/lib/ms.js +0 -130
  82. package/lib/to-iso-string/index.js +0 -37
  83. package/vendor/glob/LICENSE +0 -15
  84. package/vendor/glob/README.md +0 -399
  85. package/vendor/glob/common.js +0 -244
  86. package/vendor/glob/glob.js +0 -788
  87. package/vendor/glob/package.json +0 -55
  88. package/vendor/glob/sync.js +0 -486
  89. package/vendor/inflight/LICENSE +0 -15
  90. package/vendor/inflight/README.md +0 -37
  91. package/vendor/inflight/inflight.js +0 -54
  92. package/vendor/inflight/package.json +0 -29
package/lib/test.js CHANGED
@@ -1,52 +1,113 @@
1
1
  'use strict';
2
-
3
- /**
4
- * Module dependencies.
5
- */
6
-
7
2
  var Runnable = require('./runnable');
8
- var create = require('lodash.create');
9
- var isString = require('./utils').isString;
3
+ var utils = require('./utils');
4
+ var errors = require('./errors');
5
+ var createInvalidArgumentTypeError = errors.createInvalidArgumentTypeError;
6
+ var isString = utils.isString;
10
7
 
11
- /**
12
- * Expose `Test`.
13
- */
8
+ const {MOCHA_ID_PROP_NAME} = utils.constants;
14
9
 
15
10
  module.exports = Test;
16
11
 
17
12
  /**
18
13
  * Initialize a new `Test` with the given `title` and callback `fn`.
19
14
  *
20
- * @api private
21
- * @param {String} title
22
- * @param {Function} fn
15
+ * @public
16
+ * @class
17
+ * @extends Runnable
18
+ * @param {String} title - Test title (required)
19
+ * @param {Function} [fn] - Test callback. If omitted, the Test is considered "pending"
23
20
  */
24
- function Test (title, fn) {
21
+ function Test(title, fn) {
25
22
  if (!isString(title)) {
26
- throw new Error('Test `title` should be a "string" but "' + typeof title + '" was given instead.');
23
+ throw createInvalidArgumentTypeError(
24
+ 'Test argument "title" should be a string. Received type "' +
25
+ typeof title +
26
+ '"',
27
+ 'title',
28
+ 'string'
29
+ );
27
30
  }
28
- Runnable.call(this, title, fn);
29
- this.pending = !fn;
30
31
  this.type = 'test';
32
+ Runnable.call(this, title, fn);
33
+ this.reset();
31
34
  }
32
35
 
33
36
  /**
34
37
  * Inherit from `Runnable.prototype`.
35
38
  */
36
- Test.prototype = create(Runnable.prototype, {
37
- constructor: Test
38
- });
39
+ utils.inherits(Test, Runnable);
40
+
41
+ /**
42
+ * Resets the state initially or for a next run.
43
+ */
44
+ Test.prototype.reset = function () {
45
+ Runnable.prototype.reset.call(this);
46
+ this.pending = !this.fn;
47
+ delete this.state;
48
+ };
49
+
50
+ /**
51
+ * Set or get retried test
52
+ *
53
+ * @private
54
+ */
55
+ Test.prototype.retriedTest = function (n) {
56
+ if (!arguments.length) {
57
+ return this._retriedTest;
58
+ }
59
+ this._retriedTest = n;
60
+ };
61
+
62
+ /**
63
+ * Add test to the list of tests marked `only`.
64
+ *
65
+ * @private
66
+ */
67
+ Test.prototype.markOnly = function () {
68
+ this.parent.appendOnlyTest(this);
69
+ };
39
70
 
40
71
  Test.prototype.clone = function () {
41
72
  var test = new Test(this.title, this.fn);
42
73
  test.timeout(this.timeout());
43
74
  test.slow(this.slow());
44
- test.enableTimeouts(this.enableTimeouts());
45
75
  test.retries(this.retries());
46
76
  test.currentRetry(this.currentRetry());
77
+ test.retriedTest(this.retriedTest() || this);
47
78
  test.globals(this.globals());
48
79
  test.parent = this.parent;
49
80
  test.file = this.file;
50
81
  test.ctx = this.ctx;
51
82
  return test;
52
83
  };
84
+
85
+ /**
86
+ * Returns an minimal object suitable for transmission over IPC.
87
+ * Functions are represented by keys beginning with `$$`.
88
+ * @private
89
+ * @returns {Object}
90
+ */
91
+ Test.prototype.serialize = function serialize() {
92
+ return {
93
+ $$currentRetry: this._currentRetry,
94
+ $$fullTitle: this.fullTitle(),
95
+ $$isPending: Boolean(this.pending),
96
+ $$retriedTest: this._retriedTest || null,
97
+ $$slow: this._slow,
98
+ $$titlePath: this.titlePath(),
99
+ body: this.body,
100
+ duration: this.duration,
101
+ err: this.err,
102
+ parent: {
103
+ $$fullTitle: this.parent.fullTitle(),
104
+ [MOCHA_ID_PROP_NAME]: this.parent.id
105
+ },
106
+ speed: this.speed,
107
+ state: this.state,
108
+ title: this.title,
109
+ type: this.type,
110
+ file: this.file,
111
+ [MOCHA_ID_PROP_NAME]: this.id
112
+ };
113
+ };