@eggjs/mock 6.1.0-beta.9 → 7.0.0-beta.14

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 (104) hide show
  1. package/README.md +1 -1
  2. package/README.zh_CN.md +1 -1
  3. package/dist/_virtual/rolldown_runtime.js +1 -24
  4. package/dist/inject_mocha.d.ts +1 -1
  5. package/dist/inject_mocha.js +2 -3
  6. package/dist/lib/app.js +4 -1
  7. package/dist/lib/context.js +1 -3
  8. package/dist/lib/types.d.ts +4 -0
  9. package/package.json +9 -13
  10. package/dist/node_modules/.pnpm/ansi-styles@4.3.0/node_modules/ansi-styles/index.js +0 -142
  11. package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js +0 -157
  12. package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/templates.js +0 -97
  13. package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/util.js +0 -40
  14. package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js +0 -814
  15. package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/index.js +0 -50
  16. package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/route.js +0 -68
  17. package/dist/node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js +0 -752
  18. package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/browser.js +0 -203
  19. package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/common.js +0 -209
  20. package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js +0 -18
  21. package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js +0 -215
  22. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/dmp.js +0 -24
  23. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/xml.js +0 -33
  24. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/array.js +0 -29
  25. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/base.js +0 -185
  26. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/character.js +0 -23
  27. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/css.js +0 -26
  28. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/json.js +0 -83
  29. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/line.js +0 -51
  30. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/sentence.js +0 -26
  31. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/word.js +0 -151
  32. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/index.js +0 -178
  33. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/apply.js +0 -168
  34. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/create.js +0 -301
  35. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/line-endings.js +0 -137
  36. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/merge.js +0 -367
  37. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/parse.js +0 -91
  38. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/reverse.js +0 -99
  39. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/array.js +0 -23
  40. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/distance-iterator.js +0 -30
  41. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/params.js +0 -22
  42. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/string.js +0 -97
  43. package/dist/node_modules/.pnpm/escape-string-regexp@4.0.0/node_modules/escape-string-regexp/index.js +0 -14
  44. package/dist/node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js +0 -16
  45. package/dist/node_modules/.pnpm/he@1.2.0/node_modules/he/he.js +0 -4093
  46. package/dist/node_modules/.pnpm/is-unicode-supported@0.1.0/node_modules/is-unicode-supported/index.js +0 -14
  47. package/dist/node_modules/.pnpm/log-symbols@4.1.0/node_modules/log-symbols/index.js +0 -27
  48. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/index.js +0 -12
  49. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/context.js +0 -83
  50. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/error-constants.js +0 -35
  51. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/errors.js +0 -392
  52. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/hook.js +0 -86
  53. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/bdd.js +0 -104
  54. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/common.js +0 -99
  55. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/exports.js +0 -65
  56. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/index.js +0 -18
  57. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/qunit.js +0 -95
  58. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/tdd.js +0 -105
  59. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocha.js +0 -1037
  60. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocharc.js +0 -24
  61. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/buffered-worker-pool.js +0 -152
  62. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/esm-utils.js +0 -74
  63. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/file-unloader.js +0 -22
  64. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/parallel-buffered-runner.js +0 -329
  65. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/serializer.js +0 -314
  66. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/pending.js +0 -22
  67. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/base.js +0 -417
  68. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/doc.js +0 -79
  69. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/dot.js +0 -75
  70. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/html.js +0 -283
  71. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/index.js +0 -40
  72. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json-stream.js +0 -90
  73. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json.js +0 -145
  74. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/landing.js +0 -107
  75. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/list.js +0 -77
  76. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/markdown.js +0 -106
  77. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/min.js +0 -57
  78. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/nyan.js +0 -233
  79. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/progress.js +0 -92
  80. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/spec.js +0 -91
  81. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/tap.js +0 -261
  82. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/xunit.js +0 -166
  83. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runnable.js +0 -346
  84. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runner.js +0 -922
  85. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/stats-collector.js +0 -72
  86. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/suite.js +0 -517
  87. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/test.js +0 -105
  88. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/utils.js +0 -505
  89. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/package.js +0 -225
  90. package/dist/node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js +0 -124
  91. package/dist/node_modules/.pnpm/randombytes@2.1.0/node_modules/randombytes/index.js +0 -11
  92. package/dist/node_modules/.pnpm/serialize-javascript@6.0.2/node_modules/serialize-javascript/index.js +0 -114
  93. package/dist/node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js +0 -76
  94. package/dist/node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js +0 -89
  95. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Pool.js +0 -366
  96. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Promise.js +0 -248
  97. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/WorkerHandler.js +0 -419
  98. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/debug-port-allocator.js +0 -27
  99. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/environment.js +0 -18
  100. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/generated/embeddedWorker.js +0 -16
  101. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/index.js +0 -63
  102. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/transfer.js +0 -21
  103. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/validateOptions.js +0 -9
  104. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/worker.js +0 -277
