@plugjs/expect5 0.4.0
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 +7 -0
- package/dist/cli.d.mts +2 -0
- package/dist/cli.mjs +96 -0
- package/dist/cli.mjs.map +6 -0
- package/dist/execution/executable.cjs +299 -0
- package/dist/execution/executable.cjs.map +6 -0
- package/dist/execution/executable.d.ts +87 -0
- package/dist/execution/executable.mjs +260 -0
- package/dist/execution/executable.mjs.map +6 -0
- package/dist/execution/executor.cjs +125 -0
- package/dist/execution/executor.cjs.map +6 -0
- package/dist/execution/executor.d.ts +35 -0
- package/dist/execution/executor.mjs +90 -0
- package/dist/execution/executor.mjs.map +6 -0
- package/dist/execution/setup.cjs +127 -0
- package/dist/execution/setup.cjs.map +6 -0
- package/dist/execution/setup.d.ts +31 -0
- package/dist/execution/setup.mjs +87 -0
- package/dist/execution/setup.mjs.map +6 -0
- package/dist/expectation/basic.cjs +216 -0
- package/dist/expectation/basic.cjs.map +6 -0
- package/dist/expectation/basic.d.ts +47 -0
- package/dist/expectation/basic.mjs +177 -0
- package/dist/expectation/basic.mjs.map +6 -0
- package/dist/expectation/diff.cjs +253 -0
- package/dist/expectation/diff.cjs.map +6 -0
- package/dist/expectation/diff.d.ts +27 -0
- package/dist/expectation/diff.mjs +228 -0
- package/dist/expectation/diff.mjs.map +6 -0
- package/dist/expectation/expect.cjs +211 -0
- package/dist/expectation/expect.cjs.map +6 -0
- package/dist/expectation/expect.d.ts +140 -0
- package/dist/expectation/expect.mjs +219 -0
- package/dist/expectation/expect.mjs.map +6 -0
- package/dist/expectation/include.cjs +187 -0
- package/dist/expectation/include.cjs.map +6 -0
- package/dist/expectation/include.d.ts +10 -0
- package/dist/expectation/include.mjs +158 -0
- package/dist/expectation/include.mjs.map +6 -0
- package/dist/expectation/print.cjs +281 -0
- package/dist/expectation/print.cjs.map +6 -0
- package/dist/expectation/print.d.ts +4 -0
- package/dist/expectation/print.mjs +256 -0
- package/dist/expectation/print.mjs.map +6 -0
- package/dist/expectation/throwing.cjs +58 -0
- package/dist/expectation/throwing.cjs.map +6 -0
- package/dist/expectation/throwing.d.ts +8 -0
- package/dist/expectation/throwing.mjs +32 -0
- package/dist/expectation/throwing.mjs.map +6 -0
- package/dist/expectation/types.cjs +212 -0
- package/dist/expectation/types.cjs.map +6 -0
- package/dist/expectation/types.d.ts +57 -0
- package/dist/expectation/types.mjs +178 -0
- package/dist/expectation/types.mjs.map +6 -0
- package/dist/expectation/void.cjs +111 -0
- package/dist/expectation/void.cjs.map +6 -0
- package/dist/expectation/void.d.ts +39 -0
- package/dist/expectation/void.mjs +77 -0
- package/dist/expectation/void.mjs.map +6 -0
- package/dist/globals.cjs +2 -0
- package/dist/globals.cjs.map +6 -0
- package/dist/globals.d.ts +23 -0
- package/dist/globals.mjs +1 -0
- package/dist/globals.mjs.map +6 -0
- package/dist/index.cjs +66 -0
- package/dist/index.cjs.map +6 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.mjs +41 -0
- package/dist/index.mjs.map +6 -0
- package/dist/test.cjs +229 -0
- package/dist/test.cjs.map +6 -0
- package/dist/test.d.ts +9 -0
- package/dist/test.mjs +194 -0
- package/dist/test.mjs.map +6 -0
- package/package.json +57 -0
- package/src/cli.mts +122 -0
- package/src/execution/executable.ts +364 -0
- package/src/execution/executor.ts +146 -0
- package/src/execution/setup.ts +108 -0
- package/src/expectation/basic.ts +209 -0
- package/src/expectation/diff.ts +445 -0
- package/src/expectation/expect.ts +401 -0
- package/src/expectation/include.ts +184 -0
- package/src/expectation/print.ts +386 -0
- package/src/expectation/throwing.ts +45 -0
- package/src/expectation/types.ts +263 -0
- package/src/expectation/void.ts +80 -0
- package/src/globals.ts +30 -0
- package/src/index.ts +54 -0
- package/src/test.ts +239 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
// execution/executable.ts
|
|
2
|
+
import assert from "node:assert";
|
|
3
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
|
+
function execute(call, timeout, notify) {
|
|
5
|
+
return new Promise((resolve) => {
|
|
6
|
+
let resolved = false;
|
|
7
|
+
const abort = new AbortController();
|
|
8
|
+
const handle = setTimeout(() => {
|
|
9
|
+
if (resolved)
|
|
10
|
+
return;
|
|
11
|
+
const error = new Error(`Timeout of ${timeout} ms reached`);
|
|
12
|
+
resolve(error);
|
|
13
|
+
notify?.(error);
|
|
14
|
+
resolved = true;
|
|
15
|
+
}, timeout).unref();
|
|
16
|
+
void Promise.resolve().then(async () => {
|
|
17
|
+
try {
|
|
18
|
+
await call.call(void 0, abort.signal);
|
|
19
|
+
resolve(void 0);
|
|
20
|
+
resolved = true;
|
|
21
|
+
} catch (cause) {
|
|
22
|
+
const error = cause instanceof Error ? cause : new Error(String(cause));
|
|
23
|
+
notify?.(error);
|
|
24
|
+
resolve(error);
|
|
25
|
+
resolved = true;
|
|
26
|
+
} finally {
|
|
27
|
+
abort.abort("Spec finished");
|
|
28
|
+
clearTimeout(handle);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
var suiteKey = Symbol.for("plugjs.expect5.async.suiteStorage");
|
|
34
|
+
var skipKey = Symbol.for("plugjs.expect5.async.skipStorage");
|
|
35
|
+
function getSuiteStorage() {
|
|
36
|
+
let storage = globalThis[suiteKey];
|
|
37
|
+
if (!storage) {
|
|
38
|
+
storage = new AsyncLocalStorage();
|
|
39
|
+
globalThis[suiteKey] = storage;
|
|
40
|
+
}
|
|
41
|
+
return storage;
|
|
42
|
+
}
|
|
43
|
+
function getSkipStorage() {
|
|
44
|
+
let storage = globalThis[skipKey];
|
|
45
|
+
if (!storage) {
|
|
46
|
+
storage = new AsyncLocalStorage();
|
|
47
|
+
globalThis[skipKey] = storage;
|
|
48
|
+
}
|
|
49
|
+
return storage;
|
|
50
|
+
}
|
|
51
|
+
var suiteStorage = getSuiteStorage();
|
|
52
|
+
var skipStorage = getSkipStorage();
|
|
53
|
+
function getCurrentSuite() {
|
|
54
|
+
const suite = suiteStorage.getStore();
|
|
55
|
+
assert(suite, "No suite found");
|
|
56
|
+
return suite;
|
|
57
|
+
}
|
|
58
|
+
function skip() {
|
|
59
|
+
const skipState = skipStorage.getStore();
|
|
60
|
+
assert(skipState, 'The "skip" function can only be used in specs or hooks');
|
|
61
|
+
skipState.skipped = true;
|
|
62
|
+
}
|
|
63
|
+
var suiteMarker = Symbol.for("plugjs:expect5:marker:Suite");
|
|
64
|
+
var Suite = class {
|
|
65
|
+
constructor(parent, name, call, timeout = 5e3, flag = void 0) {
|
|
66
|
+
this.parent = parent;
|
|
67
|
+
this.name = name;
|
|
68
|
+
this.call = call;
|
|
69
|
+
this.timeout = timeout;
|
|
70
|
+
this.flag = flag;
|
|
71
|
+
}
|
|
72
|
+
_beforeAll = [];
|
|
73
|
+
_beforeEach = [];
|
|
74
|
+
_afterAll = [];
|
|
75
|
+
_afterEach = [];
|
|
76
|
+
_suites = [];
|
|
77
|
+
_specs = [];
|
|
78
|
+
_children = [];
|
|
79
|
+
_setup = false;
|
|
80
|
+
static {
|
|
81
|
+
this.prototype[suiteMarker] = suiteMarker;
|
|
82
|
+
}
|
|
83
|
+
static [Symbol.hasInstance](instance) {
|
|
84
|
+
return instance && instance[suiteMarker] === suiteMarker;
|
|
85
|
+
}
|
|
86
|
+
get specs() {
|
|
87
|
+
return this._suites.reduce((n, s) => n + s.specs, 0) + this._specs.length;
|
|
88
|
+
}
|
|
89
|
+
/** Add a child {@link Suite} to this */
|
|
90
|
+
addSuite(suite) {
|
|
91
|
+
assert.strictEqual(suite.parent, this, "Suite is not a child of this");
|
|
92
|
+
this._children.push(suite);
|
|
93
|
+
this._suites.push(suite);
|
|
94
|
+
}
|
|
95
|
+
/** Add a {@link Spec} to this */
|
|
96
|
+
addSpec(spec) {
|
|
97
|
+
assert.strictEqual(spec.parent, this, "Spec is not a child of this");
|
|
98
|
+
this._children.push(spec);
|
|
99
|
+
this._specs.push(spec);
|
|
100
|
+
}
|
|
101
|
+
/** Add a _before all_ {@link Hook} to this */
|
|
102
|
+
addBeforeAllHook(hook) {
|
|
103
|
+
assert.strictEqual(hook.parent, this, "Hook is not a child of this");
|
|
104
|
+
assert.strictEqual(hook.name, "beforeAll", `Invalid before all hook name "${hook.name}"`);
|
|
105
|
+
this._beforeAll.push(hook);
|
|
106
|
+
}
|
|
107
|
+
/** Add a _before each_ {@link Hook} to this */
|
|
108
|
+
addBeforeEachHook(hook) {
|
|
109
|
+
assert.strictEqual(hook.parent, this, "Hook is not a child of this");
|
|
110
|
+
assert.strictEqual(hook.name, "beforeEach", `Invalid before each hook name "${hook.name}"`);
|
|
111
|
+
this._beforeEach.push(hook);
|
|
112
|
+
}
|
|
113
|
+
/** Add a _after all_ {@link Hook} to this */
|
|
114
|
+
addAfterAllHook(hook) {
|
|
115
|
+
assert.strictEqual(hook.parent, this, "Hook is not a child of this");
|
|
116
|
+
assert.strictEqual(hook.name, "afterAll", `Invalid after all hook name "${hook.name}"`);
|
|
117
|
+
this._afterAll.push(hook);
|
|
118
|
+
}
|
|
119
|
+
/** Add a _after each_ {@link Hook} to this */
|
|
120
|
+
addAfterEachHook(hook) {
|
|
121
|
+
assert.strictEqual(hook.parent, this, "Hook is not a child of this");
|
|
122
|
+
assert.strictEqual(hook.name, "afterEach", `Invalid after each hook name "${hook.name}"`);
|
|
123
|
+
this._afterEach.push(hook);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Setup this {@link Suite} invoking its main function, then initializing all
|
|
127
|
+
* children {@link Suite Suites}, and finally normalizing execution flags.
|
|
128
|
+
*/
|
|
129
|
+
async setup() {
|
|
130
|
+
if (this._setup)
|
|
131
|
+
return;
|
|
132
|
+
this._setup = true;
|
|
133
|
+
await suiteStorage.run(this, async () => {
|
|
134
|
+
const error = await execute(this.call, this.timeout);
|
|
135
|
+
if (error)
|
|
136
|
+
throw error;
|
|
137
|
+
});
|
|
138
|
+
if (this.parent) {
|
|
139
|
+
this._beforeEach.unshift(...this.parent._beforeEach.map((h) => h.clone(this)));
|
|
140
|
+
this._afterEach.push(...this.parent._afterEach.map((h) => h.clone(this)));
|
|
141
|
+
}
|
|
142
|
+
for (const suite of this._suites) {
|
|
143
|
+
await suite.setup();
|
|
144
|
+
}
|
|
145
|
+
for (const spec of this._specs) {
|
|
146
|
+
spec.before.push(...this._beforeEach.map((h) => h.clone(spec)));
|
|
147
|
+
spec.after.push(...this._afterEach.map((h) => h.clone(spec)));
|
|
148
|
+
}
|
|
149
|
+
const only = this._children.reduce((o, c) => o || c.flag === "only", false);
|
|
150
|
+
if (only) {
|
|
151
|
+
this._children.forEach((c) => c.flag !== "only" && (c.flag = "skip"));
|
|
152
|
+
this.flag = "only";
|
|
153
|
+
}
|
|
154
|
+
if (this.flag === "only") {
|
|
155
|
+
this._children.forEach((c) => c.flag !== "skip" && (c.flag = "only"));
|
|
156
|
+
}
|
|
157
|
+
for (const child of this._children) {
|
|
158
|
+
if (child.flag !== "skip")
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
this.flag = "skip";
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Execute this suite, executing all {@link Hook hooks} and children
|
|
165
|
+
* {@link Spec specs} and {@link Suite suites}
|
|
166
|
+
*/
|
|
167
|
+
async execute(executor, skip2 = false) {
|
|
168
|
+
const { done } = executor.start(this);
|
|
169
|
+
if (skip2 || this.flag === "skip") {
|
|
170
|
+
for (const child of this._children)
|
|
171
|
+
await child.execute(executor, true);
|
|
172
|
+
return done();
|
|
173
|
+
}
|
|
174
|
+
for (const hook of this._beforeAll) {
|
|
175
|
+
const failed = await hook.execute(executor);
|
|
176
|
+
if (failed) {
|
|
177
|
+
for (const child of this._children)
|
|
178
|
+
await child.execute(executor, true);
|
|
179
|
+
return done();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
for (const child of this._children)
|
|
183
|
+
await child.execute(executor);
|
|
184
|
+
for (const hook of this._afterAll)
|
|
185
|
+
await hook.execute(executor);
|
|
186
|
+
done();
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
var specMarker = Symbol.for("plugjs:expect5:marker:Spec");
|
|
190
|
+
var Spec = class {
|
|
191
|
+
constructor(parent, name, call, timeout = 5e3, flag = void 0) {
|
|
192
|
+
this.parent = parent;
|
|
193
|
+
this.name = name;
|
|
194
|
+
this.call = call;
|
|
195
|
+
this.timeout = timeout;
|
|
196
|
+
this.flag = flag;
|
|
197
|
+
}
|
|
198
|
+
before = [];
|
|
199
|
+
after = [];
|
|
200
|
+
static {
|
|
201
|
+
this.prototype[specMarker] = specMarker;
|
|
202
|
+
}
|
|
203
|
+
static [Symbol.hasInstance](instance) {
|
|
204
|
+
return instance && instance[specMarker] === specMarker;
|
|
205
|
+
}
|
|
206
|
+
/** Execute this spec */
|
|
207
|
+
async execute(executor, skip2 = false) {
|
|
208
|
+
const { done, notify } = executor.start(this);
|
|
209
|
+
if (skip2 || this.flag == "skip")
|
|
210
|
+
return done(true);
|
|
211
|
+
for (const hook of this.before) {
|
|
212
|
+
const failed = await hook.execute(executor);
|
|
213
|
+
if (failed)
|
|
214
|
+
return done(true);
|
|
215
|
+
}
|
|
216
|
+
const skipState = { skipped: false };
|
|
217
|
+
await skipStorage.run(skipState, () => execute(this.call, this.timeout, notify));
|
|
218
|
+
for (const hook of this.after)
|
|
219
|
+
await hook.execute(executor);
|
|
220
|
+
return done(skipState.skipped);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
var hookMarker = Symbol.for("plugjs:expect5:marker:Hook");
|
|
224
|
+
var Hook = class {
|
|
225
|
+
constructor(parent, name, call, timeout = 5e3, flag = void 0) {
|
|
226
|
+
this.parent = parent;
|
|
227
|
+
this.name = name;
|
|
228
|
+
this.call = call;
|
|
229
|
+
this.timeout = timeout;
|
|
230
|
+
this.flag = flag;
|
|
231
|
+
}
|
|
232
|
+
static {
|
|
233
|
+
this.prototype[hookMarker] = hookMarker;
|
|
234
|
+
}
|
|
235
|
+
static [Symbol.hasInstance](instance) {
|
|
236
|
+
return instance && instance[hookMarker] === hookMarker;
|
|
237
|
+
}
|
|
238
|
+
/** Execute this hook */
|
|
239
|
+
async execute(executor) {
|
|
240
|
+
if (this.flag === "skip")
|
|
241
|
+
return false;
|
|
242
|
+
const { done, notify } = executor.start(this);
|
|
243
|
+
const skipState = { skipped: false };
|
|
244
|
+
const error = await skipStorage.run(skipState, () => execute(this.call, this.timeout, notify));
|
|
245
|
+
done(skipState.skipped);
|
|
246
|
+
return !!error;
|
|
247
|
+
}
|
|
248
|
+
/** Clone this associating it with a new {@link Suite} or {@link Spec} */
|
|
249
|
+
clone(parent) {
|
|
250
|
+
return new Hook(parent, this.name, this.call, this.timeout, this.flag);
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
export {
|
|
254
|
+
Hook,
|
|
255
|
+
Spec,
|
|
256
|
+
Suite,
|
|
257
|
+
getCurrentSuite,
|
|
258
|
+
skip
|
|
259
|
+
};
|
|
260
|
+
//# sourceMappingURL=executable.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/execution/executable.ts"],
|
|
4
|
+
"mappings": ";AAAA,OAAO,YAAY;AACnB,SAAS,yBAAyB;AAuBlC,SAAS,QACL,MACA,SACA,QAC0B;AAC5B,SAAO,IAAI,QAA2B,CAAC,YAAY;AACjD,QAAI,WAAW;AAGf,UAAM,QAAQ,IAAI,gBAAgB;AAClC,UAAM,SAAS,WAAW,MAAM;AAE9B,UAAI;AAAU;AAEd,YAAM,QAAQ,IAAI,MAAM,cAAc,oBAAoB;AAC1D,cAAQ,KAAK;AACb,eAAS,KAAK;AACd,iBAAW;AAAA,IACb,GAAG,OAAO,EAAE,MAAM;AAGlB,SAAK,QAAQ,QAAQ,EAAE,KAAK,YAAY;AACtC,UAAI;AACF,cAAM,KAAK,KAAK,QAAW,MAAM,MAAM;AACvC,gBAAQ,MAAS;AACjB,m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|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// execution/executor.ts
|
|
31
|
+
var executor_exports = {};
|
|
32
|
+
__export(executor_exports, {
|
|
33
|
+
runSuite: () => runSuite
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(executor_exports);
|
|
36
|
+
var import_node_assert = __toESM(require("node:assert"), 1);
|
|
37
|
+
var import_node_events = require("node:events");
|
|
38
|
+
var import_executable = require("./executable.cjs");
|
|
39
|
+
function runSuite(suite) {
|
|
40
|
+
const _emitter = new import_node_events.EventEmitter();
|
|
41
|
+
let resolve;
|
|
42
|
+
let reject;
|
|
43
|
+
const promise = new Promise((_resolve, _reject) => {
|
|
44
|
+
resolve = _resolve;
|
|
45
|
+
reject = _reject;
|
|
46
|
+
});
|
|
47
|
+
const result = {
|
|
48
|
+
time: 0,
|
|
49
|
+
passed: 0,
|
|
50
|
+
failed: 0,
|
|
51
|
+
skipped: 0,
|
|
52
|
+
failures: []
|
|
53
|
+
};
|
|
54
|
+
const execution = {
|
|
55
|
+
result: promise,
|
|
56
|
+
on: (event, listener) => {
|
|
57
|
+
_emitter.on(event, listener);
|
|
58
|
+
return execution;
|
|
59
|
+
},
|
|
60
|
+
off: (event, listener) => {
|
|
61
|
+
_emitter.off(event, listener);
|
|
62
|
+
return execution;
|
|
63
|
+
},
|
|
64
|
+
once: (event, listener) => {
|
|
65
|
+
_emitter.once(event, listener);
|
|
66
|
+
return execution;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const start = (executable) => {
|
|
70
|
+
const type = executable instanceof import_executable.Suite ? "suite" : executable instanceof import_executable.Spec ? "spec" : executable instanceof import_executable.Hook ? "hook" : (
|
|
71
|
+
/* coverage ignore next */
|
|
72
|
+
import_node_assert.default.fail(`Unable to start ${Object.getPrototypeOf(executable)?.constructor?.name}`)
|
|
73
|
+
);
|
|
74
|
+
const now = Date.now();
|
|
75
|
+
_emitter.emit(`${type}:start`, executable);
|
|
76
|
+
let done = false;
|
|
77
|
+
let failure;
|
|
78
|
+
return {
|
|
79
|
+
done(skipped = false) {
|
|
80
|
+
const time = Date.now() - now;
|
|
81
|
+
done = true;
|
|
82
|
+
if (type === "suite") {
|
|
83
|
+
_emitter.emit(`${type}:done`, executable, time);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (failure) {
|
|
87
|
+
_emitter.emit(`${type}:fail`, executable, time, failure);
|
|
88
|
+
if (type === "spec")
|
|
89
|
+
result.failed++;
|
|
90
|
+
} else if (skipped) {
|
|
91
|
+
_emitter.emit(`${type}:skip`, executable, time);
|
|
92
|
+
if (type === "spec")
|
|
93
|
+
result.skipped++;
|
|
94
|
+
} else {
|
|
95
|
+
_emitter.emit(`${type}:pass`, executable, time);
|
|
96
|
+
if (type === "spec")
|
|
97
|
+
result.passed++;
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
notify(error) {
|
|
101
|
+
const number = result.failures.length + 1;
|
|
102
|
+
const fail = { error, number, source: executable, type };
|
|
103
|
+
result.failures.push(fail);
|
|
104
|
+
if (failure || done) {
|
|
105
|
+
_emitter.emit(`${type}:error`, executable, fail);
|
|
106
|
+
} else {
|
|
107
|
+
failure = fail;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
setImmediate(() => Promise.resolve().then(async () => {
|
|
113
|
+
const now = Date.now();
|
|
114
|
+
await suite.setup();
|
|
115
|
+
await suite.execute({ start });
|
|
116
|
+
result.time = Date.now() - now;
|
|
117
|
+
resolve(result);
|
|
118
|
+
}).catch((error) => reject(error)));
|
|
119
|
+
return execution;
|
|
120
|
+
}
|
|
121
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
122
|
+
0 && (module.exports = {
|
|
123
|
+
runSuite
|
|
124
|
+
});
|
|
125
|
+
//# sourceMappingURL=executor.cjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/execution/executor.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAmB;AACnB,yBAA6B;AAE7B,wBAAkC;AA+C3B,SAAS,SAAS,OAAyB;AAChD,QAAM,WAAW,IAAI,gCAAa;AAElC,MAAI;AACJ,MAAI;AACJ,QAAM,UAAU,IAAI,QAAyB,CAAC,UAAU,YAAY;AAClE,cAAU;AACV,aA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AQ,mBAAO;AAAA,QAC9B;AAAA,MACF;AAAA,MACA,OAAO,OAAoB;AACzB,cAAM,SAAS,OAAO,SAAS,SAAS;AACxC,cAAM,OAAO,EAAE,OAAO,QAAQ,QAAQ,YAAY,KAAK;AACvD,eAAO,SAAS,KAAK,IAAI;AAGzB,YAAI,WAAW,MAAM;AACnB,mBAAS,KAAK,GAAG,cAAc,YAAY,IAAI;AAAA,QACjD,OAAO;AACL,oBAAU;AAAA,QACZ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,eAAa,MAAM,QAAQ,QAAQ,EAAE,KAAK,YAAY;AACpD,UAAM,MAAM,KAAK,IAAI;AACrB,UAAM,MAAM,MAAM;AAClB,UAAM,MAAM,QAAQ,EAAE,MAAM,CAAC;AAE7B,WAAO,OAAO,KAAK,IAAI,IAAI;AAE3B,YAAQ,MAAM;AAAA,EAChB,CAAC,EAAE,MAAM,CAAC,UAAU,OAAO,KAAK,CAAC,CAAC;AAElC,SAAO;AACT;",
|
|
5
|
+
"names": ["assert"]
|
|
6
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Spec, Suite, Hook } from './executable';
|
|
2
|
+
export interface ExecutionFailure {
|
|
3
|
+
number: number;
|
|
4
|
+
error: Error;
|
|
5
|
+
source: Suite | Spec | Hook;
|
|
6
|
+
type: 'suite' | 'spec' | 'hook';
|
|
7
|
+
}
|
|
8
|
+
export interface ExecutionEvents {
|
|
9
|
+
'suite:start': (suite: Suite) => void;
|
|
10
|
+
'suite:done': (suite: Suite, time: number) => void;
|
|
11
|
+
'spec:start': (spec: Spec) => void;
|
|
12
|
+
'spec:error': (spec: Spec, failure: ExecutionFailure) => void;
|
|
13
|
+
'spec:skip': (spec: Spec, time: number) => void;
|
|
14
|
+
'spec:pass': (spec: Spec, time: number) => void;
|
|
15
|
+
'spec:fail': (spec: Spec, time: number, failure: ExecutionFailure) => void;
|
|
16
|
+
'hook:start': (hook: Hook) => void;
|
|
17
|
+
'hook:error': (hook: Hook, failure: ExecutionFailure) => void;
|
|
18
|
+
'hook:skip': (hook: Hook, time: number) => void;
|
|
19
|
+
'hook:pass': (hook: Hook, time: number) => void;
|
|
20
|
+
'hook:fail': (hook: Hook, time: number, failure: ExecutionFailure) => void;
|
|
21
|
+
}
|
|
22
|
+
export interface Execution {
|
|
23
|
+
on<E extends keyof ExecutionEvents>(event: E, listener: ExecutionEvents[E]): this;
|
|
24
|
+
off<E extends keyof ExecutionEvents>(event: E, listener: ExecutionEvents[E]): this;
|
|
25
|
+
once<E extends keyof ExecutionEvents>(event: E, listener: ExecutionEvents[E]): this;
|
|
26
|
+
result: Promise<ExecutionResult>;
|
|
27
|
+
}
|
|
28
|
+
export interface ExecutionResult {
|
|
29
|
+
passed: number;
|
|
30
|
+
failed: number;
|
|
31
|
+
skipped: number;
|
|
32
|
+
time: number;
|
|
33
|
+
failures: ExecutionFailure[];
|
|
34
|
+
}
|
|
35
|
+
export declare function runSuite(suite: Suite): Execution;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// execution/executor.ts
|
|
2
|
+
import assert from "node:assert";
|
|
3
|
+
import { EventEmitter } from "node:events";
|
|
4
|
+
import { Spec, Suite, Hook } from "./executable.mjs";
|
|
5
|
+
function runSuite(suite) {
|
|
6
|
+
const _emitter = new EventEmitter();
|
|
7
|
+
let resolve;
|
|
8
|
+
let reject;
|
|
9
|
+
const promise = new Promise((_resolve, _reject) => {
|
|
10
|
+
resolve = _resolve;
|
|
11
|
+
reject = _reject;
|
|
12
|
+
});
|
|
13
|
+
const result = {
|
|
14
|
+
time: 0,
|
|
15
|
+
passed: 0,
|
|
16
|
+
failed: 0,
|
|
17
|
+
skipped: 0,
|
|
18
|
+
failures: []
|
|
19
|
+
};
|
|
20
|
+
const execution = {
|
|
21
|
+
result: promise,
|
|
22
|
+
on: (event, listener) => {
|
|
23
|
+
_emitter.on(event, listener);
|
|
24
|
+
return execution;
|
|
25
|
+
},
|
|
26
|
+
off: (event, listener) => {
|
|
27
|
+
_emitter.off(event, listener);
|
|
28
|
+
return execution;
|
|
29
|
+
},
|
|
30
|
+
once: (event, listener) => {
|
|
31
|
+
_emitter.once(event, listener);
|
|
32
|
+
return execution;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const start = (executable) => {
|
|
36
|
+
const type = executable instanceof Suite ? "suite" : executable instanceof Spec ? "spec" : executable instanceof Hook ? "hook" : (
|
|
37
|
+
/* coverage ignore next */
|
|
38
|
+
assert.fail(`Unable to start ${Object.getPrototypeOf(executable)?.constructor?.name}`)
|
|
39
|
+
);
|
|
40
|
+
const now = Date.now();
|
|
41
|
+
_emitter.emit(`${type}:start`, executable);
|
|
42
|
+
let done = false;
|
|
43
|
+
let failure;
|
|
44
|
+
return {
|
|
45
|
+
done(skipped = false) {
|
|
46
|
+
const time = Date.now() - now;
|
|
47
|
+
done = true;
|
|
48
|
+
if (type === "suite") {
|
|
49
|
+
_emitter.emit(`${type}:done`, executable, time);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (failure) {
|
|
53
|
+
_emitter.emit(`${type}:fail`, executable, time, failure);
|
|
54
|
+
if (type === "spec")
|
|
55
|
+
result.failed++;
|
|
56
|
+
} else if (skipped) {
|
|
57
|
+
_emitter.emit(`${type}:skip`, executable, time);
|
|
58
|
+
if (type === "spec")
|
|
59
|
+
result.skipped++;
|
|
60
|
+
} else {
|
|
61
|
+
_emitter.emit(`${type}:pass`, executable, time);
|
|
62
|
+
if (type === "spec")
|
|
63
|
+
result.passed++;
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
notify(error) {
|
|
67
|
+
const number = result.failures.length + 1;
|
|
68
|
+
const fail = { error, number, source: executable, type };
|
|
69
|
+
result.failures.push(fail);
|
|
70
|
+
if (failure || done) {
|
|
71
|
+
_emitter.emit(`${type}:error`, executable, fail);
|
|
72
|
+
} else {
|
|
73
|
+
failure = fail;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
setImmediate(() => Promise.resolve().then(async () => {
|
|
79
|
+
const now = Date.now();
|
|
80
|
+
await suite.setup();
|
|
81
|
+
await suite.execute({ start });
|
|
82
|
+
result.time = Date.now() - now;
|
|
83
|
+
resolve(result);
|
|
84
|
+
}).catch((error) => reject(error)));
|
|
85
|
+
return execution;
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
runSuite
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=executor.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/execution/executor.ts"],
|
|
4
|
+
"mappings": ";AAAA,OAAO,YAAY;AACnB,SAAS,oBAAoB;AAE7B,SAAS,MAAM,OAAO,YAAY;AA+C3B,SAAS,SAAS,OAAyB;AAChD,QAAM,WAAW,IAAI,aAAa;AAElC,MAAI;AACJ,MAAI;AACJ,QAAM,UAAU,IAAI,QAAyB,CAAC,UAAU,YAAY;AAClE,cAAU;AACV,aAAS;AAAA,EACX,CAAC;AAED,QAAM,SAA0B;AAAA,IAC9B,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,UAAU,CAAC;AAAA,EACb;AAEA,QAAM,YAAuB;AAAA,IAC3B,QAAQ;AAAA,IACR,IAAI,CAAC,OAAe,aAAkD;AACpE,eAAS,GAAG,OAAO,QAAQ;AAC3B,aAAO;AAAA,IACT;AAAA,IACA,KAAK,CAAC,OAAe,aAAkD;AACrE,eAAS,IAAI,OAAO,QAAQ;AAC5B,aAAO;AAAA,IACT;AAAA,IACA,MAAM,CAAC,OAAe,aAAkD;AACtE,eAAS,KAAK,OAAO,QAAQ;AAC7B,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,QAAQ,CAAC,eAAmE;AAChF,UAAM,OACJ,sBAAsB,QAAQ,UAC9B,sBAAsB,OAAO,SAC7B,sBAAsB,OAAO;A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CAAC;AAElC,SAAO;AACT;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// execution/setup.ts
|
|
21
|
+
var setup_exports = {};
|
|
22
|
+
__export(setup_exports, {
|
|
23
|
+
after: () => after,
|
|
24
|
+
afterAll: () => afterAll,
|
|
25
|
+
afterEach: () => afterEach,
|
|
26
|
+
before: () => before,
|
|
27
|
+
beforeAll: () => beforeAll,
|
|
28
|
+
beforeEach: () => beforeEach,
|
|
29
|
+
describe: () => describe,
|
|
30
|
+
fdescribe: () => fdescribe,
|
|
31
|
+
fit: () => fit,
|
|
32
|
+
it: () => it,
|
|
33
|
+
xafterAll: () => xafterAll,
|
|
34
|
+
xafterEach: () => xafterEach,
|
|
35
|
+
xbeforeAll: () => xbeforeAll,
|
|
36
|
+
xbeforeEach: () => xbeforeEach,
|
|
37
|
+
xdescribe: () => xdescribe,
|
|
38
|
+
xit: () => xit
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(setup_exports);
|
|
41
|
+
var import_executable = require("./executable.cjs");
|
|
42
|
+
var describe = (name, call, timeout) => {
|
|
43
|
+
const parent = (0, import_executable.getCurrentSuite)();
|
|
44
|
+
parent.addSuite(new import_executable.Suite(parent, name, call, timeout));
|
|
45
|
+
};
|
|
46
|
+
var fdescribe = (name, call, timeout) => {
|
|
47
|
+
const parent = (0, import_executable.getCurrentSuite)();
|
|
48
|
+
parent.addSuite(new import_executable.Suite(parent, name, call, timeout, "only"));
|
|
49
|
+
};
|
|
50
|
+
var xdescribe = (name, call, timeout) => {
|
|
51
|
+
const parent = (0, import_executable.getCurrentSuite)();
|
|
52
|
+
parent.addSuite(new import_executable.Suite(parent, name, call, timeout, "skip"));
|
|
53
|
+
};
|
|
54
|
+
describe.skip = xdescribe;
|
|
55
|
+
describe.only = fdescribe;
|
|
56
|
+
var it = (name, call, timeout) => {
|
|
57
|
+
const parent = (0, import_executable.getCurrentSuite)();
|
|
58
|
+
parent.addSpec(new import_executable.Spec(parent, name, call, timeout));
|
|
59
|
+
};
|
|
60
|
+
var fit = (name, call, timeout) => {
|
|
61
|
+
const parent = (0, import_executable.getCurrentSuite)();
|
|
62
|
+
parent.addSpec(new import_executable.Spec(parent, name, call, timeout, "only"));
|
|
63
|
+
};
|
|
64
|
+
var xit = (name, call, timeout) => {
|
|
65
|
+
const parent = (0, import_executable.getCurrentSuite)();
|
|
66
|
+
parent.addSpec(new import_executable.Spec(parent, name, call, timeout, "skip"));
|
|
67
|
+
};
|
|
68
|
+
it.skip = xit;
|
|
69
|
+
it.only = fit;
|
|
70
|
+
var beforeAll = (call, timeout) => {
|
|
71
|
+
const parent = (0, import_executable.getCurrentSuite)();
|
|
72
|
+
parent.addBeforeAllHook(new import_executable.Hook(parent, "beforeAll", call, timeout));
|
|
73
|
+
};
|
|
74
|
+
var xbeforeAll = (call, timeout) => {
|
|
75
|
+
const parent = (0, import_executable.getCurrentSuite)();
|
|
76
|
+
parent.addBeforeAllHook(new import_executable.Hook(parent, "beforeAll", call, timeout, "skip"));
|
|
77
|
+
};
|
|
78
|
+
var beforeEach = (call, timeout) => {
|
|
79
|
+
const parent = (0, import_executable.getCurrentSuite)();
|
|
80
|
+
parent.addBeforeEachHook(new import_executable.Hook(parent, "beforeEach", call, timeout));
|
|
81
|
+
};
|
|
82
|
+
var xbeforeEach = (call, timeout) => {
|
|
83
|
+
const parent = (0, import_executable.getCurrentSuite)();
|
|
84
|
+
parent.addBeforeEachHook(new import_executable.Hook(parent, "beforeEach", call, timeout, "skip"));
|
|
85
|
+
};
|
|
86
|
+
var afterAll = (call, timeout) => {
|
|
87
|
+
const parent = (0, import_executable.getCurrentSuite)();
|
|
88
|
+
parent.addAfterAllHook(new import_executable.Hook(parent, "afterAll", call, timeout));
|
|
89
|
+
};
|
|
90
|
+
var xafterAll = (call, timeout) => {
|
|
91
|
+
const parent = (0, import_executable.getCurrentSuite)();
|
|
92
|
+
parent.addAfterAllHook(new import_executable.Hook(parent, "afterAll", call, timeout, "skip"));
|
|
93
|
+
};
|
|
94
|
+
var afterEach = (call, timeout) => {
|
|
95
|
+
const parent = (0, import_executable.getCurrentSuite)();
|
|
96
|
+
parent.addAfterEachHook(new import_executable.Hook(parent, "afterEach", call, timeout));
|
|
97
|
+
};
|
|
98
|
+
var xafterEach = (call, timeout) => {
|
|
99
|
+
const parent = (0, import_executable.getCurrentSuite)();
|
|
100
|
+
parent.addAfterEachHook(new import_executable.Hook(parent, "afterEach", call, timeout, "skip"));
|
|
101
|
+
};
|
|
102
|
+
beforeAll.skip = xbeforeAll;
|
|
103
|
+
beforeEach.skip = xbeforeEach;
|
|
104
|
+
afterAll.skip = xafterAll;
|
|
105
|
+
afterEach.skip = xafterEach;
|
|
106
|
+
var before = beforeAll;
|
|
107
|
+
var after = afterAll;
|
|
108
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
109
|
+
0 && (module.exports = {
|
|
110
|
+
after,
|
|
111
|
+
afterAll,
|
|
112
|
+
afterEach,
|
|
113
|
+
before,
|
|
114
|
+
beforeAll,
|
|
115
|
+
beforeEach,
|
|
116
|
+
describe,
|
|
117
|
+
fdescribe,
|
|
118
|
+
fit,
|
|
119
|
+
it,
|
|
120
|
+
xafterAll,
|
|
121
|
+
xafterEach,
|
|
122
|
+
xbeforeAll,
|
|
123
|
+
xbeforeEach,
|
|
124
|
+
xdescribe,
|
|
125
|
+
xit
|
|
126
|
+
});
|
|
127
|
+
//# sourceMappingURL=setup.cjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/execution/setup.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAmD;AAU5C,IAAM,WAA0B,CAAC,MAAc,MAAY,YAA2B;AAC3F,QAAM,aAAS,mCAAgB;AAC/B,SAAO,SAAS,IAAI,wBAAM,QAAQ,MAAM,MAAM,OAAO,CAAC;AACxD;AAEO,IAAM,YAAwB,CAAC,MAAc,MAAY,YAA2B;AACzF,QAAM,aAAS,mCAAgB;AAC/B,SAAO,SAAS,IAAI,wBAAM,QAAQ,MAAM,MAAM,SAAS,MAAM,CAAC;AAChE;AAEO,IAAM,YAAwB,CAAC,MAAc,MAAY,YAA2B;AACzF,QAAM,aAAS,mCAAgB;AAC/B,SAAO,SAAS,IAAI,wBAAM,QAAQ,MAAM,MAAM,SAAS,MAAM,CAAC;AAChE;AAEA,SAAS,OAAO;AAChB,SAAS,OAAO;AAUT,IAAM,KAAmB,CAAC,MAAc,MAAY,YAA2B;AACpF,QAAM,aAAS,mCAAgB;AAC/B,SAAO,QAAQ,IAAI,uBAAK,QAAQ,MAAM,MAAM,OAAO,CAAC;AACtD;AAEO,IAAM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