@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.
- package/README.md +1 -1
- package/README.zh_CN.md +1 -1
- package/dist/_virtual/rolldown_runtime.js +1 -24
- package/dist/inject_mocha.d.ts +1 -1
- package/dist/inject_mocha.js +2 -3
- package/dist/lib/app.js +4 -1
- package/dist/lib/context.js +1 -3
- package/dist/lib/types.d.ts +4 -0
- package/package.json +9 -13
- package/dist/node_modules/.pnpm/ansi-styles@4.3.0/node_modules/ansi-styles/index.js +0 -142
- package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js +0 -157
- package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/templates.js +0 -97
- package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/util.js +0 -40
- package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js +0 -814
- package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/index.js +0 -50
- package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/route.js +0 -68
- package/dist/node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js +0 -752
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/browser.js +0 -203
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/common.js +0 -209
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js +0 -18
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js +0 -215
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/dmp.js +0 -24
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/xml.js +0 -33
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/array.js +0 -29
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/base.js +0 -185
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/character.js +0 -23
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/css.js +0 -26
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/json.js +0 -83
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/line.js +0 -51
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/sentence.js +0 -26
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/word.js +0 -151
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/index.js +0 -178
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/apply.js +0 -168
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/create.js +0 -301
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/line-endings.js +0 -137
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/merge.js +0 -367
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/parse.js +0 -91
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/reverse.js +0 -99
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/array.js +0 -23
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/distance-iterator.js +0 -30
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/params.js +0 -22
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/string.js +0 -97
- package/dist/node_modules/.pnpm/escape-string-regexp@4.0.0/node_modules/escape-string-regexp/index.js +0 -14
- package/dist/node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js +0 -16
- package/dist/node_modules/.pnpm/he@1.2.0/node_modules/he/he.js +0 -4093
- package/dist/node_modules/.pnpm/is-unicode-supported@0.1.0/node_modules/is-unicode-supported/index.js +0 -14
- package/dist/node_modules/.pnpm/log-symbols@4.1.0/node_modules/log-symbols/index.js +0 -27
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/index.js +0 -12
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/context.js +0 -83
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/error-constants.js +0 -35
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/errors.js +0 -392
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/hook.js +0 -86
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/bdd.js +0 -104
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/common.js +0 -99
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/exports.js +0 -65
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/index.js +0 -18
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/qunit.js +0 -95
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/tdd.js +0 -105
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocha.js +0 -1037
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocharc.js +0 -24
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/buffered-worker-pool.js +0 -152
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/esm-utils.js +0 -74
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/file-unloader.js +0 -22
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/parallel-buffered-runner.js +0 -329
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/serializer.js +0 -314
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/pending.js +0 -22
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/base.js +0 -417
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/doc.js +0 -79
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/dot.js +0 -75
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/html.js +0 -283
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/index.js +0 -40
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json-stream.js +0 -90
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json.js +0 -145
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/landing.js +0 -107
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/list.js +0 -77
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/markdown.js +0 -106
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/min.js +0 -57
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/nyan.js +0 -233
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/progress.js +0 -92
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/spec.js +0 -91
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/tap.js +0 -261
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/xunit.js +0 -166
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runnable.js +0 -346
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runner.js +0 -922
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/stats-collector.js +0 -72
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/suite.js +0 -517
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/test.js +0 -105
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/utils.js +0 -505
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/package.js +0 -225
- package/dist/node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js +0 -124
- package/dist/node_modules/.pnpm/randombytes@2.1.0/node_modules/randombytes/index.js +0 -11
- package/dist/node_modules/.pnpm/serialize-javascript@6.0.2/node_modules/serialize-javascript/index.js +0 -114
- package/dist/node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js +0 -76
- package/dist/node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js +0 -89
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Pool.js +0 -366
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Promise.js +0 -248
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/WorkerHandler.js +0 -419
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/debug-port-allocator.js +0 -27
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/environment.js +0 -18
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/generated/embeddedWorker.js +0 -16
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/index.js +0 -63
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/transfer.js +0 -21
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/validateOptions.js +0 -9
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/worker.js +0 -277
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
import { __commonJS, __require } from "../../../../../../_virtual/rolldown_runtime.js";
|
|
2
|
-
import { require_ms } from "../../../../ms@2.1.3/node_modules/ms/index.js";
|
|
3
|
-
import { require_utils } from "./utils.js";
|
|
4
|
-
import { require_pending } from "./pending.js";
|
|
5
|
-
import { require_src } from "../../../../debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js";
|
|
6
|
-
import { require_errors } from "./errors.js";
|
|
7
|
-
|
|
8
|
-
//#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runnable.js
|
|
9
|
-
var require_runnable = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runnable.js": ((exports, module) => {
|
|
10
|
-
var EventEmitter = __require("node:events").EventEmitter;
|
|
11
|
-
var Pending = require_pending();
|
|
12
|
-
var debug = require_src()("mocha:runnable");
|
|
13
|
-
var milliseconds = require_ms();
|
|
14
|
-
var utils = require_utils();
|
|
15
|
-
const { createInvalidExceptionError, createMultipleDoneError, createTimeoutError } = require_errors();
|
|
16
|
-
/**
|
|
17
|
-
* Save timer references to avoid Sinon interfering (see GH-237).
|
|
18
|
-
* @private
|
|
19
|
-
*/
|
|
20
|
-
var Date = global.Date;
|
|
21
|
-
var setTimeout = global.setTimeout;
|
|
22
|
-
var clearTimeout = global.clearTimeout;
|
|
23
|
-
var toString = Object.prototype.toString;
|
|
24
|
-
var MAX_TIMEOUT = Math.pow(2, 31) - 1;
|
|
25
|
-
module.exports = Runnable;
|
|
26
|
-
/**
|
|
27
|
-
* Initialize a new `Runnable` with the given `title` and callback `fn`.
|
|
28
|
-
* Additional properties, like `getFullTitle()` and `slow()`, can be viewed in the `Runnable` source.
|
|
29
|
-
*
|
|
30
|
-
* @class
|
|
31
|
-
* @extends external:EventEmitter
|
|
32
|
-
* @public
|
|
33
|
-
* @param {String} title
|
|
34
|
-
* @param {Function} fn
|
|
35
|
-
*/
|
|
36
|
-
function Runnable(title, fn) {
|
|
37
|
-
this.title = title;
|
|
38
|
-
this.fn = fn;
|
|
39
|
-
this.body = (fn || "").toString();
|
|
40
|
-
this.async = fn && fn.length;
|
|
41
|
-
this.sync = !this.async;
|
|
42
|
-
this._timeout = 2e3;
|
|
43
|
-
this._slow = 75;
|
|
44
|
-
this._retries = -1;
|
|
45
|
-
utils.assignNewMochaID(this);
|
|
46
|
-
Object.defineProperty(this, "id", { get() {
|
|
47
|
-
return utils.getMochaID(this);
|
|
48
|
-
} });
|
|
49
|
-
this.reset();
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Inherit from `EventEmitter.prototype`.
|
|
53
|
-
*/
|
|
54
|
-
utils.inherits(Runnable, EventEmitter);
|
|
55
|
-
/**
|
|
56
|
-
* Resets the state initially or for a next run.
|
|
57
|
-
*/
|
|
58
|
-
Runnable.prototype.reset = function() {
|
|
59
|
-
this.timedOut = false;
|
|
60
|
-
this._currentRetry = 0;
|
|
61
|
-
this.pending = false;
|
|
62
|
-
delete this.state;
|
|
63
|
-
delete this.err;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Get current timeout value in msecs.
|
|
67
|
-
*
|
|
68
|
-
* @private
|
|
69
|
-
* @returns {number} current timeout threshold value
|
|
70
|
-
*/
|
|
71
|
-
/**
|
|
72
|
-
* @summary
|
|
73
|
-
* Set timeout threshold value (msecs).
|
|
74
|
-
*
|
|
75
|
-
* @description
|
|
76
|
-
* A string argument can use shorthand (e.g., "2s") and will be converted.
|
|
77
|
-
* The value will be clamped to range [<code>0</code>, <code>2^<sup>31</sup>-1</code>].
|
|
78
|
-
* If clamped value matches either range endpoint, timeouts will be disabled.
|
|
79
|
-
*
|
|
80
|
-
* @private
|
|
81
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout#Maximum_delay_value}
|
|
82
|
-
* @param {number|string} ms - Timeout threshold value.
|
|
83
|
-
* @returns {Runnable} this
|
|
84
|
-
* @chainable
|
|
85
|
-
*/
|
|
86
|
-
Runnable.prototype.timeout = function(ms) {
|
|
87
|
-
if (!arguments.length) return this._timeout;
|
|
88
|
-
if (typeof ms === "string") ms = milliseconds(ms);
|
|
89
|
-
var range = [0, MAX_TIMEOUT];
|
|
90
|
-
ms = utils.clamp(ms, range);
|
|
91
|
-
if (ms === range[0] || ms === range[1]) this._timeout = 0;
|
|
92
|
-
else this._timeout = ms;
|
|
93
|
-
debug("timeout %d", this._timeout);
|
|
94
|
-
if (this.timer) this.resetTimeout();
|
|
95
|
-
return this;
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* Set or get slow `ms`.
|
|
99
|
-
*
|
|
100
|
-
* @private
|
|
101
|
-
* @param {number|string} ms
|
|
102
|
-
* @return {Runnable|number} ms or Runnable instance.
|
|
103
|
-
*/
|
|
104
|
-
Runnable.prototype.slow = function(ms) {
|
|
105
|
-
if (!arguments.length || typeof ms === "undefined") return this._slow;
|
|
106
|
-
if (typeof ms === "string") ms = milliseconds(ms);
|
|
107
|
-
debug("slow %d", ms);
|
|
108
|
-
this._slow = ms;
|
|
109
|
-
return this;
|
|
110
|
-
};
|
|
111
|
-
/**
|
|
112
|
-
* Halt and mark as pending.
|
|
113
|
-
*
|
|
114
|
-
* @memberof Mocha.Runnable
|
|
115
|
-
* @public
|
|
116
|
-
*/
|
|
117
|
-
Runnable.prototype.skip = function() {
|
|
118
|
-
this.pending = true;
|
|
119
|
-
throw new Pending("sync skip; aborting execution");
|
|
120
|
-
};
|
|
121
|
-
/**
|
|
122
|
-
* Check if this runnable or its parent suite is marked as pending.
|
|
123
|
-
*
|
|
124
|
-
* @private
|
|
125
|
-
*/
|
|
126
|
-
Runnable.prototype.isPending = function() {
|
|
127
|
-
return this.pending || this.parent && this.parent.isPending();
|
|
128
|
-
};
|
|
129
|
-
/**
|
|
130
|
-
* Return `true` if this Runnable has failed.
|
|
131
|
-
* @return {boolean}
|
|
132
|
-
* @private
|
|
133
|
-
*/
|
|
134
|
-
Runnable.prototype.isFailed = function() {
|
|
135
|
-
return !this.isPending() && this.state === constants.STATE_FAILED;
|
|
136
|
-
};
|
|
137
|
-
/**
|
|
138
|
-
* Return `true` if this Runnable has passed.
|
|
139
|
-
* @return {boolean}
|
|
140
|
-
* @private
|
|
141
|
-
*/
|
|
142
|
-
Runnable.prototype.isPassed = function() {
|
|
143
|
-
return !this.isPending() && this.state === constants.STATE_PASSED;
|
|
144
|
-
};
|
|
145
|
-
/**
|
|
146
|
-
* Set or get number of retries.
|
|
147
|
-
*
|
|
148
|
-
* @private
|
|
149
|
-
*/
|
|
150
|
-
Runnable.prototype.retries = function(n) {
|
|
151
|
-
if (!arguments.length) return this._retries;
|
|
152
|
-
this._retries = n;
|
|
153
|
-
};
|
|
154
|
-
/**
|
|
155
|
-
* Set or get current retry
|
|
156
|
-
*
|
|
157
|
-
* @private
|
|
158
|
-
*/
|
|
159
|
-
Runnable.prototype.currentRetry = function(n) {
|
|
160
|
-
if (!arguments.length) return this._currentRetry;
|
|
161
|
-
this._currentRetry = n;
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* Return the full title generated by recursively concatenating the parent's
|
|
165
|
-
* full title.
|
|
166
|
-
*
|
|
167
|
-
* @memberof Mocha.Runnable
|
|
168
|
-
* @public
|
|
169
|
-
* @return {string}
|
|
170
|
-
*/
|
|
171
|
-
Runnable.prototype.fullTitle = function() {
|
|
172
|
-
return this.titlePath().join(" ");
|
|
173
|
-
};
|
|
174
|
-
/**
|
|
175
|
-
* Return the title path generated by concatenating the parent's title path with the title.
|
|
176
|
-
*
|
|
177
|
-
* @memberof Mocha.Runnable
|
|
178
|
-
* @public
|
|
179
|
-
* @return {string[]}
|
|
180
|
-
*/
|
|
181
|
-
Runnable.prototype.titlePath = function() {
|
|
182
|
-
return this.parent.titlePath().concat([this.title]);
|
|
183
|
-
};
|
|
184
|
-
/**
|
|
185
|
-
* Clear the timeout.
|
|
186
|
-
*
|
|
187
|
-
* @private
|
|
188
|
-
*/
|
|
189
|
-
Runnable.prototype.clearTimeout = function() {
|
|
190
|
-
clearTimeout(this.timer);
|
|
191
|
-
};
|
|
192
|
-
/**
|
|
193
|
-
* Reset the timeout.
|
|
194
|
-
*
|
|
195
|
-
* @private
|
|
196
|
-
*/
|
|
197
|
-
Runnable.prototype.resetTimeout = function() {
|
|
198
|
-
var self = this;
|
|
199
|
-
var ms = this.timeout() || MAX_TIMEOUT;
|
|
200
|
-
this.clearTimeout();
|
|
201
|
-
this.timer = setTimeout(function() {
|
|
202
|
-
if (self.timeout() === 0) return;
|
|
203
|
-
self.callback(self._timeoutError(ms));
|
|
204
|
-
self.timedOut = true;
|
|
205
|
-
}, ms);
|
|
206
|
-
};
|
|
207
|
-
/**
|
|
208
|
-
* Set or get a list of whitelisted globals for this test run.
|
|
209
|
-
*
|
|
210
|
-
* @private
|
|
211
|
-
* @param {string[]} globals
|
|
212
|
-
*/
|
|
213
|
-
Runnable.prototype.globals = function(globals) {
|
|
214
|
-
if (!arguments.length) return this._allowedGlobals;
|
|
215
|
-
this._allowedGlobals = globals;
|
|
216
|
-
};
|
|
217
|
-
/**
|
|
218
|
-
* Run the test and invoke `fn(err)`.
|
|
219
|
-
*
|
|
220
|
-
* @param {Function} fn
|
|
221
|
-
* @private
|
|
222
|
-
*/
|
|
223
|
-
Runnable.prototype.run = function(fn) {
|
|
224
|
-
var self = this;
|
|
225
|
-
var start = new Date();
|
|
226
|
-
var ctx = this.ctx;
|
|
227
|
-
var finished;
|
|
228
|
-
var errorWasHandled = false;
|
|
229
|
-
if (this.isPending()) return fn();
|
|
230
|
-
if (ctx && ctx.runnable) ctx.runnable(this);
|
|
231
|
-
function multiple(err) {
|
|
232
|
-
if (errorWasHandled) return;
|
|
233
|
-
errorWasHandled = true;
|
|
234
|
-
self.emit("error", createMultipleDoneError(self, err));
|
|
235
|
-
}
|
|
236
|
-
function done(err) {
|
|
237
|
-
var ms = self.timeout();
|
|
238
|
-
if (self.timedOut) return;
|
|
239
|
-
if (finished) return multiple(err);
|
|
240
|
-
self.clearTimeout();
|
|
241
|
-
self.duration = new Date() - start;
|
|
242
|
-
finished = true;
|
|
243
|
-
if (!err && self.duration > ms && ms > 0) err = self._timeoutError(ms);
|
|
244
|
-
fn(err);
|
|
245
|
-
}
|
|
246
|
-
this.callback = done;
|
|
247
|
-
if (this.fn && typeof this.fn.call !== "function") {
|
|
248
|
-
done(/* @__PURE__ */ new TypeError("A runnable must be passed a function as its second argument."));
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
if (this.async) {
|
|
252
|
-
this.resetTimeout();
|
|
253
|
-
this.skip = function asyncSkip() {
|
|
254
|
-
this.pending = true;
|
|
255
|
-
done();
|
|
256
|
-
throw new Pending("async skip; aborting execution");
|
|
257
|
-
};
|
|
258
|
-
try {
|
|
259
|
-
callFnAsync(this.fn);
|
|
260
|
-
} catch (err) {
|
|
261
|
-
errorWasHandled = true;
|
|
262
|
-
if (err instanceof Pending) return;
|
|
263
|
-
else if (this.allowUncaught) throw err;
|
|
264
|
-
done(Runnable.toValueOrError(err));
|
|
265
|
-
}
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
try {
|
|
269
|
-
callFn(this.fn);
|
|
270
|
-
} catch (err) {
|
|
271
|
-
errorWasHandled = true;
|
|
272
|
-
if (err instanceof Pending) return done();
|
|
273
|
-
else if (this.allowUncaught) throw err;
|
|
274
|
-
done(Runnable.toValueOrError(err));
|
|
275
|
-
}
|
|
276
|
-
function callFn(fn$1) {
|
|
277
|
-
var result = fn$1.call(ctx);
|
|
278
|
-
if (result && typeof result.then === "function") {
|
|
279
|
-
self.resetTimeout();
|
|
280
|
-
result.then(function() {
|
|
281
|
-
done();
|
|
282
|
-
return null;
|
|
283
|
-
}, function(reason) {
|
|
284
|
-
done(reason || /* @__PURE__ */ new Error("Promise rejected with no or falsy reason"));
|
|
285
|
-
});
|
|
286
|
-
} else {
|
|
287
|
-
if (self.asyncOnly) return done(/* @__PURE__ */ new Error("--async-only option in use without declaring `done()` or returning a promise"));
|
|
288
|
-
done();
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
function callFnAsync(fn$1) {
|
|
292
|
-
var result = fn$1.call(ctx, function(err) {
|
|
293
|
-
if (err instanceof Error || toString.call(err) === "[object Error]") return done(err);
|
|
294
|
-
if (err) {
|
|
295
|
-
if (Object.prototype.toString.call(err) === "[object Object]") return done(/* @__PURE__ */ new Error("done() invoked with non-Error: " + JSON.stringify(err)));
|
|
296
|
-
return done(/* @__PURE__ */ new Error("done() invoked with non-Error: " + err));
|
|
297
|
-
}
|
|
298
|
-
if (result && utils.isPromise(result)) return done(/* @__PURE__ */ new Error("Resolution method is overspecified. Specify a callback *or* return a Promise; not both."));
|
|
299
|
-
done();
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
/**
|
|
304
|
-
* Instantiates a "timeout" error
|
|
305
|
-
*
|
|
306
|
-
* @param {number} ms - Timeout (in milliseconds)
|
|
307
|
-
* @returns {Error} a "timeout" error
|
|
308
|
-
* @private
|
|
309
|
-
*/
|
|
310
|
-
Runnable.prototype._timeoutError = function(ms) {
|
|
311
|
-
let msg = `Timeout of ${ms}ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.`;
|
|
312
|
-
if (this.file) msg += " (" + this.file + ")";
|
|
313
|
-
return createTimeoutError(msg, ms, this.file);
|
|
314
|
-
};
|
|
315
|
-
var constants = utils.defineConstants(
|
|
316
|
-
/**
|
|
317
|
-
* {@link Runnable}-related constants.
|
|
318
|
-
* @public
|
|
319
|
-
* @memberof Runnable
|
|
320
|
-
* @readonly
|
|
321
|
-
* @static
|
|
322
|
-
* @alias constants
|
|
323
|
-
* @enum {string}
|
|
324
|
-
*/
|
|
325
|
-
{
|
|
326
|
-
STATE_FAILED: "failed",
|
|
327
|
-
STATE_PASSED: "passed",
|
|
328
|
-
STATE_PENDING: "pending"
|
|
329
|
-
}
|
|
330
|
-
);
|
|
331
|
-
/**
|
|
332
|
-
* Given `value`, return identity if truthy, otherwise create an "invalid exception" error and return that.
|
|
333
|
-
* @param {*} [value] - Value to return, if present
|
|
334
|
-
* @returns {*|Error} `value`, otherwise an `Error`
|
|
335
|
-
* @private
|
|
336
|
-
*/
|
|
337
|
-
Runnable.toValueOrError = function(value) {
|
|
338
|
-
return value || createInvalidExceptionError("Runnable failed with falsy or undefined exception. Please throw an Error instead.", value);
|
|
339
|
-
};
|
|
340
|
-
Runnable.constants = constants;
|
|
341
|
-
}) });
|
|
342
|
-
|
|
343
|
-
//#endregion
|
|
344
|
-
export default require_runnable();
|
|
345
|
-
|
|
346
|
-
export { require_runnable };
|