@eggjs/mock 6.1.0-beta.3 → 6.1.0-beta.5
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/dist/_virtual/rolldown_runtime.js +24 -1
- package/dist/bootstrap.d.ts +1 -1
- package/dist/bootstrap.js +1 -1
- package/dist/index.js +0 -1
- package/dist/inject_mocha.d.ts +1 -0
- package/dist/inject_mocha.js +35 -0
- package/dist/node_modules/.pnpm/ansi-styles@4.3.0/node_modules/ansi-styles/index.js +142 -0
- package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js +157 -0
- package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/templates.js +97 -0
- package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/util.js +40 -0
- package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js +812 -0
- package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/index.js +50 -0
- package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/route.js +68 -0
- package/dist/node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js +752 -0
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/browser.js +203 -0
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/common.js +209 -0
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js +18 -0
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js +215 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/dmp.js +24 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/xml.js +33 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/array.js +29 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/base.js +185 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/character.js +23 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/css.js +26 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/json.js +83 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/line.js +51 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/sentence.js +26 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/word.js +151 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/index.js +178 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/apply.js +168 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/create.js +301 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/line-endings.js +137 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/merge.js +367 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/parse.js +91 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/reverse.js +99 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/array.js +23 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/distance-iterator.js +30 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/params.js +22 -0
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/string.js +97 -0
- package/dist/node_modules/.pnpm/escape-string-regexp@4.0.0/node_modules/escape-string-regexp/index.js +14 -0
- package/dist/node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js +16 -0
- package/dist/node_modules/.pnpm/he@1.2.0/node_modules/he/he.js +4093 -0
- package/dist/node_modules/.pnpm/is-unicode-supported@0.1.0/node_modules/is-unicode-supported/index.js +14 -0
- package/dist/node_modules/.pnpm/log-symbols@4.1.0/node_modules/log-symbols/index.js +27 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/index.js +12 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/context.js +83 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/error-constants.js +35 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/errors.js +392 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/hook.js +86 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/bdd.js +104 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/common.js +99 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/exports.js +65 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/index.js +18 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/qunit.js +95 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/tdd.js +105 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocha.js +1037 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocharc.js +24 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/buffered-worker-pool.js +152 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/esm-utils.js +74 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/file-unloader.js +22 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/parallel-buffered-runner.js +329 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/serializer.js +314 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/pending.js +22 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/base.js +417 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/doc.js +79 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/dot.js +75 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/html.js +283 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/index.js +40 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json-stream.js +90 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json.js +145 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/landing.js +107 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/list.js +77 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/markdown.js +106 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/min.js +57 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/nyan.js +233 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/progress.js +92 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/spec.js +91 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/tap.js +261 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/xunit.js +166 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runnable.js +346 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runner.js +922 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/stats-collector.js +72 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/suite.js +517 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/test.js +105 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/utils.js +505 -0
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/package.js +225 -0
- package/dist/node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js +124 -0
- package/dist/node_modules/.pnpm/randombytes@2.1.0/node_modules/randombytes/index.js +11 -0
- package/dist/node_modules/.pnpm/serialize-javascript@6.0.2/node_modules/serialize-javascript/index.js +114 -0
- package/dist/node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js +76 -0
- package/dist/node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js +89 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Pool.js +366 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Promise.js +248 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/WorkerHandler.js +419 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/debug-port-allocator.js +27 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/environment.js +18 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/generated/embeddedWorker.js +16 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/index.js +63 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/transfer.js +21 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/validateOptions.js +9 -0
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/worker.js +277 -0
- package/dist/register.d.ts +0 -2
- package/dist/register.js +1 -26
- package/package.json +10 -8
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { __commonJS } from "../../../../../_virtual/rolldown_runtime.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../node_modules/.pnpm/is-unicode-supported@0.1.0/node_modules/is-unicode-supported/index.js
|
|
4
|
+
var require_is_unicode_supported = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/is-unicode-supported@0.1.0/node_modules/is-unicode-supported/index.js": ((exports, module) => {
|
|
5
|
+
module.exports = () => {
|
|
6
|
+
if (process.platform !== "win32") return true;
|
|
7
|
+
return Boolean(process.env.CI) || Boolean(process.env.WT_SESSION) || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty";
|
|
8
|
+
};
|
|
9
|
+
}) });
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export default require_is_unicode_supported();
|
|
13
|
+
|
|
14
|
+
export { require_is_unicode_supported };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { __commonJS } from "../../../../../_virtual/rolldown_runtime.js";
|
|
2
|
+
import { require_source } from "../../../chalk@4.1.2/node_modules/chalk/source/index.js";
|
|
3
|
+
import { require_is_unicode_supported } from "../../../is-unicode-supported@0.1.0/node_modules/is-unicode-supported/index.js";
|
|
4
|
+
|
|
5
|
+
//#region ../../node_modules/.pnpm/log-symbols@4.1.0/node_modules/log-symbols/index.js
|
|
6
|
+
var require_log_symbols = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/log-symbols@4.1.0/node_modules/log-symbols/index.js": ((exports, module) => {
|
|
7
|
+
const chalk = require_source();
|
|
8
|
+
const isUnicodeSupported = require_is_unicode_supported();
|
|
9
|
+
const main = {
|
|
10
|
+
info: chalk.blue("ℹ"),
|
|
11
|
+
success: chalk.green("✔"),
|
|
12
|
+
warning: chalk.yellow("⚠"),
|
|
13
|
+
error: chalk.red("✖")
|
|
14
|
+
};
|
|
15
|
+
const fallback = {
|
|
16
|
+
info: chalk.blue("i"),
|
|
17
|
+
success: chalk.green("√"),
|
|
18
|
+
warning: chalk.yellow("‼"),
|
|
19
|
+
error: chalk.red("×")
|
|
20
|
+
};
|
|
21
|
+
module.exports = isUnicodeSupported() ? main : fallback;
|
|
22
|
+
}) });
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export default require_log_symbols();
|
|
26
|
+
|
|
27
|
+
export { require_log_symbols };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { __commonJS } from "../../../../../_virtual/rolldown_runtime.js";
|
|
2
|
+
import { require_mocha as require_mocha$1 } from "./lib/mocha.js";
|
|
3
|
+
|
|
4
|
+
//#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/index.js
|
|
5
|
+
var require_mocha = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/index.js": ((exports, module) => {
|
|
6
|
+
module.exports = require_mocha$1();
|
|
7
|
+
}) });
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export default require_mocha();
|
|
11
|
+
|
|
12
|
+
export { require_mocha };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { __commonJS } from "../../../../../../_virtual/rolldown_runtime.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/context.js
|
|
4
|
+
var require_context = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/context.js": ((exports, module) => {
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {import('./runnable.js')} Runnable
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @module Context
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Expose `Context`.
|
|
13
|
+
*/
|
|
14
|
+
module.exports = Context;
|
|
15
|
+
/**
|
|
16
|
+
* Initialize a new `Context`.
|
|
17
|
+
*
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
function Context() {}
|
|
21
|
+
/**
|
|
22
|
+
* Set or get the context `Runnable` to `runnable`.
|
|
23
|
+
*
|
|
24
|
+
* @private
|
|
25
|
+
* @param {Runnable} runnable
|
|
26
|
+
* @return {Context} context
|
|
27
|
+
*/
|
|
28
|
+
Context.prototype.runnable = function(runnable) {
|
|
29
|
+
if (!arguments.length) return this._runnable;
|
|
30
|
+
this.test = this._runnable = runnable;
|
|
31
|
+
return this;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Set or get test timeout `ms`.
|
|
35
|
+
*
|
|
36
|
+
* @private
|
|
37
|
+
* @param {number} ms
|
|
38
|
+
* @return {Context} self
|
|
39
|
+
*/
|
|
40
|
+
Context.prototype.timeout = function(ms) {
|
|
41
|
+
if (!arguments.length) return this.runnable().timeout();
|
|
42
|
+
this.runnable().timeout(ms);
|
|
43
|
+
return this;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Set or get test slowness threshold `ms`.
|
|
47
|
+
*
|
|
48
|
+
* @private
|
|
49
|
+
* @param {number} ms
|
|
50
|
+
* @return {Context} self
|
|
51
|
+
*/
|
|
52
|
+
Context.prototype.slow = function(ms) {
|
|
53
|
+
if (!arguments.length) return this.runnable().slow();
|
|
54
|
+
this.runnable().slow(ms);
|
|
55
|
+
return this;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Mark a test as skipped.
|
|
59
|
+
*
|
|
60
|
+
* @private
|
|
61
|
+
* @throws Pending
|
|
62
|
+
*/
|
|
63
|
+
Context.prototype.skip = function() {
|
|
64
|
+
this.runnable().skip();
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Set or get a number of allowed retries on failed tests
|
|
68
|
+
*
|
|
69
|
+
* @private
|
|
70
|
+
* @param {number} n
|
|
71
|
+
* @return {Context} self
|
|
72
|
+
*/
|
|
73
|
+
Context.prototype.retries = function(n) {
|
|
74
|
+
if (!arguments.length) return this.runnable().retries();
|
|
75
|
+
this.runnable().retries(n);
|
|
76
|
+
return this;
|
|
77
|
+
};
|
|
78
|
+
}) });
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
export default require_context();
|
|
82
|
+
|
|
83
|
+
export { require_context };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { __commonJS } from "../../../../../../_virtual/rolldown_runtime.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/error-constants.js
|
|
4
|
+
var require_error_constants = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/error-constants.js": ((exports, module) => {
|
|
5
|
+
/**
|
|
6
|
+
* When Mocha throws exceptions (or rejects `Promise`s), it attempts to assign a `code` property to the `Error` object, for easier handling. These are the potential values of `code`.
|
|
7
|
+
* @public
|
|
8
|
+
* @namespace
|
|
9
|
+
* @memberof module:lib/errors
|
|
10
|
+
*/
|
|
11
|
+
var constants = {
|
|
12
|
+
FATAL: "ERR_MOCHA_FATAL",
|
|
13
|
+
INVALID_ARG_TYPE: "ERR_MOCHA_INVALID_ARG_TYPE",
|
|
14
|
+
INVALID_ARG_VALUE: "ERR_MOCHA_INVALID_ARG_VALUE",
|
|
15
|
+
INVALID_EXCEPTION: "ERR_MOCHA_INVALID_EXCEPTION",
|
|
16
|
+
INVALID_INTERFACE: "ERR_MOCHA_INVALID_INTERFACE",
|
|
17
|
+
INVALID_REPORTER: "ERR_MOCHA_INVALID_REPORTER",
|
|
18
|
+
MULTIPLE_DONE: "ERR_MOCHA_MULTIPLE_DONE",
|
|
19
|
+
NO_FILES_MATCH_PATTERN: "ERR_MOCHA_NO_FILES_MATCH_PATTERN",
|
|
20
|
+
UNSUPPORTED: "ERR_MOCHA_UNSUPPORTED",
|
|
21
|
+
INSTANCE_ALREADY_RUNNING: "ERR_MOCHA_INSTANCE_ALREADY_RUNNING",
|
|
22
|
+
INSTANCE_ALREADY_DISPOSED: "ERR_MOCHA_INSTANCE_ALREADY_DISPOSED",
|
|
23
|
+
FORBIDDEN_EXCLUSIVITY: "ERR_MOCHA_FORBIDDEN_EXCLUSIVITY",
|
|
24
|
+
INVALID_PLUGIN_IMPLEMENTATION: "ERR_MOCHA_INVALID_PLUGIN_IMPLEMENTATION",
|
|
25
|
+
INVALID_PLUGIN_DEFINITION: "ERR_MOCHA_INVALID_PLUGIN_DEFINITION",
|
|
26
|
+
TIMEOUT: "ERR_MOCHA_TIMEOUT",
|
|
27
|
+
UNPARSABLE_FILE: "ERR_MOCHA_UNPARSABLE_FILE"
|
|
28
|
+
};
|
|
29
|
+
module.exports = { constants };
|
|
30
|
+
}) });
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export default require_error_constants();
|
|
34
|
+
|
|
35
|
+
export { require_error_constants };
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import { __commonJS, __require } from "../../../../../../_virtual/rolldown_runtime.js";
|
|
2
|
+
import { require_error_constants } from "./error-constants.js";
|
|
3
|
+
|
|
4
|
+
//#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/errors.js
|
|
5
|
+
var require_errors = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/errors.js": ((exports, module) => {
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {import('./mocha.js')} Mocha
|
|
8
|
+
* @typedef {import('./runnable.js')} Runnable
|
|
9
|
+
* @typedef {import('./types.d.ts').MochaTimeoutError} MochaTimeoutError
|
|
10
|
+
* @typedef {import('./types.d.ts').PluginDefinition} PluginDefinition
|
|
11
|
+
*/
|
|
12
|
+
const { format } = __require("node:util");
|
|
13
|
+
const { constants } = require_error_constants();
|
|
14
|
+
/**
|
|
15
|
+
* Contains error codes, factory functions to create throwable error objects,
|
|
16
|
+
* and warning/deprecation functions.
|
|
17
|
+
* @module
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* process.emitWarning or a polyfill
|
|
21
|
+
* @see https://nodejs.org/api/process.html#process_process_emitwarning_warning_options
|
|
22
|
+
* @ignore
|
|
23
|
+
*/
|
|
24
|
+
const emitWarning = (msg, type) => {
|
|
25
|
+
if (process.emitWarning) process.emitWarning(msg, type);
|
|
26
|
+
else
|
|
27
|
+
/* istanbul ignore next */
|
|
28
|
+
process.nextTick(function() {
|
|
29
|
+
console.warn(type + ": " + msg);
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Show a deprecation warning. Each distinct message is only displayed once.
|
|
34
|
+
* Ignores empty messages.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} [msg] - Warning to print
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
const deprecate = (msg) => {
|
|
40
|
+
msg = String(msg);
|
|
41
|
+
if (msg && !deprecate.cache[msg]) {
|
|
42
|
+
deprecate.cache[msg] = true;
|
|
43
|
+
emitWarning(msg, "DeprecationWarning");
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
deprecate.cache = {};
|
|
47
|
+
/**
|
|
48
|
+
* Show a generic warning.
|
|
49
|
+
* Ignores empty messages.
|
|
50
|
+
*
|
|
51
|
+
* @param {string} [msg] - Warning to print
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
const warn = (msg) => {
|
|
55
|
+
if (msg) emitWarning(msg);
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* A set containing all string values of all Mocha error constants, for use by {@link isMochaError}.
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
const MOCHA_ERRORS = new Set(Object.values(constants));
|
|
62
|
+
/**
|
|
63
|
+
* Creates an error object to be thrown when no files to be tested could be found using specified pattern.
|
|
64
|
+
*
|
|
65
|
+
* @public
|
|
66
|
+
* @static
|
|
67
|
+
* @param {string} message - Error message to be displayed.
|
|
68
|
+
* @param {string} pattern - User-specified argument value.
|
|
69
|
+
* @returns {Error} instance detailing the error condition
|
|
70
|
+
*/
|
|
71
|
+
function createNoFilesMatchPatternError(message, pattern) {
|
|
72
|
+
var err = new Error(message);
|
|
73
|
+
err.code = constants.NO_FILES_MATCH_PATTERN;
|
|
74
|
+
err.pattern = pattern;
|
|
75
|
+
return err;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Creates an error object to be thrown when the reporter specified in the options was not found.
|
|
79
|
+
*
|
|
80
|
+
* @public
|
|
81
|
+
* @param {string} message - Error message to be displayed.
|
|
82
|
+
* @param {string} reporter - User-specified reporter value.
|
|
83
|
+
* @returns {Error} instance detailing the error condition
|
|
84
|
+
*/
|
|
85
|
+
function createInvalidReporterError(message, reporter) {
|
|
86
|
+
var err = new TypeError(message);
|
|
87
|
+
err.code = constants.INVALID_REPORTER;
|
|
88
|
+
err.reporter = reporter;
|
|
89
|
+
return err;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Creates an error object to be thrown when the interface specified in the options was not found.
|
|
93
|
+
*
|
|
94
|
+
* @public
|
|
95
|
+
* @static
|
|
96
|
+
* @param {string} message - Error message to be displayed.
|
|
97
|
+
* @param {string} ui - User-specified interface value.
|
|
98
|
+
* @returns {Error} instance detailing the error condition
|
|
99
|
+
*/
|
|
100
|
+
function createInvalidInterfaceError(message, ui) {
|
|
101
|
+
var err = new Error(message);
|
|
102
|
+
err.code = constants.INVALID_INTERFACE;
|
|
103
|
+
err.interface = ui;
|
|
104
|
+
return err;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Creates an error object to be thrown when a behavior, option, or parameter is unsupported.
|
|
108
|
+
*
|
|
109
|
+
* @public
|
|
110
|
+
* @static
|
|
111
|
+
* @param {string} message - Error message to be displayed.
|
|
112
|
+
* @returns {Error} instance detailing the error condition
|
|
113
|
+
*/
|
|
114
|
+
function createUnsupportedError(message) {
|
|
115
|
+
var err = new Error(message);
|
|
116
|
+
err.code = constants.UNSUPPORTED;
|
|
117
|
+
return err;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Creates an error object to be thrown when an argument is missing.
|
|
121
|
+
*
|
|
122
|
+
* @public
|
|
123
|
+
* @static
|
|
124
|
+
* @param {string} message - Error message to be displayed.
|
|
125
|
+
* @param {string} argument - Argument name.
|
|
126
|
+
* @param {string} expected - Expected argument datatype.
|
|
127
|
+
* @returns {Error} instance detailing the error condition
|
|
128
|
+
*/
|
|
129
|
+
function createMissingArgumentError(message, argument, expected) {
|
|
130
|
+
return createInvalidArgumentTypeError(message, argument, expected);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Creates an error object to be thrown when an argument did not use the supported type
|
|
134
|
+
*
|
|
135
|
+
* @public
|
|
136
|
+
* @static
|
|
137
|
+
* @param {string} message - Error message to be displayed.
|
|
138
|
+
* @param {string} argument - Argument name.
|
|
139
|
+
* @param {string} expected - Expected argument datatype.
|
|
140
|
+
* @returns {Error} instance detailing the error condition
|
|
141
|
+
*/
|
|
142
|
+
function createInvalidArgumentTypeError(message, argument, expected) {
|
|
143
|
+
var err = new TypeError(message);
|
|
144
|
+
err.code = constants.INVALID_ARG_TYPE;
|
|
145
|
+
err.argument = argument;
|
|
146
|
+
err.expected = expected;
|
|
147
|
+
err.actual = typeof argument;
|
|
148
|
+
return err;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Creates an error object to be thrown when an argument did not use the supported value
|
|
152
|
+
*
|
|
153
|
+
* @public
|
|
154
|
+
* @static
|
|
155
|
+
* @param {string} message - Error message to be displayed.
|
|
156
|
+
* @param {string} argument - Argument name.
|
|
157
|
+
* @param {string} value - Argument value.
|
|
158
|
+
* @param {string} [reason] - Why value is invalid.
|
|
159
|
+
* @returns {Error} instance detailing the error condition
|
|
160
|
+
*/
|
|
161
|
+
function createInvalidArgumentValueError(message, argument, value, reason) {
|
|
162
|
+
var err = new TypeError(message);
|
|
163
|
+
err.code = constants.INVALID_ARG_VALUE;
|
|
164
|
+
err.argument = argument;
|
|
165
|
+
err.value = value;
|
|
166
|
+
err.reason = typeof reason !== "undefined" ? reason : "is invalid";
|
|
167
|
+
return err;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Creates an error object to be thrown when an exception was caught, but the `Error` is falsy or undefined.
|
|
171
|
+
*
|
|
172
|
+
* @public
|
|
173
|
+
* @static
|
|
174
|
+
* @param {string} message - Error message to be displayed.
|
|
175
|
+
* @returns {Error} instance detailing the error condition
|
|
176
|
+
*/
|
|
177
|
+
function createInvalidExceptionError(message, value) {
|
|
178
|
+
var err = new Error(message);
|
|
179
|
+
err.code = constants.INVALID_EXCEPTION;
|
|
180
|
+
err.valueType = typeof value;
|
|
181
|
+
err.value = value;
|
|
182
|
+
return err;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Creates an error object to be thrown when an unrecoverable error occurs.
|
|
186
|
+
*
|
|
187
|
+
* @public
|
|
188
|
+
* @static
|
|
189
|
+
* @param {string} message - Error message to be displayed.
|
|
190
|
+
* @returns {Error} instance detailing the error condition
|
|
191
|
+
*/
|
|
192
|
+
function createFatalError(message, value) {
|
|
193
|
+
var err = new Error(message);
|
|
194
|
+
err.code = constants.FATAL;
|
|
195
|
+
err.valueType = typeof value;
|
|
196
|
+
err.value = value;
|
|
197
|
+
return err;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Dynamically creates a plugin-type-specific error based on plugin type
|
|
201
|
+
* @param {string} message - Error message
|
|
202
|
+
* @param {"reporter"|"ui"} pluginType - Plugin type. Future: expand as needed
|
|
203
|
+
* @param {string} [pluginId] - Name/path of plugin, if any
|
|
204
|
+
* @throws When `pluginType` is not known
|
|
205
|
+
* @public
|
|
206
|
+
* @static
|
|
207
|
+
* @returns {Error}
|
|
208
|
+
*/
|
|
209
|
+
function createInvalidLegacyPluginError(message, pluginType, pluginId) {
|
|
210
|
+
switch (pluginType) {
|
|
211
|
+
case "reporter": return createInvalidReporterError(message, pluginId);
|
|
212
|
+
case "ui": return createInvalidInterfaceError(message, pluginId);
|
|
213
|
+
default: throw new Error("unknown pluginType \"" + pluginType + "\"");
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* **DEPRECATED**. Use {@link createInvalidLegacyPluginError} instead Dynamically creates a plugin-type-specific error based on plugin type
|
|
218
|
+
* @deprecated
|
|
219
|
+
* @param {string} message - Error message
|
|
220
|
+
* @param {"reporter"|"interface"} pluginType - Plugin type. Future: expand as needed
|
|
221
|
+
* @param {string} [pluginId] - Name/path of plugin, if any
|
|
222
|
+
* @throws When `pluginType` is not known
|
|
223
|
+
* @public
|
|
224
|
+
* @static
|
|
225
|
+
* @returns {Error}
|
|
226
|
+
*/
|
|
227
|
+
function createInvalidPluginError(...args) {
|
|
228
|
+
deprecate("Use createInvalidLegacyPluginError() instead");
|
|
229
|
+
return createInvalidLegacyPluginError(...args);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Creates an error object to be thrown when a mocha object's `run` method is executed while it is already disposed.
|
|
233
|
+
* @param {string} message The error message to be displayed.
|
|
234
|
+
* @param {boolean} cleanReferencesAfterRun the value of `cleanReferencesAfterRun`
|
|
235
|
+
* @param {Mocha} instance the mocha instance that throw this error
|
|
236
|
+
* @static
|
|
237
|
+
*/
|
|
238
|
+
function createMochaInstanceAlreadyDisposedError(message, cleanReferencesAfterRun, instance) {
|
|
239
|
+
var err = new Error(message);
|
|
240
|
+
err.code = constants.INSTANCE_ALREADY_DISPOSED;
|
|
241
|
+
err.cleanReferencesAfterRun = cleanReferencesAfterRun;
|
|
242
|
+
err.instance = instance;
|
|
243
|
+
return err;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Creates an error object to be thrown when a mocha object's `run` method is called while a test run is in progress.
|
|
247
|
+
* @param {string} message The error message to be displayed.
|
|
248
|
+
* @static
|
|
249
|
+
* @public
|
|
250
|
+
*/
|
|
251
|
+
function createMochaInstanceAlreadyRunningError(message, instance) {
|
|
252
|
+
var err = new Error(message);
|
|
253
|
+
err.code = constants.INSTANCE_ALREADY_RUNNING;
|
|
254
|
+
err.instance = instance;
|
|
255
|
+
return err;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Creates an error object to be thrown when done() is called multiple times in a test
|
|
259
|
+
*
|
|
260
|
+
* @public
|
|
261
|
+
* @param {Runnable} runnable - Original runnable
|
|
262
|
+
* @param {Error} [originalErr] - Original error, if any
|
|
263
|
+
* @returns {Error} instance detailing the error condition
|
|
264
|
+
* @static
|
|
265
|
+
*/
|
|
266
|
+
function createMultipleDoneError(runnable, originalErr) {
|
|
267
|
+
var title;
|
|
268
|
+
try {
|
|
269
|
+
title = format("<%s>", runnable.fullTitle());
|
|
270
|
+
if (runnable.parent.root) title += " (of root suite)";
|
|
271
|
+
} catch (ignored) {
|
|
272
|
+
title = format("<%s> (of unknown suite)", runnable.title);
|
|
273
|
+
}
|
|
274
|
+
var message = format("done() called multiple times in %s %s", runnable.type ? runnable.type : "unknown runnable", title);
|
|
275
|
+
if (runnable.file) message += format(" of file %s", runnable.file);
|
|
276
|
+
if (originalErr) message += format("; in addition, done() received error: %s", originalErr);
|
|
277
|
+
var err = new Error(message);
|
|
278
|
+
err.code = constants.MULTIPLE_DONE;
|
|
279
|
+
err.valueType = typeof originalErr;
|
|
280
|
+
err.value = originalErr;
|
|
281
|
+
return err;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Creates an error object to be thrown when `.only()` is used with
|
|
285
|
+
* `--forbid-only`.
|
|
286
|
+
* @static
|
|
287
|
+
* @public
|
|
288
|
+
* @param {Mocha} mocha - Mocha instance
|
|
289
|
+
* @returns {Error} Error with code {@link constants.FORBIDDEN_EXCLUSIVITY}
|
|
290
|
+
*/
|
|
291
|
+
function createForbiddenExclusivityError(mocha) {
|
|
292
|
+
var err = /* @__PURE__ */ new Error(mocha.isWorker ? "`.only` is not supported in parallel mode" : "`.only` forbidden by --forbid-only");
|
|
293
|
+
err.code = constants.FORBIDDEN_EXCLUSIVITY;
|
|
294
|
+
return err;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Creates an error object to be thrown when a plugin definition is invalid
|
|
298
|
+
* @static
|
|
299
|
+
* @param {string} msg - Error message
|
|
300
|
+
* @param {PluginDefinition} [pluginDef] - Problematic plugin definition
|
|
301
|
+
* @public
|
|
302
|
+
* @returns {Error} Error with code {@link constants.INVALID_PLUGIN_DEFINITION}
|
|
303
|
+
*/
|
|
304
|
+
function createInvalidPluginDefinitionError(msg, pluginDef) {
|
|
305
|
+
const err = new Error(msg);
|
|
306
|
+
err.code = constants.INVALID_PLUGIN_DEFINITION;
|
|
307
|
+
err.pluginDef = pluginDef;
|
|
308
|
+
return err;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Creates an error object to be thrown when a plugin implementation (user code) is invalid
|
|
312
|
+
* @static
|
|
313
|
+
* @param {string} msg - Error message
|
|
314
|
+
* @param {Object} [opts] - Plugin definition and user-supplied implementation
|
|
315
|
+
* @param {PluginDefinition} [opts.pluginDef] - Plugin Definition
|
|
316
|
+
* @param {*} [opts.pluginImpl] - Plugin Implementation (user-supplied)
|
|
317
|
+
* @public
|
|
318
|
+
* @returns {Error} Error with code {@link constants.INVALID_PLUGIN_DEFINITION}
|
|
319
|
+
*/
|
|
320
|
+
function createInvalidPluginImplementationError(msg, { pluginDef, pluginImpl } = {}) {
|
|
321
|
+
const err = new Error(msg);
|
|
322
|
+
err.code = constants.INVALID_PLUGIN_IMPLEMENTATION;
|
|
323
|
+
err.pluginDef = pluginDef;
|
|
324
|
+
err.pluginImpl = pluginImpl;
|
|
325
|
+
return err;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Creates an error object to be thrown when a runnable exceeds its allowed run time.
|
|
329
|
+
* @static
|
|
330
|
+
* @param {string} msg - Error message
|
|
331
|
+
* @param {number} [timeout] - Timeout in ms
|
|
332
|
+
* @param {string} [file] - File, if given
|
|
333
|
+
* @returns {MochaTimeoutError}
|
|
334
|
+
*/
|
|
335
|
+
function createTimeoutError(msg, timeout, file) {
|
|
336
|
+
const err = new Error(msg);
|
|
337
|
+
err.code = constants.TIMEOUT;
|
|
338
|
+
err.timeout = timeout;
|
|
339
|
+
err.file = file;
|
|
340
|
+
return err;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Creates an error object to be thrown when file is unparsable
|
|
344
|
+
* @public
|
|
345
|
+
* @static
|
|
346
|
+
* @param {string} message - Error message to be displayed.
|
|
347
|
+
* @returns {Error} Error with code {@link constants.UNPARSABLE_FILE}
|
|
348
|
+
*/
|
|
349
|
+
function createUnparsableFileError(message) {
|
|
350
|
+
var err = new Error(message);
|
|
351
|
+
err.code = constants.UNPARSABLE_FILE;
|
|
352
|
+
return err;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Returns `true` if an error came out of Mocha.
|
|
356
|
+
* _Can suffer from false negatives, but not false positives._
|
|
357
|
+
* @static
|
|
358
|
+
* @public
|
|
359
|
+
* @param {*} err - Error, or anything
|
|
360
|
+
* @returns {boolean}
|
|
361
|
+
*/
|
|
362
|
+
const isMochaError = (err) => Boolean(err && typeof err === "object" && MOCHA_ERRORS.has(err.code));
|
|
363
|
+
module.exports = {
|
|
364
|
+
createFatalError,
|
|
365
|
+
createForbiddenExclusivityError,
|
|
366
|
+
createInvalidArgumentTypeError,
|
|
367
|
+
createInvalidArgumentValueError,
|
|
368
|
+
createInvalidExceptionError,
|
|
369
|
+
createInvalidInterfaceError,
|
|
370
|
+
createInvalidLegacyPluginError,
|
|
371
|
+
createInvalidPluginDefinitionError,
|
|
372
|
+
createInvalidPluginError,
|
|
373
|
+
createInvalidPluginImplementationError,
|
|
374
|
+
createInvalidReporterError,
|
|
375
|
+
createMissingArgumentError,
|
|
376
|
+
createMochaInstanceAlreadyDisposedError,
|
|
377
|
+
createMochaInstanceAlreadyRunningError,
|
|
378
|
+
createMultipleDoneError,
|
|
379
|
+
createNoFilesMatchPatternError,
|
|
380
|
+
createTimeoutError,
|
|
381
|
+
createUnparsableFileError,
|
|
382
|
+
createUnsupportedError,
|
|
383
|
+
deprecate,
|
|
384
|
+
isMochaError,
|
|
385
|
+
warn
|
|
386
|
+
};
|
|
387
|
+
}) });
|
|
388
|
+
|
|
389
|
+
//#endregion
|
|
390
|
+
export default require_errors();
|
|
391
|
+
|
|
392
|
+
export { require_errors };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { __commonJS } from "../../../../../../_virtual/rolldown_runtime.js";
|
|
2
|
+
import { require_utils } from "./utils.js";
|
|
3
|
+
import { require_runnable } from "./runnable.js";
|
|
4
|
+
|
|
5
|
+
//#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/hook.js
|
|
6
|
+
var require_hook = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/hook.js": ((exports, module) => {
|
|
7
|
+
var Runnable = require_runnable();
|
|
8
|
+
const { inherits, constants } = require_utils();
|
|
9
|
+
const { MOCHA_ID_PROP_NAME } = constants;
|
|
10
|
+
/**
|
|
11
|
+
* Expose `Hook`.
|
|
12
|
+
*/
|
|
13
|
+
module.exports = Hook;
|
|
14
|
+
/**
|
|
15
|
+
* Initialize a new `Hook` with the given `title` and callback `fn`
|
|
16
|
+
*
|
|
17
|
+
* @class
|
|
18
|
+
* @extends Runnable
|
|
19
|
+
* @param {String} title
|
|
20
|
+
* @param {Function} fn
|
|
21
|
+
*/
|
|
22
|
+
function Hook(title, fn) {
|
|
23
|
+
Runnable.call(this, title, fn);
|
|
24
|
+
this.type = "hook";
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Inherit from `Runnable.prototype`.
|
|
28
|
+
*/
|
|
29
|
+
inherits(Hook, Runnable);
|
|
30
|
+
/**
|
|
31
|
+
* Resets the state for a next run.
|
|
32
|
+
*/
|
|
33
|
+
Hook.prototype.reset = function() {
|
|
34
|
+
Runnable.prototype.reset.call(this);
|
|
35
|
+
delete this._error;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Get or set the test `err`.
|
|
39
|
+
*
|
|
40
|
+
* @memberof Hook
|
|
41
|
+
* @public
|
|
42
|
+
* @param {Error} err
|
|
43
|
+
* @return {Error}
|
|
44
|
+
*/
|
|
45
|
+
Hook.prototype.error = function(err) {
|
|
46
|
+
if (!arguments.length) {
|
|
47
|
+
err = this._error;
|
|
48
|
+
this._error = null;
|
|
49
|
+
return err;
|
|
50
|
+
}
|
|
51
|
+
this._error = err;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Returns an object suitable for IPC.
|
|
55
|
+
* Functions are represented by keys beginning with `$$`.
|
|
56
|
+
* @private
|
|
57
|
+
* @returns {Object}
|
|
58
|
+
*/
|
|
59
|
+
Hook.prototype.serialize = function serialize() {
|
|
60
|
+
return {
|
|
61
|
+
$$currentRetry: this.currentRetry(),
|
|
62
|
+
$$fullTitle: this.fullTitle(),
|
|
63
|
+
$$isPending: Boolean(this.isPending()),
|
|
64
|
+
$$titlePath: this.titlePath(),
|
|
65
|
+
ctx: this.ctx && this.ctx.currentTest ? { currentTest: {
|
|
66
|
+
title: this.ctx.currentTest.title,
|
|
67
|
+
[MOCHA_ID_PROP_NAME]: this.ctx.currentTest.id
|
|
68
|
+
} } : {},
|
|
69
|
+
duration: this.duration,
|
|
70
|
+
file: this.file,
|
|
71
|
+
parent: {
|
|
72
|
+
$$fullTitle: this.parent.fullTitle(),
|
|
73
|
+
[MOCHA_ID_PROP_NAME]: this.parent.id
|
|
74
|
+
},
|
|
75
|
+
state: this.state,
|
|
76
|
+
title: this.title,
|
|
77
|
+
type: this.type,
|
|
78
|
+
[MOCHA_ID_PROP_NAME]: this.id
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
}) });
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
84
|
+
export default require_hook();
|
|
85
|
+
|
|
86
|
+
export { require_hook };
|