@@ -1,261 +0,0 @@
1
- import { __commonJS, __require } from "../../../../../../../_virtual/rolldown_runtime.js";
2
- import { require_utils } from "../utils.js";
3
- import { require_runner } from "../runner.js";
4
- import { require_base } from "./base.js";
5
-
6
- //#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/tap.js
7
- var require_tap = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/tap.js": ((exports, module) => {
8
- /**
9
- * @typedef {import('../runner.js')} Runner
10
- * @typedef {import('../test.js')} Test
11
- */
12
- /**
13
- * @module TAP
14
- */
15
- /**
16
- * Module dependencies.
17
- */
18
- var util = __require("node:util");
19
- var Base = require_base();
20
- var constants = require_runner().constants;
21
- var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
22
- var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
23
- var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
24
- var EVENT_RUN_END = constants.EVENT_RUN_END;
25
- var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
26
- var EVENT_TEST_END = constants.EVENT_TEST_END;
27
- var inherits = require_utils().inherits;
28
- var sprintf = util.format;
29
- /**
30
- * Expose `TAP`.
31
- */
32
- exports = module.exports = TAP;
33
- /**
34
- * Constructs a new `TAP` reporter instance.
35
- *
36
- * @public
37
- * @class
38
- * @memberof Mocha.reporters
39
- * @extends Mocha.reporters.Base
40
- * @param {Runner} runner - Instance triggers reporter actions.
41
- * @param {Object} [options] - runner options
42
- */
43
- function TAP(runner, options) {
44
- Base.call(this, runner, options);
45
- var self = this;
46
- var n = 1;
47
- var tapVersion = "12";
48
- if (options && options.reporterOptions) {
49
- if (options.reporterOptions.tapVersion) tapVersion = options.reporterOptions.tapVersion.toString();
50
- }
51
- this._producer = createProducer(tapVersion);
52
- runner.once(EVENT_RUN_BEGIN, function() {
53
- self._producer.writeVersion();
54
- });
55
- runner.on(EVENT_TEST_END, function() {
56
- ++n;
57
- });
58
- runner.on(EVENT_TEST_PENDING, function(test) {
59
- self._producer.writePending(n, test);
60
- });
61
- runner.on(EVENT_TEST_PASS, function(test) {
62
- self._producer.writePass(n, test);
63
- });
64
- runner.on(EVENT_TEST_FAIL, function(test, err) {
65
- self._producer.writeFail(n, test, err);
66
- });
67
- runner.once(EVENT_RUN_END, function() {
68
- self._producer.writeEpilogue(runner.stats);
69
- });
70
- }
71
- /**
72
- * Inherit from `Base.prototype`.
73
- */
74
- inherits(TAP, Base);
75
- /**
76
- * Returns a TAP-safe title of `test`.
77
- *
78
- * @private
79
- * @param {Test} test - Test instance.
80
- * @return {String} title with any hash character removed
81
- */
82
- function title(test) {
83
- return test.fullTitle().replace(/#/g, "");
84
- }
85
- /**
86
- * Writes newline-terminated formatted string to reporter output stream.
87
- *
88
- * @private
89
- * @param {string} format - `printf`-like format string
90
- * @param {...*} [varArgs] - Format string arguments
91
- */
92
- function println() {
93
- var vargs = Array.from(arguments);
94
- vargs[0] += "\n";
95
- process.stdout.write(sprintf.apply(null, vargs));
96
- }
97
- /**
98
- * Returns a `tapVersion`-appropriate TAP producer instance, if possible.
99
- *
100
- * @private
101
- * @param {string} tapVersion - Version of TAP specification to produce.
102
- * @returns {TAPProducer} specification-appropriate instance
103
- * @throws {Error} if specification version has no associated producer.
104
- */
105
- function createProducer(tapVersion) {
106
- var producer = {
107
- 12: new TAP12Producer(),
108
- 13: new TAP13Producer()
109
- }[tapVersion];
110
- if (!producer) throw new Error("invalid or unsupported TAP version: " + JSON.stringify(tapVersion));
111
- return producer;
112
- }
113
- /**
114
- * @summary
115
- * Constructs a new TAPProducer.
116
- *
117
- * @description
118
- * <em>Only</em> to be used as an abstract base class.
119
- *
120
- * @private
121
- * @constructor
122
- */
123
- function TAPProducer() {}
124
- /**
125
- * Writes the TAP version to reporter output stream.
126
- *
127
- * @abstract
128
- */
129
- TAPProducer.prototype.writeVersion = function() {};
130
- /**
131
- * Writes the plan to reporter output stream.
132
- *
133
- * @abstract
134
- * @param {number} ntests - Number of tests that are planned to run.
135
- */
136
- TAPProducer.prototype.writePlan = function(ntests) {
137
- println("%d..%d", 1, ntests);
138
- };
139
- /**
140
- * Writes that test passed to reporter output stream.
141
- *
142
- * @abstract
143
- * @param {number} n - Index of test that passed.
144
- * @param {Test} test - Instance containing test information.
145
- */
146
- TAPProducer.prototype.writePass = function(n, test) {
147
- println("ok %d %s", n, title(test));
148
- };
149
- /**
150
- * Writes that test was skipped to reporter output stream.
151
- *
152
- * @abstract
153
- * @param {number} n - Index of test that was skipped.
154
- * @param {Test} test - Instance containing test information.
155
- */
156
- TAPProducer.prototype.writePending = function(n, test) {
157
- println("ok %d %s # SKIP -", n, title(test));
158
- };
159
- /**
160
- * Writes that test failed to reporter output stream.
161
- *
162
- * @abstract
163
- * @param {number} n - Index of test that failed.
164
- * @param {Test} test - Instance containing test information.
165
- */
166
- TAPProducer.prototype.writeFail = function(n, test) {
167
- println("not ok %d %s", n, title(test));
168
- };
169
- /**
170
- * Writes the summary epilogue to reporter output stream.
171
- *
172
- * @abstract
173
- * @param {Object} stats - Object containing run statistics.
174
- */
175
- TAPProducer.prototype.writeEpilogue = function(stats) {
176
- println("# tests " + (stats.passes + stats.failures));
177
- println("# pass " + stats.passes);
178
- println("# fail " + stats.failures);
179
- this.writePlan(stats.passes + stats.failures + stats.pending);
180
- };
181
- /**
182
- * @summary
183
- * Constructs a new TAP12Producer.
184
- *
185
- * @description
186
- * Produces output conforming to the TAP12 specification.
187
- *
188
- * @private
189
- * @constructor
190
- * @extends TAPProducer
191
- * @see {@link https://testanything.org/tap-specification.html|Specification}
192
- */
193
- function TAP12Producer() {
194
- /**
195
- * Writes that test failed to reporter output stream, with error formatting.
196
- * @override
197
- */
198
- this.writeFail = function(n, test, err) {
199
- TAPProducer.prototype.writeFail.call(this, n, test, err);
200
- if (err.message) println(err.message.replace(/^/gm, " "));
201
- if (err.stack) println(err.stack.replace(/^/gm, " "));
202
- };
203
- }
204
- /**
205
- * Inherit from `TAPProducer.prototype`.
206
- */
207
- inherits(TAP12Producer, TAPProducer);
208
- /**
209
- * @summary
210
- * Constructs a new TAP13Producer.
211
- *
212
- * @description
213
- * Produces output conforming to the TAP13 specification.
214
- *
215
- * @private
216
- * @constructor
217
- * @extends TAPProducer
218
- * @see {@link https://testanything.org/tap-version-13-specification.html|Specification}
219
- */
220
- function TAP13Producer() {
221
- /**
222
- * Writes the TAP version to reporter output stream.
223
- * @override
224
- */
225
- this.writeVersion = function() {
226
- println("TAP version 13");
227
- };
228
- /**
229
- * Writes that test failed to reporter output stream, with error formatting.
230
- * @override
231
- */
232
- this.writeFail = function(n, test, err) {
233
- TAPProducer.prototype.writeFail.call(this, n, test, err);
234
- if (err.message != null || err.stack != null) {
235
- println(indent(1) + "---");
236
- if (err.message) {
237
- println(indent(2) + "message: |-");
238
- println(err.message.replace(/^/gm, indent(3)));
239
- }
240
- if (err.stack) {
241
- println(indent(2) + "stack: |-");
242
- println(err.stack.replace(/^/gm, indent(3)));
243
- }
244
- println(indent(1) + "...");
245
- }
246
- };
247
- function indent(level) {
248
- return Array(level + 1).join(" ");
249
- }
250
- }
251
- /**
252
- * Inherit from `TAPProducer.prototype`.
253
- */
254
- inherits(TAP13Producer, TAPProducer);
255
- TAP.description = "TAP-compatible output";
256
- }) });
257
-
258
- //#endregion
259
- export default require_tap();
260
-
261
- export { require_tap };
@@ -1,166 +0,0 @@
1
- import { __commonJS, __require } from "../../../../../../../_virtual/rolldown_runtime.js";
2
- import { require_utils } from "../utils.js";
3
- import { require_errors } from "../errors.js";
4
- import { require_runnable } from "../runnable.js";
5
- import { require_runner } from "../runner.js";
6
- import { require_base } from "./base.js";
7
-
8
- //#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/xunit.js
9
- var require_xunit = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/xunit.js": ((exports, module) => {
10
- /**
11
- * @typedef {import('../runner.js')} Runner
12
- * @typedef {import('../test.js')} Test
13
- */
14
- /**
15
- * @module XUnit
16
- */
17
- /**
18
- * Module dependencies.
19
- */
20
- var Base = require_base();
21
- var utils = require_utils();
22
- var fs = __require("node:fs");
23
- var path = __require("node:path");
24
- var createUnsupportedError = require_errors().createUnsupportedError;
25
- var constants = require_runner().constants;
26
- var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
27
- var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
28
- var EVENT_RUN_END = constants.EVENT_RUN_END;
29
- var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
30
- var STATE_FAILED = require_runnable().constants.STATE_FAILED;
31
- var inherits = utils.inherits;
32
- var escape = utils.escape;
33
- /**
34
- * Save timer references to avoid Sinon interfering (see GH-237).
35
- */
36
- var Date = global.Date;
37
- /**
38
- * Expose `XUnit`.
39
- */
40
- exports = module.exports = XUnit;
41
- /**
42
- * Constructs a new `XUnit` reporter instance.
43
- *
44
- * @public
45
- * @class
46
- * @memberof Mocha.reporters
47
- * @extends Mocha.reporters.Base
48
- * @param {Runner} runner - Instance triggers reporter actions.
49
- * @param {Object} [options] - runner options
50
- */
51
- function XUnit(runner, options) {
52
- Base.call(this, runner, options);
53
- var stats = this.stats;
54
- var tests = [];
55
- var self = this;
56
- var suiteName;
57
- var DEFAULT_SUITE_NAME = "Mocha Tests";
58
- if (options && options.reporterOptions) {
59
- if (options.reporterOptions.output) {
60
- if (!fs.createWriteStream) throw createUnsupportedError("file output not supported in browser");
61
- fs.mkdirSync(path.dirname(options.reporterOptions.output), { recursive: true });
62
- self.fileStream = fs.createWriteStream(options.reporterOptions.output);
63
- }
64
- suiteName = options.reporterOptions.suiteName;
65
- }
66
- suiteName = suiteName || DEFAULT_SUITE_NAME;
67
- runner.on(EVENT_TEST_PENDING, function(test) {
68
- tests.push(test);
69
- });
70
- runner.on(EVENT_TEST_PASS, function(test) {
71
- tests.push(test);
72
- });
73
- runner.on(EVENT_TEST_FAIL, function(test) {
74
- tests.push(test);
75
- });
76
- runner.once(EVENT_RUN_END, function() {
77
- self.write(tag("testsuite", {
78
- name: suiteName,
79
- tests: stats.tests,
80
- failures: 0,
81
- errors: stats.failures,
82
- skipped: stats.tests - stats.failures - stats.passes,
83
- timestamp: new Date().toUTCString(),
84
- time: stats.duration / 1e3 || 0
85
- }, false));
86
- tests.forEach(function(t) {
87
- self.test(t, options);
88
- });
89
- self.write("</testsuite>");
90
- });
91
- }
92
- /**
93
- * Inherit from `Base.prototype`.
94
- */
95
- inherits(XUnit, Base);
96
- /**
97
- * Override done to close the stream (if it's a file).
98
- *
99
- * @param failures
100
- * @param {Function} fn
101
- */
102
- XUnit.prototype.done = function(failures, fn) {
103
- if (this.fileStream) this.fileStream.end(function() {
104
- fn(failures);
105
- });
106
- else fn(failures);
107
- };
108
- /**
109
- * Write out the given line.
110
- *
111
- * @param {string} line
112
- */
113
- XUnit.prototype.write = function(line) {
114
- if (this.fileStream) this.fileStream.write(line + "\n");
115
- else if (typeof process === "object" && process.stdout) process.stdout.write(line + "\n");
116
- else Base.consoleLog(line);
117
- };
118
- /**
119
- * Output tag for the given `test.`
120
- *
121
- * @param {Test} test
122
- */
123
- XUnit.prototype.test = function(test, options) {
124
- Base.useColors = false;
125
- var attrs = {
126
- classname: test.parent.fullTitle(),
127
- name: test.title,
128
- file: testFilePath(test.file, options),
129
- time: test.duration / 1e3 || 0
130
- };
131
- if (test.state === STATE_FAILED) {
132
- var err = test.err;
133
- var diff = !Base.hideDiff && Base.showDiff(err) ? "\n" + Base.generateDiff(err.actual, err.expected) : "";
134
- this.write(tag("testcase", attrs, false, tag("failure", {}, false, escape(err.message) + escape(diff) + "\n" + escape(err.stack))));
135
- } else if (test.isPending()) this.write(tag("testcase", attrs, false, tag("skipped", {}, true)));
136
- else this.write(tag("testcase", attrs, true));
137
- };
138
- /**
139
- * HTML tag helper.
140
- *
141
- * @param name
142
- * @param attrs
143
- * @param close
144
- * @param content
145
- * @return {string}
146
- */
147
- function tag(name, attrs, close, content) {
148
- var end = close ? "/>" : ">";
149
- var pairs = [];
150
- var tag$1;
151
- for (var key in attrs) if (Object.prototype.hasOwnProperty.call(attrs, key)) pairs.push(key + "=\"" + escape(attrs[key]) + "\"");
152
- tag$1 = "<" + name + (pairs.length ? " " + pairs.join(" ") : "") + end;
153
- if (content) tag$1 += content + "</" + name + end;
154
- return tag$1;
155
- }
156
- function testFilePath(filepath, options) {
157
- if (options && options.reporterOptions && options.reporterOptions.showRelativePaths) return path.relative(process.cwd(), filepath);
158
- return filepath;
159
- }
160
- XUnit.description = "XUnit-compatible XML output";
161
- }) });
162
-
163
- //#endregion
164
- export default require_xunit();
165
-
166
- export { require_xunit };