@eggjs/mock 6.1.0-beta.8 → 7.0.0-beta.13
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/context.js +1 -3
- package/package.json +9 -11
- 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,72 +0,0 @@
|
|
|
1
|
-
import { __commonJS } from "../../../../../../_virtual/rolldown_runtime.js";
|
|
2
|
-
import { require_runner } from "./runner.js";
|
|
3
|
-
|
|
4
|
-
//#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/stats-collector.js
|
|
5
|
-
var require_stats_collector = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/stats-collector.js": ((exports, module) => {
|
|
6
|
-
/**
|
|
7
|
-
* @typedef {import('./types.d.ts').StatsCollector} StatsCollector
|
|
8
|
-
* @typedef {import('./runner.js')} Runner
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Provides a factory function for a {@link StatsCollector} object.
|
|
12
|
-
* @module
|
|
13
|
-
*/
|
|
14
|
-
var constants = require_runner().constants;
|
|
15
|
-
var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
|
|
16
|
-
var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
|
|
17
|
-
var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
|
|
18
|
-
var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
|
|
19
|
-
var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
|
|
20
|
-
var EVENT_RUN_END = constants.EVENT_RUN_END;
|
|
21
|
-
var EVENT_TEST_END = constants.EVENT_TEST_END;
|
|
22
|
-
var Date = global.Date;
|
|
23
|
-
/**
|
|
24
|
-
* Provides stats such as test duration, number of tests passed / failed etc., by listening for events emitted by `runner`.
|
|
25
|
-
*
|
|
26
|
-
* @private
|
|
27
|
-
* @param {Runner} runner - Runner instance
|
|
28
|
-
* @throws {TypeError} If falsy `runner`
|
|
29
|
-
*/
|
|
30
|
-
function createStatsCollector(runner) {
|
|
31
|
-
/**
|
|
32
|
-
* @type {StatsCollector}
|
|
33
|
-
*/
|
|
34
|
-
var stats = {
|
|
35
|
-
suites: 0,
|
|
36
|
-
tests: 0,
|
|
37
|
-
passes: 0,
|
|
38
|
-
pending: 0,
|
|
39
|
-
failures: 0
|
|
40
|
-
};
|
|
41
|
-
if (!runner) throw new TypeError("Missing runner argument");
|
|
42
|
-
runner.stats = stats;
|
|
43
|
-
runner.once(EVENT_RUN_BEGIN, function() {
|
|
44
|
-
stats.start = new Date();
|
|
45
|
-
});
|
|
46
|
-
runner.on(EVENT_SUITE_BEGIN, function(suite) {
|
|
47
|
-
suite.root || stats.suites++;
|
|
48
|
-
});
|
|
49
|
-
runner.on(EVENT_TEST_PASS, function() {
|
|
50
|
-
stats.passes++;
|
|
51
|
-
});
|
|
52
|
-
runner.on(EVENT_TEST_FAIL, function() {
|
|
53
|
-
stats.failures++;
|
|
54
|
-
});
|
|
55
|
-
runner.on(EVENT_TEST_PENDING, function() {
|
|
56
|
-
stats.pending++;
|
|
57
|
-
});
|
|
58
|
-
runner.on(EVENT_TEST_END, function() {
|
|
59
|
-
stats.tests++;
|
|
60
|
-
});
|
|
61
|
-
runner.once(EVENT_RUN_END, function() {
|
|
62
|
-
stats.end = new Date();
|
|
63
|
-
stats.duration = stats.end - stats.start;
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
module.exports = createStatsCollector;
|
|
67
|
-
}) });
|
|
68
|
-
|
|
69
|
-
//#endregion
|
|
70
|
-
export default require_stats_collector();
|
|
71
|
-
|
|
72
|
-
export { require_stats_collector };
|
|
@@ -1,517 +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_src } from "../../../../debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js";
|
|
5
|
-
import { require_errors } from "./errors.js";
|
|
6
|
-
import { require_hook } from "./hook.js";
|
|
7
|
-
|
|
8
|
-
//#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/suite.js
|
|
9
|
-
var require_suite = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/suite.js": ((exports, module) => {
|
|
10
|
-
/**
|
|
11
|
-
* @typedef {import('./test.js')} Test
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Module dependencies.
|
|
15
|
-
* @private
|
|
16
|
-
*/
|
|
17
|
-
const { EventEmitter } = __require("node:events");
|
|
18
|
-
const Hook = require_hook();
|
|
19
|
-
var { assignNewMochaID, clamp, constants: utilsConstants, defineConstants, getMochaID, inherits, isString } = require_utils();
|
|
20
|
-
const debug = require_src()("mocha:suite");
|
|
21
|
-
const milliseconds = require_ms();
|
|
22
|
-
const errors = require_errors();
|
|
23
|
-
const { MOCHA_ID_PROP_NAME } = utilsConstants;
|
|
24
|
-
/**
|
|
25
|
-
* Expose `Suite`.
|
|
26
|
-
*/
|
|
27
|
-
exports = module.exports = Suite;
|
|
28
|
-
/**
|
|
29
|
-
* Create a new `Suite` with the given `title` and parent `Suite`.
|
|
30
|
-
*
|
|
31
|
-
* @public
|
|
32
|
-
* @param {Suite} parent - Parent suite (required!)
|
|
33
|
-
* @param {string} title - Title
|
|
34
|
-
* @return {Suite}
|
|
35
|
-
*/
|
|
36
|
-
Suite.create = function(parent, title) {
|
|
37
|
-
var suite = new Suite(title, parent.ctx);
|
|
38
|
-
suite.parent = parent;
|
|
39
|
-
title = suite.fullTitle();
|
|
40
|
-
parent.addSuite(suite);
|
|
41
|
-
return suite;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Constructs a new `Suite` instance with the given `title`, `ctx`, and `isRoot`.
|
|
45
|
-
*
|
|
46
|
-
* @public
|
|
47
|
-
* @class
|
|
48
|
-
* @extends EventEmitter
|
|
49
|
-
* @see {@link https://nodejs.org/api/events.html#events_class_eventemitter|EventEmitter}
|
|
50
|
-
* @param {string} title - Suite title.
|
|
51
|
-
* @param {Context} parentContext - Parent context instance.
|
|
52
|
-
* @param {boolean} [isRoot=false] - Whether this is the root suite.
|
|
53
|
-
*/
|
|
54
|
-
function Suite(title, parentContext, isRoot) {
|
|
55
|
-
if (!isString(title)) throw errors.createInvalidArgumentTypeError("Suite argument \"title\" must be a string. Received type \"" + typeof title + "\"", "title", "string");
|
|
56
|
-
this.title = title;
|
|
57
|
-
function Context() {}
|
|
58
|
-
Context.prototype = parentContext;
|
|
59
|
-
this.ctx = new Context();
|
|
60
|
-
this.suites = [];
|
|
61
|
-
this.tests = [];
|
|
62
|
-
this.root = isRoot === true;
|
|
63
|
-
this.pending = false;
|
|
64
|
-
this._retries = -1;
|
|
65
|
-
this._beforeEach = [];
|
|
66
|
-
this._beforeAll = [];
|
|
67
|
-
this._afterEach = [];
|
|
68
|
-
this._afterAll = [];
|
|
69
|
-
this._timeout = 2e3;
|
|
70
|
-
this._slow = 75;
|
|
71
|
-
this._bail = false;
|
|
72
|
-
this._onlyTests = [];
|
|
73
|
-
this._onlySuites = [];
|
|
74
|
-
assignNewMochaID(this);
|
|
75
|
-
Object.defineProperty(this, "id", { get() {
|
|
76
|
-
return getMochaID(this);
|
|
77
|
-
} });
|
|
78
|
-
this.reset();
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Inherit from `EventEmitter.prototype`.
|
|
82
|
-
*/
|
|
83
|
-
inherits(Suite, EventEmitter);
|
|
84
|
-
/**
|
|
85
|
-
* Resets the state initially or for a next run.
|
|
86
|
-
*/
|
|
87
|
-
Suite.prototype.reset = function() {
|
|
88
|
-
this.delayed = false;
|
|
89
|
-
function doReset(thingToReset) {
|
|
90
|
-
thingToReset.reset();
|
|
91
|
-
}
|
|
92
|
-
this.suites.forEach(doReset);
|
|
93
|
-
this.tests.forEach(doReset);
|
|
94
|
-
this._beforeEach.forEach(doReset);
|
|
95
|
-
this._afterEach.forEach(doReset);
|
|
96
|
-
this._beforeAll.forEach(doReset);
|
|
97
|
-
this._afterAll.forEach(doReset);
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* Return a clone of this `Suite`.
|
|
101
|
-
*
|
|
102
|
-
* @private
|
|
103
|
-
* @return {Suite}
|
|
104
|
-
*/
|
|
105
|
-
Suite.prototype.clone = function() {
|
|
106
|
-
var suite = new Suite(this.title);
|
|
107
|
-
debug("clone");
|
|
108
|
-
suite.ctx = this.ctx;
|
|
109
|
-
suite.root = this.root;
|
|
110
|
-
suite.timeout(this.timeout());
|
|
111
|
-
suite.retries(this.retries());
|
|
112
|
-
suite.slow(this.slow());
|
|
113
|
-
suite.bail(this.bail());
|
|
114
|
-
return suite;
|
|
115
|
-
};
|
|
116
|
-
/**
|
|
117
|
-
* Set or get timeout `ms` or short-hand such as "2s".
|
|
118
|
-
*
|
|
119
|
-
* @private
|
|
120
|
-
* @todo Do not attempt to set value if `ms` is undefined
|
|
121
|
-
* @param {number|string} ms
|
|
122
|
-
* @return {Suite|number} for chaining
|
|
123
|
-
*/
|
|
124
|
-
Suite.prototype.timeout = function(ms) {
|
|
125
|
-
if (!arguments.length) return this._timeout;
|
|
126
|
-
if (typeof ms === "string") ms = milliseconds(ms);
|
|
127
|
-
var range = [0, Math.pow(2, 31) - 1];
|
|
128
|
-
ms = clamp(ms, range);
|
|
129
|
-
debug("timeout %d", ms);
|
|
130
|
-
this._timeout = parseInt(ms, 10);
|
|
131
|
-
return this;
|
|
132
|
-
};
|
|
133
|
-
/**
|
|
134
|
-
* Set or get number of times to retry a failed test.
|
|
135
|
-
*
|
|
136
|
-
* @private
|
|
137
|
-
* @param {number|string} n
|
|
138
|
-
* @return {Suite|number} for chaining
|
|
139
|
-
*/
|
|
140
|
-
Suite.prototype.retries = function(n) {
|
|
141
|
-
if (!arguments.length) return this._retries;
|
|
142
|
-
debug("retries %d", n);
|
|
143
|
-
this._retries = parseInt(n, 10) || 0;
|
|
144
|
-
return this;
|
|
145
|
-
};
|
|
146
|
-
/**
|
|
147
|
-
* Set or get slow `ms` or short-hand such as "2s".
|
|
148
|
-
*
|
|
149
|
-
* @private
|
|
150
|
-
* @param {number|string} ms
|
|
151
|
-
* @return {Suite|number} for chaining
|
|
152
|
-
*/
|
|
153
|
-
Suite.prototype.slow = function(ms) {
|
|
154
|
-
if (!arguments.length) return this._slow;
|
|
155
|
-
if (typeof ms === "string") ms = milliseconds(ms);
|
|
156
|
-
debug("slow %d", ms);
|
|
157
|
-
this._slow = ms;
|
|
158
|
-
return this;
|
|
159
|
-
};
|
|
160
|
-
/**
|
|
161
|
-
* Set or get whether to bail after first error.
|
|
162
|
-
*
|
|
163
|
-
* @private
|
|
164
|
-
* @param {boolean} bail
|
|
165
|
-
* @return {Suite|number} for chaining
|
|
166
|
-
*/
|
|
167
|
-
Suite.prototype.bail = function(bail) {
|
|
168
|
-
if (!arguments.length) return this._bail;
|
|
169
|
-
debug("bail %s", bail);
|
|
170
|
-
this._bail = bail;
|
|
171
|
-
return this;
|
|
172
|
-
};
|
|
173
|
-
/**
|
|
174
|
-
* Check if this suite or its parent suite is marked as pending.
|
|
175
|
-
*
|
|
176
|
-
* @private
|
|
177
|
-
*/
|
|
178
|
-
Suite.prototype.isPending = function() {
|
|
179
|
-
return this.pending || this.parent && this.parent.isPending();
|
|
180
|
-
};
|
|
181
|
-
/**
|
|
182
|
-
* Generic hook-creator.
|
|
183
|
-
* @private
|
|
184
|
-
* @param {string} title - Title of hook
|
|
185
|
-
* @param {Function} fn - Hook callback
|
|
186
|
-
* @returns {Hook} A new hook
|
|
187
|
-
*/
|
|
188
|
-
Suite.prototype._createHook = function(title, fn) {
|
|
189
|
-
var hook = new Hook(title, fn);
|
|
190
|
-
hook.parent = this;
|
|
191
|
-
hook.timeout(this.timeout());
|
|
192
|
-
hook.retries(this.retries());
|
|
193
|
-
hook.slow(this.slow());
|
|
194
|
-
hook.ctx = this.ctx;
|
|
195
|
-
hook.file = this.file;
|
|
196
|
-
return hook;
|
|
197
|
-
};
|
|
198
|
-
/**
|
|
199
|
-
* Run `fn(test[, done])` before running tests.
|
|
200
|
-
*
|
|
201
|
-
* @private
|
|
202
|
-
* @param {string} title
|
|
203
|
-
* @param {Function} fn
|
|
204
|
-
* @return {Suite} for chaining
|
|
205
|
-
*/
|
|
206
|
-
Suite.prototype.beforeAll = function(title, fn) {
|
|
207
|
-
if (this.isPending()) return this;
|
|
208
|
-
if (typeof title === "function") {
|
|
209
|
-
fn = title;
|
|
210
|
-
title = fn.name;
|
|
211
|
-
}
|
|
212
|
-
title = "\"before all\" hook" + (title ? ": " + title : "");
|
|
213
|
-
var hook = this._createHook(title, fn);
|
|
214
|
-
this._beforeAll.push(hook);
|
|
215
|
-
this.emit(constants.EVENT_SUITE_ADD_HOOK_BEFORE_ALL, hook);
|
|
216
|
-
return hook;
|
|
217
|
-
};
|
|
218
|
-
/**
|
|
219
|
-
* Run `fn(test[, done])` after running tests.
|
|
220
|
-
*
|
|
221
|
-
* @private
|
|
222
|
-
* @param {string} title
|
|
223
|
-
* @param {Function} fn
|
|
224
|
-
* @return {Suite} for chaining
|
|
225
|
-
*/
|
|
226
|
-
Suite.prototype.afterAll = function(title, fn) {
|
|
227
|
-
if (this.isPending()) return this;
|
|
228
|
-
if (typeof title === "function") {
|
|
229
|
-
fn = title;
|
|
230
|
-
title = fn.name;
|
|
231
|
-
}
|
|
232
|
-
title = "\"after all\" hook" + (title ? ": " + title : "");
|
|
233
|
-
var hook = this._createHook(title, fn);
|
|
234
|
-
this._afterAll.push(hook);
|
|
235
|
-
this.emit(constants.EVENT_SUITE_ADD_HOOK_AFTER_ALL, hook);
|
|
236
|
-
return hook;
|
|
237
|
-
};
|
|
238
|
-
/**
|
|
239
|
-
* Run `fn(test[, done])` before each test case.
|
|
240
|
-
*
|
|
241
|
-
* @private
|
|
242
|
-
* @param {string} title
|
|
243
|
-
* @param {Function} fn
|
|
244
|
-
* @return {Suite} for chaining
|
|
245
|
-
*/
|
|
246
|
-
Suite.prototype.beforeEach = function(title, fn) {
|
|
247
|
-
if (this.isPending()) return this;
|
|
248
|
-
if (typeof title === "function") {
|
|
249
|
-
fn = title;
|
|
250
|
-
title = fn.name;
|
|
251
|
-
}
|
|
252
|
-
title = "\"before each\" hook" + (title ? ": " + title : "");
|
|
253
|
-
var hook = this._createHook(title, fn);
|
|
254
|
-
this._beforeEach.push(hook);
|
|
255
|
-
this.emit(constants.EVENT_SUITE_ADD_HOOK_BEFORE_EACH, hook);
|
|
256
|
-
return hook;
|
|
257
|
-
};
|
|
258
|
-
/**
|
|
259
|
-
* Run `fn(test[, done])` after each test case.
|
|
260
|
-
*
|
|
261
|
-
* @private
|
|
262
|
-
* @param {string} title
|
|
263
|
-
* @param {Function} fn
|
|
264
|
-
* @return {Suite} for chaining
|
|
265
|
-
*/
|
|
266
|
-
Suite.prototype.afterEach = function(title, fn) {
|
|
267
|
-
if (this.isPending()) return this;
|
|
268
|
-
if (typeof title === "function") {
|
|
269
|
-
fn = title;
|
|
270
|
-
title = fn.name;
|
|
271
|
-
}
|
|
272
|
-
title = "\"after each\" hook" + (title ? ": " + title : "");
|
|
273
|
-
var hook = this._createHook(title, fn);
|
|
274
|
-
this._afterEach.push(hook);
|
|
275
|
-
this.emit(constants.EVENT_SUITE_ADD_HOOK_AFTER_EACH, hook);
|
|
276
|
-
return hook;
|
|
277
|
-
};
|
|
278
|
-
/**
|
|
279
|
-
* Add a test `suite`.
|
|
280
|
-
*
|
|
281
|
-
* @private
|
|
282
|
-
* @param {Suite} suite
|
|
283
|
-
* @return {Suite} for chaining
|
|
284
|
-
*/
|
|
285
|
-
Suite.prototype.addSuite = function(suite) {
|
|
286
|
-
suite.parent = this;
|
|
287
|
-
suite.root = false;
|
|
288
|
-
suite.timeout(this.timeout());
|
|
289
|
-
suite.retries(this.retries());
|
|
290
|
-
suite.slow(this.slow());
|
|
291
|
-
suite.bail(this.bail());
|
|
292
|
-
this.suites.push(suite);
|
|
293
|
-
this.emit(constants.EVENT_SUITE_ADD_SUITE, suite);
|
|
294
|
-
return this;
|
|
295
|
-
};
|
|
296
|
-
/**
|
|
297
|
-
* Add a `test` to this suite.
|
|
298
|
-
*
|
|
299
|
-
* @private
|
|
300
|
-
* @param {Test} test
|
|
301
|
-
* @return {Suite} for chaining
|
|
302
|
-
*/
|
|
303
|
-
Suite.prototype.addTest = function(test) {
|
|
304
|
-
test.parent = this;
|
|
305
|
-
test.timeout(this.timeout());
|
|
306
|
-
test.retries(this.retries());
|
|
307
|
-
test.slow(this.slow());
|
|
308
|
-
test.ctx = this.ctx;
|
|
309
|
-
this.tests.push(test);
|
|
310
|
-
this.emit(constants.EVENT_SUITE_ADD_TEST, test);
|
|
311
|
-
return this;
|
|
312
|
-
};
|
|
313
|
-
/**
|
|
314
|
-
* Return the full title generated by recursively concatenating the parent's
|
|
315
|
-
* full title.
|
|
316
|
-
*
|
|
317
|
-
* @memberof Suite
|
|
318
|
-
* @public
|
|
319
|
-
* @return {string}
|
|
320
|
-
*/
|
|
321
|
-
Suite.prototype.fullTitle = function() {
|
|
322
|
-
return this.titlePath().join(" ");
|
|
323
|
-
};
|
|
324
|
-
/**
|
|
325
|
-
* Return the title path generated by recursively concatenating the parent's
|
|
326
|
-
* title path.
|
|
327
|
-
*
|
|
328
|
-
* @memberof Suite
|
|
329
|
-
* @public
|
|
330
|
-
* @return {string[]}
|
|
331
|
-
*/
|
|
332
|
-
Suite.prototype.titlePath = function() {
|
|
333
|
-
var result = [];
|
|
334
|
-
if (this.parent) result = result.concat(this.parent.titlePath());
|
|
335
|
-
if (!this.root) result.push(this.title);
|
|
336
|
-
return result;
|
|
337
|
-
};
|
|
338
|
-
/**
|
|
339
|
-
* Return the total number of tests.
|
|
340
|
-
*
|
|
341
|
-
* @memberof Suite
|
|
342
|
-
* @public
|
|
343
|
-
* @return {number}
|
|
344
|
-
*/
|
|
345
|
-
Suite.prototype.total = function() {
|
|
346
|
-
return this.suites.reduce(function(sum, suite) {
|
|
347
|
-
return sum + suite.total();
|
|
348
|
-
}, 0) + this.tests.length;
|
|
349
|
-
};
|
|
350
|
-
/**
|
|
351
|
-
* Iterates through each suite recursively to find all tests. Applies a
|
|
352
|
-
* function in the format `fn(test)`.
|
|
353
|
-
*
|
|
354
|
-
* @private
|
|
355
|
-
* @param {Function} fn
|
|
356
|
-
* @return {Suite}
|
|
357
|
-
*/
|
|
358
|
-
Suite.prototype.eachTest = function(fn) {
|
|
359
|
-
this.tests.forEach(fn);
|
|
360
|
-
this.suites.forEach(function(suite) {
|
|
361
|
-
suite.eachTest(fn);
|
|
362
|
-
});
|
|
363
|
-
return this;
|
|
364
|
-
};
|
|
365
|
-
/**
|
|
366
|
-
* This will run the root suite if we happen to be running in delayed mode.
|
|
367
|
-
* @private
|
|
368
|
-
*/
|
|
369
|
-
Suite.prototype.run = function run() {
|
|
370
|
-
if (this.root) this.emit(constants.EVENT_ROOT_SUITE_RUN);
|
|
371
|
-
};
|
|
372
|
-
/**
|
|
373
|
-
* Determines whether a suite has an `only` test or suite as a descendant.
|
|
374
|
-
*
|
|
375
|
-
* @private
|
|
376
|
-
* @returns {Boolean}
|
|
377
|
-
*/
|
|
378
|
-
Suite.prototype.hasOnly = function hasOnly() {
|
|
379
|
-
return this._onlyTests.length > 0 || this._onlySuites.length > 0 || this.suites.some(function(suite) {
|
|
380
|
-
return suite.hasOnly();
|
|
381
|
-
});
|
|
382
|
-
};
|
|
383
|
-
/**
|
|
384
|
-
* Filter suites based on `isOnly` logic.
|
|
385
|
-
*
|
|
386
|
-
* @private
|
|
387
|
-
* @returns {Boolean}
|
|
388
|
-
*/
|
|
389
|
-
Suite.prototype.filterOnly = function filterOnly() {
|
|
390
|
-
if (this._onlyTests.length) {
|
|
391
|
-
this.tests = this._onlyTests;
|
|
392
|
-
this.suites = [];
|
|
393
|
-
} else {
|
|
394
|
-
this.tests = [];
|
|
395
|
-
this._onlySuites.forEach(function(onlySuite) {
|
|
396
|
-
if (onlySuite.hasOnly()) onlySuite.filterOnly();
|
|
397
|
-
});
|
|
398
|
-
var onlySuites = this._onlySuites;
|
|
399
|
-
this.suites = this.suites.filter(function(childSuite) {
|
|
400
|
-
return onlySuites.indexOf(childSuite) !== -1 || childSuite.filterOnly();
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
return this.tests.length > 0 || this.suites.length > 0;
|
|
404
|
-
};
|
|
405
|
-
/**
|
|
406
|
-
* Adds a suite to the list of subsuites marked `only`.
|
|
407
|
-
*
|
|
408
|
-
* @private
|
|
409
|
-
* @param {Suite} suite
|
|
410
|
-
*/
|
|
411
|
-
Suite.prototype.appendOnlySuite = function(suite) {
|
|
412
|
-
this._onlySuites.push(suite);
|
|
413
|
-
};
|
|
414
|
-
/**
|
|
415
|
-
* Marks a suite to be `only`.
|
|
416
|
-
*
|
|
417
|
-
* @private
|
|
418
|
-
*/
|
|
419
|
-
Suite.prototype.markOnly = function() {
|
|
420
|
-
this.parent && this.parent.appendOnlySuite(this);
|
|
421
|
-
};
|
|
422
|
-
/**
|
|
423
|
-
* Adds a test to the list of tests marked `only`.
|
|
424
|
-
*
|
|
425
|
-
* @private
|
|
426
|
-
* @param {Test} test
|
|
427
|
-
*/
|
|
428
|
-
Suite.prototype.appendOnlyTest = function(test) {
|
|
429
|
-
this._onlyTests.push(test);
|
|
430
|
-
};
|
|
431
|
-
/**
|
|
432
|
-
* Returns the array of hooks by hook name; see `HOOK_TYPE_*` constants.
|
|
433
|
-
* @private
|
|
434
|
-
*/
|
|
435
|
-
Suite.prototype.getHooks = function getHooks(name) {
|
|
436
|
-
return this["_" + name];
|
|
437
|
-
};
|
|
438
|
-
/**
|
|
439
|
-
* cleans all references from this suite and all child suites.
|
|
440
|
-
*/
|
|
441
|
-
Suite.prototype.dispose = function() {
|
|
442
|
-
this.suites.forEach(function(suite) {
|
|
443
|
-
suite.dispose();
|
|
444
|
-
});
|
|
445
|
-
this.cleanReferences();
|
|
446
|
-
};
|
|
447
|
-
/**
|
|
448
|
-
* Cleans up the references to all the deferred functions
|
|
449
|
-
* (before/after/beforeEach/afterEach) and tests of a Suite.
|
|
450
|
-
* These must be deleted otherwise a memory leak can happen,
|
|
451
|
-
* as those functions may reference variables from closures,
|
|
452
|
-
* thus those variables can never be garbage collected as long
|
|
453
|
-
* as the deferred functions exist.
|
|
454
|
-
*
|
|
455
|
-
* @private
|
|
456
|
-
*/
|
|
457
|
-
Suite.prototype.cleanReferences = function cleanReferences() {
|
|
458
|
-
function cleanArrReferences(arr) {
|
|
459
|
-
for (var i$1 = 0; i$1 < arr.length; i$1++) delete arr[i$1].fn;
|
|
460
|
-
}
|
|
461
|
-
if (Array.isArray(this._beforeAll)) cleanArrReferences(this._beforeAll);
|
|
462
|
-
if (Array.isArray(this._beforeEach)) cleanArrReferences(this._beforeEach);
|
|
463
|
-
if (Array.isArray(this._afterAll)) cleanArrReferences(this._afterAll);
|
|
464
|
-
if (Array.isArray(this._afterEach)) cleanArrReferences(this._afterEach);
|
|
465
|
-
for (var i = 0; i < this.tests.length; i++) delete this.tests[i].fn;
|
|
466
|
-
};
|
|
467
|
-
/**
|
|
468
|
-
* Returns an object suitable for IPC.
|
|
469
|
-
* Functions are represented by keys beginning with `$$`.
|
|
470
|
-
* @private
|
|
471
|
-
* @returns {Object}
|
|
472
|
-
*/
|
|
473
|
-
Suite.prototype.serialize = function serialize() {
|
|
474
|
-
return {
|
|
475
|
-
_bail: this._bail,
|
|
476
|
-
$$fullTitle: this.fullTitle(),
|
|
477
|
-
$$isPending: Boolean(this.isPending()),
|
|
478
|
-
root: this.root,
|
|
479
|
-
title: this.title,
|
|
480
|
-
[MOCHA_ID_PROP_NAME]: this.id,
|
|
481
|
-
parent: this.parent ? { [MOCHA_ID_PROP_NAME]: this.parent.id } : null
|
|
482
|
-
};
|
|
483
|
-
};
|
|
484
|
-
var constants = defineConstants(
|
|
485
|
-
/**
|
|
486
|
-
* {@link Suite}-related constants.
|
|
487
|
-
* @public
|
|
488
|
-
* @memberof Suite
|
|
489
|
-
* @alias constants
|
|
490
|
-
* @readonly
|
|
491
|
-
* @static
|
|
492
|
-
* @enum {string}
|
|
493
|
-
*/
|
|
494
|
-
{
|
|
495
|
-
EVENT_FILE_POST_REQUIRE: "post-require",
|
|
496
|
-
EVENT_FILE_PRE_REQUIRE: "pre-require",
|
|
497
|
-
EVENT_FILE_REQUIRE: "require",
|
|
498
|
-
EVENT_ROOT_SUITE_RUN: "run",
|
|
499
|
-
HOOK_TYPE_AFTER_ALL: "afterAll",
|
|
500
|
-
HOOK_TYPE_AFTER_EACH: "afterEach",
|
|
501
|
-
HOOK_TYPE_BEFORE_ALL: "beforeAll",
|
|
502
|
-
HOOK_TYPE_BEFORE_EACH: "beforeEach",
|
|
503
|
-
EVENT_SUITE_ADD_SUITE: "suite",
|
|
504
|
-
EVENT_SUITE_ADD_HOOK_AFTER_ALL: "afterAll",
|
|
505
|
-
EVENT_SUITE_ADD_HOOK_AFTER_EACH: "afterEach",
|
|
506
|
-
EVENT_SUITE_ADD_HOOK_BEFORE_ALL: "beforeAll",
|
|
507
|
-
EVENT_SUITE_ADD_HOOK_BEFORE_EACH: "beforeEach",
|
|
508
|
-
EVENT_SUITE_ADD_TEST: "test"
|
|
509
|
-
}
|
|
510
|
-
);
|
|
511
|
-
Suite.constants = constants;
|
|
512
|
-
}) });
|
|
513
|
-
|
|
514
|
-
//#endregion
|
|
515
|
-
export default require_suite();
|
|
516
|
-
|
|
517
|
-
export { require_suite };
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { __commonJS } 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
|
-
|
|
6
|
-
//#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/test.js
|
|
7
|
-
var require_test = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/test.js": ((exports, module) => {
|
|
8
|
-
var Runnable = require_runnable();
|
|
9
|
-
var utils = require_utils();
|
|
10
|
-
var createInvalidArgumentTypeError = require_errors().createInvalidArgumentTypeError;
|
|
11
|
-
var isString = utils.isString;
|
|
12
|
-
const { MOCHA_ID_PROP_NAME } = utils.constants;
|
|
13
|
-
module.exports = Test;
|
|
14
|
-
/**
|
|
15
|
-
* Initialize a new `Test` with the given `title` and callback `fn`.
|
|
16
|
-
*
|
|
17
|
-
* @public
|
|
18
|
-
* @class
|
|
19
|
-
* @extends Runnable
|
|
20
|
-
* @param {String} title - Test title (required)
|
|
21
|
-
* @param {Function} [fn] - Test callback. If omitted, the Test is considered "pending"
|
|
22
|
-
*/
|
|
23
|
-
function Test(title, fn) {
|
|
24
|
-
if (!isString(title)) throw createInvalidArgumentTypeError("Test argument \"title\" should be a string. Received type \"" + typeof title + "\"", "title", "string");
|
|
25
|
-
this.type = "test";
|
|
26
|
-
Runnable.call(this, title, fn);
|
|
27
|
-
this.reset();
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Inherit from `Runnable.prototype`.
|
|
31
|
-
*/
|
|
32
|
-
utils.inherits(Test, Runnable);
|
|
33
|
-
/**
|
|
34
|
-
* Resets the state initially or for a next run.
|
|
35
|
-
*/
|
|
36
|
-
Test.prototype.reset = function() {
|
|
37
|
-
Runnable.prototype.reset.call(this);
|
|
38
|
-
this.pending = !this.fn;
|
|
39
|
-
delete this.state;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Set or get retried test
|
|
43
|
-
*
|
|
44
|
-
* @private
|
|
45
|
-
*/
|
|
46
|
-
Test.prototype.retriedTest = function(n) {
|
|
47
|
-
if (!arguments.length) return this._retriedTest;
|
|
48
|
-
this._retriedTest = n;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Add test to the list of tests marked `only`.
|
|
52
|
-
*
|
|
53
|
-
* @private
|
|
54
|
-
*/
|
|
55
|
-
Test.prototype.markOnly = function() {
|
|
56
|
-
this.parent.appendOnlyTest(this);
|
|
57
|
-
};
|
|
58
|
-
Test.prototype.clone = function() {
|
|
59
|
-
var test = new Test(this.title, this.fn);
|
|
60
|
-
test.timeout(this.timeout());
|
|
61
|
-
test.slow(this.slow());
|
|
62
|
-
test.retries(this.retries());
|
|
63
|
-
test.currentRetry(this.currentRetry());
|
|
64
|
-
test.retriedTest(this.retriedTest() || this);
|
|
65
|
-
test.globals(this.globals());
|
|
66
|
-
test.parent = this.parent;
|
|
67
|
-
test.file = this.file;
|
|
68
|
-
test.ctx = this.ctx;
|
|
69
|
-
return test;
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* Returns an minimal object suitable for transmission over IPC.
|
|
73
|
-
* Functions are represented by keys beginning with `$$`.
|
|
74
|
-
* @private
|
|
75
|
-
* @returns {Object}
|
|
76
|
-
*/
|
|
77
|
-
Test.prototype.serialize = function serialize() {
|
|
78
|
-
return {
|
|
79
|
-
$$currentRetry: this._currentRetry,
|
|
80
|
-
$$fullTitle: this.fullTitle(),
|
|
81
|
-
$$isPending: Boolean(this.pending),
|
|
82
|
-
$$retriedTest: this._retriedTest || null,
|
|
83
|
-
$$slow: this._slow,
|
|
84
|
-
$$titlePath: this.titlePath(),
|
|
85
|
-
body: this.body,
|
|
86
|
-
duration: this.duration,
|
|
87
|
-
err: this.err,
|
|
88
|
-
parent: {
|
|
89
|
-
$$fullTitle: this.parent.fullTitle(),
|
|
90
|
-
[MOCHA_ID_PROP_NAME]: this.parent.id
|
|
91
|
-
},
|
|
92
|
-
speed: this.speed,
|
|
93
|
-
state: this.state,
|
|
94
|
-
title: this.title,
|
|
95
|
-
type: this.type,
|
|
96
|
-
file: this.file,
|
|
97
|
-
[MOCHA_ID_PROP_NAME]: this.id
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
}) });
|
|
101
|
-
|
|
102
|
-
//#endregion
|
|
103
|
-
export default require_test();
|
|
104
|
-
|
|
105
|
-
export { require_test };
|