mocha 9.1.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 (76) hide show
  1. package/CHANGELOG.md +1015 -0
  2. package/LICENSE +22 -0
  3. package/README.md +70 -0
  4. package/assets/growl/error.png +0 -0
  5. package/assets/growl/ok.png +0 -0
  6. package/bin/_mocha +10 -0
  7. package/bin/mocha +142 -0
  8. package/browser-entry.js +216 -0
  9. package/index.js +3 -0
  10. package/lib/browser/growl.js +169 -0
  11. package/lib/browser/highlight-tags.js +39 -0
  12. package/lib/browser/parse-query.js +24 -0
  13. package/lib/browser/progress.js +123 -0
  14. package/lib/browser/template.html +20 -0
  15. package/lib/cli/cli.js +89 -0
  16. package/lib/cli/collect-files.js +92 -0
  17. package/lib/cli/commands.js +13 -0
  18. package/lib/cli/config.js +105 -0
  19. package/lib/cli/index.js +3 -0
  20. package/lib/cli/init.js +36 -0
  21. package/lib/cli/lookup-files.js +145 -0
  22. package/lib/cli/node-flags.js +85 -0
  23. package/lib/cli/one-and-dones.js +69 -0
  24. package/lib/cli/options.js +261 -0
  25. package/lib/cli/run-helpers.js +243 -0
  26. package/lib/cli/run-option-metadata.js +117 -0
  27. package/lib/cli/run.js +379 -0
  28. package/lib/cli/watch-run.js +380 -0
  29. package/lib/context.js +86 -0
  30. package/lib/errors.js +563 -0
  31. package/lib/hook.js +89 -0
  32. package/lib/interfaces/bdd.js +111 -0
  33. package/lib/interfaces/common.js +193 -0
  34. package/lib/interfaces/exports.js +60 -0
  35. package/lib/interfaces/index.js +6 -0
  36. package/lib/interfaces/qunit.js +98 -0
  37. package/lib/interfaces/tdd.js +106 -0
  38. package/lib/mocha.js +1374 -0
  39. package/lib/mocharc.json +10 -0
  40. package/lib/nodejs/buffered-worker-pool.js +172 -0
  41. package/lib/nodejs/esm-utils.js +109 -0
  42. package/lib/nodejs/file-unloader.js +15 -0
  43. package/lib/nodejs/growl.js +137 -0
  44. package/lib/nodejs/parallel-buffered-runner.js +433 -0
  45. package/lib/nodejs/reporters/parallel-buffered.js +165 -0
  46. package/lib/nodejs/serializer.js +412 -0
  47. package/lib/nodejs/worker.js +151 -0
  48. package/lib/pending.js +16 -0
  49. package/lib/plugin-loader.js +286 -0
  50. package/lib/reporters/base.js +537 -0
  51. package/lib/reporters/doc.js +95 -0
  52. package/lib/reporters/dot.js +81 -0
  53. package/lib/reporters/html.js +390 -0
  54. package/lib/reporters/index.js +19 -0
  55. package/lib/reporters/json-stream.js +92 -0
  56. package/lib/reporters/json.js +162 -0
  57. package/lib/reporters/landing.js +116 -0
  58. package/lib/reporters/list.js +78 -0
  59. package/lib/reporters/markdown.js +112 -0
  60. package/lib/reporters/min.js +52 -0
  61. package/lib/reporters/nyan.js +276 -0
  62. package/lib/reporters/progress.js +104 -0
  63. package/lib/reporters/spec.js +99 -0
  64. package/lib/reporters/tap.js +293 -0
  65. package/lib/reporters/xunit.js +217 -0
  66. package/lib/runnable.js +476 -0
  67. package/lib/runner.js +1269 -0
  68. package/lib/stats-collector.js +83 -0
  69. package/lib/suite.js +695 -0
  70. package/lib/test.js +113 -0
  71. package/lib/utils.js +641 -0
  72. package/mocha-es2018.js +19816 -0
  73. package/mocha.css +325 -0
  74. package/mocha.js +30844 -0
  75. package/mocha.js.map +1 -0
  76. package/package.json +200 -0
@@ -0,0 +1,83 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Provides a factory function for a {@link StatsCollector} object.
5
+ * @module
6
+ */
7
+
8
+ var constants = require('./runner').constants;
9
+ var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
10
+ var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
11
+ var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
12
+ var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
13
+ var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
14
+ var EVENT_RUN_END = constants.EVENT_RUN_END;
15
+ var EVENT_TEST_END = constants.EVENT_TEST_END;
16
+
17
+ /**
18
+ * Test statistics collector.
19
+ *
20
+ * @public
21
+ * @typedef {Object} StatsCollector
22
+ * @property {number} suites - integer count of suites run.
23
+ * @property {number} tests - integer count of tests run.
24
+ * @property {number} passes - integer count of passing tests.
25
+ * @property {number} pending - integer count of pending tests.
26
+ * @property {number} failures - integer count of failed tests.
27
+ * @property {Date} start - time when testing began.
28
+ * @property {Date} end - time when testing concluded.
29
+ * @property {number} duration - number of msecs that testing took.
30
+ */
31
+
32
+ var Date = global.Date;
33
+
34
+ /**
35
+ * Provides stats such as test duration, number of tests passed / failed etc., by listening for events emitted by `runner`.
36
+ *
37
+ * @private
38
+ * @param {Runner} runner - Runner instance
39
+ * @throws {TypeError} If falsy `runner`
40
+ */
41
+ function createStatsCollector(runner) {
42
+ /**
43
+ * @type StatsCollector
44
+ */
45
+ var stats = {
46
+ suites: 0,
47
+ tests: 0,
48
+ passes: 0,
49
+ pending: 0,
50
+ failures: 0
51
+ };
52
+
53
+ if (!runner) {
54
+ throw new TypeError('Missing runner argument');
55
+ }
56
+
57
+ runner.stats = stats;
58
+
59
+ runner.once(EVENT_RUN_BEGIN, function() {
60
+ stats.start = new Date();
61
+ });
62
+ runner.on(EVENT_SUITE_BEGIN, function(suite) {
63
+ suite.root || stats.suites++;
64
+ });
65
+ runner.on(EVENT_TEST_PASS, function() {
66
+ stats.passes++;
67
+ });
68
+ runner.on(EVENT_TEST_FAIL, function() {
69
+ stats.failures++;
70
+ });
71
+ runner.on(EVENT_TEST_PENDING, function() {
72
+ stats.pending++;
73
+ });
74
+ runner.on(EVENT_TEST_END, function() {
75
+ stats.tests++;
76
+ });
77
+ runner.once(EVENT_RUN_END, function() {
78
+ stats.end = new Date();
79
+ stats.duration = stats.end - stats.start;
80
+ });
81
+ }
82
+
83
+ module.exports = createStatsCollector;