vitest 0.9.2 → 0.10.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/LICENSE.md +7 -0
- package/dist/{chunk-api-setup.7290422e.js → chunk-api-setup.d70fc960.js} +5 -5
- package/dist/{chunk-constants.e59013dc.js → chunk-constants.d540b1d1.js} +1 -1
- package/dist/{chunk-defaults.9aa0ce42.js → chunk-defaults.04d5d90b.js} +1 -1
- package/dist/{chunk-install-pkg.7dd40977.js → chunk-install-pkg.73b84ae1.js} +113 -115
- package/dist/chunk-integrations-globals.d2c09cd2.js +29 -0
- package/dist/chunk-integrations-spy.f036df6f.js +102 -0
- package/dist/{chunk-runtime-chain.94cf66a4.js → chunk-runtime-chain.f863f182.js} +934 -897
- package/dist/{chunk-runtime-mocker.7f4b1850.js → chunk-runtime-mocker.111ac858.js} +3 -3
- package/dist/{chunk-runtime-rpc.4b80b6bd.js → chunk-runtime-rpc.8f648236.js} +1 -1
- package/dist/{chunk-utils-global.10dcdfa6.js → chunk-utils-global.37a7c822.js} +8 -10
- package/dist/{chunk-utils-timers.4800834c.js → chunk-utils-timers.12bc05d1.js} +1404 -1057
- package/dist/{chunk-vite-node-externalize.ddf2a6fb.js → chunk-vite-node-externalize.5c678054.js} +1773 -4417
- package/dist/{chunk-vite-node-utils.7f0053fb.js → chunk-vite-node-utils.33447cc0.js} +71 -71
- package/dist/cli.js +13 -13
- package/dist/entry.js +15 -919
- package/dist/index.d.ts +92 -25
- package/dist/index.js +8 -8
- package/dist/node.d.ts +25 -7
- package/dist/node.js +12 -12
- package/dist/spy.js +2 -102
- package/dist/vendor-_commonjsHelpers.addc3445.js +3 -0
- package/dist/vendor-entry.369fd6c9.js +949 -0
- package/dist/vendor-index.405e58ef.js +6291 -0
- package/dist/{vendor-index.87b2fc14.js → vendor-index.40be925a.js} +167 -152
- package/dist/worker.js +6 -6
- package/package.json +11 -11
- package/dist/chunk-integrations-globals.c040aaa9.js +0 -23
- package/dist/vendor-_commonjsHelpers.34b404ce.js +0 -7
- package/dist/vendor-index.ee829ed6.js +0 -5707
package/dist/entry.js
CHANGED
|
@@ -1,924 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { Writable } from 'stream';
|
|
5
|
-
import { importModule } from 'local-pkg';
|
|
6
|
-
import { r as resetRunOnceCounter, i as index, R as RealDate, c as clearContext, d as defaultSuite, s as setHooks, g as getHooks, a as context, b as getSnapshotClient, e as setState, f as getFn, h as getState, v as vi } from './chunk-runtime-chain.94cf66a4.js';
|
|
7
|
-
import { r as rpc } from './chunk-runtime-rpc.4b80b6bd.js';
|
|
8
|
-
import { c as clearTimeout, s as setTimeout, d as stringify } from './chunk-utils-timers.4800834c.js';
|
|
9
|
-
import { t as takeCoverage } from './chunk-defaults.9aa0ce42.js';
|
|
10
|
-
import { createHash } from 'crypto';
|
|
11
|
-
import { format } from 'util';
|
|
12
|
-
import 'path';
|
|
1
|
+
export { r as run } from './vendor-entry.369fd6c9.js';
|
|
2
|
+
import 'fs';
|
|
3
|
+
import './chunk-utils-global.37a7c822.js';
|
|
13
4
|
import 'tty';
|
|
5
|
+
import 'local-pkg';
|
|
6
|
+
import 'path';
|
|
7
|
+
import 'console';
|
|
8
|
+
import 'stream';
|
|
9
|
+
import './chunk-runtime-chain.f863f182.js';
|
|
14
10
|
import 'chai';
|
|
15
|
-
import './vendor-_commonjsHelpers.
|
|
16
|
-
import './
|
|
11
|
+
import './vendor-_commonjsHelpers.addc3445.js';
|
|
12
|
+
import './chunk-runtime-rpc.8f648236.js';
|
|
13
|
+
import './chunk-utils-timers.12bc05d1.js';
|
|
14
|
+
import './chunk-integrations-spy.f036df6f.js';
|
|
17
15
|
import 'tinyspy';
|
|
16
|
+
import 'util';
|
|
17
|
+
import './chunk-defaults.04d5d90b.js';
|
|
18
18
|
import 'module';
|
|
19
19
|
import 'url';
|
|
20
|
-
|
|
21
|
-
var node = {
|
|
22
|
-
name: "node",
|
|
23
|
-
async setup() {
|
|
24
|
-
return {
|
|
25
|
-
teardown() {
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const LIVING_KEYS = [
|
|
32
|
-
"DOMException",
|
|
33
|
-
"URL",
|
|
34
|
-
"URLSearchParams",
|
|
35
|
-
"EventTarget",
|
|
36
|
-
"NamedNodeMap",
|
|
37
|
-
"Node",
|
|
38
|
-
"Attr",
|
|
39
|
-
"Element",
|
|
40
|
-
"DocumentFragment",
|
|
41
|
-
"DOMImplementation",
|
|
42
|
-
"Document",
|
|
43
|
-
"XMLDocument",
|
|
44
|
-
"CharacterData",
|
|
45
|
-
"Text",
|
|
46
|
-
"CDATASection",
|
|
47
|
-
"ProcessingInstruction",
|
|
48
|
-
"Comment",
|
|
49
|
-
"DocumentType",
|
|
50
|
-
"NodeList",
|
|
51
|
-
"HTMLCollection",
|
|
52
|
-
"HTMLOptionsCollection",
|
|
53
|
-
"DOMStringMap",
|
|
54
|
-
"DOMTokenList",
|
|
55
|
-
"StyleSheetList",
|
|
56
|
-
"HTMLElement",
|
|
57
|
-
"HTMLHeadElement",
|
|
58
|
-
"HTMLTitleElement",
|
|
59
|
-
"HTMLBaseElement",
|
|
60
|
-
"HTMLLinkElement",
|
|
61
|
-
"HTMLMetaElement",
|
|
62
|
-
"HTMLStyleElement",
|
|
63
|
-
"HTMLBodyElement",
|
|
64
|
-
"HTMLHeadingElement",
|
|
65
|
-
"HTMLParagraphElement",
|
|
66
|
-
"HTMLHRElement",
|
|
67
|
-
"HTMLPreElement",
|
|
68
|
-
"HTMLUListElement",
|
|
69
|
-
"HTMLOListElement",
|
|
70
|
-
"HTMLLIElement",
|
|
71
|
-
"HTMLMenuElement",
|
|
72
|
-
"HTMLDListElement",
|
|
73
|
-
"HTMLDivElement",
|
|
74
|
-
"HTMLAnchorElement",
|
|
75
|
-
"HTMLAreaElement",
|
|
76
|
-
"HTMLBRElement",
|
|
77
|
-
"HTMLButtonElement",
|
|
78
|
-
"HTMLCanvasElement",
|
|
79
|
-
"HTMLDataElement",
|
|
80
|
-
"HTMLDataListElement",
|
|
81
|
-
"HTMLDetailsElement",
|
|
82
|
-
"HTMLDialogElement",
|
|
83
|
-
"HTMLDirectoryElement",
|
|
84
|
-
"HTMLFieldSetElement",
|
|
85
|
-
"HTMLFontElement",
|
|
86
|
-
"HTMLFormElement",
|
|
87
|
-
"HTMLHtmlElement",
|
|
88
|
-
"HTMLImageElement",
|
|
89
|
-
"HTMLInputElement",
|
|
90
|
-
"HTMLLabelElement",
|
|
91
|
-
"HTMLLegendElement",
|
|
92
|
-
"HTMLMapElement",
|
|
93
|
-
"HTMLMarqueeElement",
|
|
94
|
-
"HTMLMediaElement",
|
|
95
|
-
"HTMLMeterElement",
|
|
96
|
-
"HTMLModElement",
|
|
97
|
-
"HTMLOptGroupElement",
|
|
98
|
-
"HTMLOptionElement",
|
|
99
|
-
"HTMLOutputElement",
|
|
100
|
-
"HTMLPictureElement",
|
|
101
|
-
"HTMLProgressElement",
|
|
102
|
-
"HTMLQuoteElement",
|
|
103
|
-
"HTMLScriptElement",
|
|
104
|
-
"HTMLSelectElement",
|
|
105
|
-
"HTMLSlotElement",
|
|
106
|
-
"HTMLSourceElement",
|
|
107
|
-
"HTMLSpanElement",
|
|
108
|
-
"HTMLTableCaptionElement",
|
|
109
|
-
"HTMLTableCellElement",
|
|
110
|
-
"HTMLTableColElement",
|
|
111
|
-
"HTMLTableElement",
|
|
112
|
-
"HTMLTimeElement",
|
|
113
|
-
"HTMLTableRowElement",
|
|
114
|
-
"HTMLTableSectionElement",
|
|
115
|
-
"HTMLTemplateElement",
|
|
116
|
-
"HTMLTextAreaElement",
|
|
117
|
-
"HTMLUnknownElement",
|
|
118
|
-
"HTMLFrameElement",
|
|
119
|
-
"HTMLFrameSetElement",
|
|
120
|
-
"HTMLIFrameElement",
|
|
121
|
-
"HTMLEmbedElement",
|
|
122
|
-
"HTMLObjectElement",
|
|
123
|
-
"HTMLParamElement",
|
|
124
|
-
"HTMLVideoElement",
|
|
125
|
-
"HTMLAudioElement",
|
|
126
|
-
"HTMLTrackElement",
|
|
127
|
-
"SVGElement",
|
|
128
|
-
"SVGGraphicsElement",
|
|
129
|
-
"SVGSVGElement",
|
|
130
|
-
"SVGTitleElement",
|
|
131
|
-
"SVGAnimatedString",
|
|
132
|
-
"SVGNumber",
|
|
133
|
-
"SVGStringList",
|
|
134
|
-
"Event",
|
|
135
|
-
"CloseEvent",
|
|
136
|
-
"CustomEvent",
|
|
137
|
-
"MessageEvent",
|
|
138
|
-
"ErrorEvent",
|
|
139
|
-
"HashChangeEvent",
|
|
140
|
-
"PopStateEvent",
|
|
141
|
-
"StorageEvent",
|
|
142
|
-
"ProgressEvent",
|
|
143
|
-
"PageTransitionEvent",
|
|
144
|
-
"UIEvent",
|
|
145
|
-
"FocusEvent",
|
|
146
|
-
"InputEvent",
|
|
147
|
-
"MouseEvent",
|
|
148
|
-
"KeyboardEvent",
|
|
149
|
-
"TouchEvent",
|
|
150
|
-
"CompositionEvent",
|
|
151
|
-
"WheelEvent",
|
|
152
|
-
"BarProp",
|
|
153
|
-
"External",
|
|
154
|
-
"Location",
|
|
155
|
-
"History",
|
|
156
|
-
"Screen",
|
|
157
|
-
"Performance",
|
|
158
|
-
"Navigator",
|
|
159
|
-
"PluginArray",
|
|
160
|
-
"MimeTypeArray",
|
|
161
|
-
"Plugin",
|
|
162
|
-
"MimeType",
|
|
163
|
-
"FileReader",
|
|
164
|
-
"Blob",
|
|
165
|
-
"File",
|
|
166
|
-
"FileList",
|
|
167
|
-
"ValidityState",
|
|
168
|
-
"DOMParser",
|
|
169
|
-
"XMLSerializer",
|
|
170
|
-
"FormData",
|
|
171
|
-
"XMLHttpRequestEventTarget",
|
|
172
|
-
"XMLHttpRequestUpload",
|
|
173
|
-
"XMLHttpRequest",
|
|
174
|
-
"WebSocket",
|
|
175
|
-
"NodeFilter",
|
|
176
|
-
"NodeIterator",
|
|
177
|
-
"TreeWalker",
|
|
178
|
-
"AbstractRange",
|
|
179
|
-
"Range",
|
|
180
|
-
"StaticRange",
|
|
181
|
-
"Selection",
|
|
182
|
-
"Storage",
|
|
183
|
-
"CustomElementRegistry",
|
|
184
|
-
"ShadowRoot",
|
|
185
|
-
"MutationObserver",
|
|
186
|
-
"MutationRecord",
|
|
187
|
-
"Headers",
|
|
188
|
-
"AbortController",
|
|
189
|
-
"AbortSignal",
|
|
190
|
-
"Image"
|
|
191
|
-
];
|
|
192
|
-
const OTHER_KEYS = [
|
|
193
|
-
"addEventListener",
|
|
194
|
-
"alert",
|
|
195
|
-
"atob",
|
|
196
|
-
"blur",
|
|
197
|
-
"btoa",
|
|
198
|
-
"close",
|
|
199
|
-
"confirm",
|
|
200
|
-
"createPopup",
|
|
201
|
-
"dispatchEvent",
|
|
202
|
-
"document",
|
|
203
|
-
"focus",
|
|
204
|
-
"frames",
|
|
205
|
-
"getComputedStyle",
|
|
206
|
-
"history",
|
|
207
|
-
"innerHeight",
|
|
208
|
-
"innerWidth",
|
|
209
|
-
"length",
|
|
210
|
-
"location",
|
|
211
|
-
"matchMedia",
|
|
212
|
-
"moveBy",
|
|
213
|
-
"moveTo",
|
|
214
|
-
"name",
|
|
215
|
-
"navigator",
|
|
216
|
-
"open",
|
|
217
|
-
"outerHeight",
|
|
218
|
-
"outerWidth",
|
|
219
|
-
"pageXOffset",
|
|
220
|
-
"pageYOffset",
|
|
221
|
-
"parent",
|
|
222
|
-
"postMessage",
|
|
223
|
-
"print",
|
|
224
|
-
"prompt",
|
|
225
|
-
"removeEventListener",
|
|
226
|
-
"resizeBy",
|
|
227
|
-
"resizeTo",
|
|
228
|
-
"screen",
|
|
229
|
-
"screenLeft",
|
|
230
|
-
"screenTop",
|
|
231
|
-
"screenX",
|
|
232
|
-
"screenY",
|
|
233
|
-
"scroll",
|
|
234
|
-
"scrollBy",
|
|
235
|
-
"scrollLeft",
|
|
236
|
-
"scrollTo",
|
|
237
|
-
"scrollTop",
|
|
238
|
-
"scrollX",
|
|
239
|
-
"scrollY",
|
|
240
|
-
"self",
|
|
241
|
-
"stop",
|
|
242
|
-
"top",
|
|
243
|
-
"Window",
|
|
244
|
-
"window"
|
|
245
|
-
];
|
|
246
|
-
const KEYS = LIVING_KEYS.concat(OTHER_KEYS);
|
|
247
|
-
|
|
248
|
-
const allowRewrite = /* @__PURE__ */ new Set([
|
|
249
|
-
"Event",
|
|
250
|
-
"EventTarget"
|
|
251
|
-
]);
|
|
252
|
-
function getWindowKeys(global, win) {
|
|
253
|
-
const keys = new Set(KEYS.concat(Object.getOwnPropertyNames(win)).filter((k) => {
|
|
254
|
-
if (k.startsWith("_"))
|
|
255
|
-
return false;
|
|
256
|
-
if (k in global)
|
|
257
|
-
return allowRewrite.has(k);
|
|
258
|
-
return true;
|
|
259
|
-
}));
|
|
260
|
-
return keys;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
var __defProp$1 = Object.defineProperty;
|
|
264
|
-
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
265
|
-
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
266
|
-
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
267
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
268
|
-
var __spreadValues$1 = (a, b) => {
|
|
269
|
-
for (var prop in b || (b = {}))
|
|
270
|
-
if (__hasOwnProp$1.call(b, prop))
|
|
271
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
272
|
-
if (__getOwnPropSymbols$1)
|
|
273
|
-
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
274
|
-
if (__propIsEnum$1.call(b, prop))
|
|
275
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
276
|
-
}
|
|
277
|
-
return a;
|
|
278
|
-
};
|
|
279
|
-
var __objRest = (source, exclude) => {
|
|
280
|
-
var target = {};
|
|
281
|
-
for (var prop in source)
|
|
282
|
-
if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
283
|
-
target[prop] = source[prop];
|
|
284
|
-
if (source != null && __getOwnPropSymbols$1)
|
|
285
|
-
for (var prop of __getOwnPropSymbols$1(source)) {
|
|
286
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
|
|
287
|
-
target[prop] = source[prop];
|
|
288
|
-
}
|
|
289
|
-
return target;
|
|
290
|
-
};
|
|
291
|
-
var jsdom = {
|
|
292
|
-
name: "jsdom",
|
|
293
|
-
async setup(global, { jsdom = {} }) {
|
|
294
|
-
const {
|
|
295
|
-
CookieJar,
|
|
296
|
-
JSDOM,
|
|
297
|
-
ResourceLoader,
|
|
298
|
-
VirtualConsole
|
|
299
|
-
} = await importModule("jsdom");
|
|
300
|
-
const _a = jsdom, {
|
|
301
|
-
html = "<!DOCTYPE html>",
|
|
302
|
-
userAgent,
|
|
303
|
-
url = "http://localhost:3000",
|
|
304
|
-
contentType = "text/html",
|
|
305
|
-
pretendToBeVisual = true,
|
|
306
|
-
includeNodeLocations = false,
|
|
307
|
-
runScripts = "dangerously",
|
|
308
|
-
resources,
|
|
309
|
-
console = false,
|
|
310
|
-
cookieJar = false
|
|
311
|
-
} = _a, restOptions = __objRest(_a, [
|
|
312
|
-
"html",
|
|
313
|
-
"userAgent",
|
|
314
|
-
"url",
|
|
315
|
-
"contentType",
|
|
316
|
-
"pretendToBeVisual",
|
|
317
|
-
"includeNodeLocations",
|
|
318
|
-
"runScripts",
|
|
319
|
-
"resources",
|
|
320
|
-
"console",
|
|
321
|
-
"cookieJar"
|
|
322
|
-
]);
|
|
323
|
-
const dom = new JSDOM(html, __spreadValues$1({
|
|
324
|
-
pretendToBeVisual,
|
|
325
|
-
resources: resources ?? (userAgent ? new ResourceLoader({ userAgent }) : void 0),
|
|
326
|
-
runScripts,
|
|
327
|
-
url,
|
|
328
|
-
virtualConsole: console && global.console ? new VirtualConsole().sendTo(global.console) : void 0,
|
|
329
|
-
cookieJar: cookieJar ? new CookieJar() : void 0,
|
|
330
|
-
includeNodeLocations,
|
|
331
|
-
contentType,
|
|
332
|
-
userAgent
|
|
333
|
-
}, restOptions));
|
|
334
|
-
const keys = getWindowKeys(global, dom.window);
|
|
335
|
-
const overrideObject = /* @__PURE__ */ new Map();
|
|
336
|
-
for (const key of keys) {
|
|
337
|
-
Object.defineProperty(global, key, {
|
|
338
|
-
get() {
|
|
339
|
-
if (overrideObject.has(key))
|
|
340
|
-
return overrideObject.get(key);
|
|
341
|
-
return dom.window[key];
|
|
342
|
-
},
|
|
343
|
-
set(v) {
|
|
344
|
-
overrideObject.set(key, v);
|
|
345
|
-
},
|
|
346
|
-
configurable: true
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
return {
|
|
350
|
-
teardown(global2) {
|
|
351
|
-
keys.forEach((key) => delete global2[key]);
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
var happy = {
|
|
358
|
-
name: "happy-dom",
|
|
359
|
-
async setup(global) {
|
|
360
|
-
const { Window } = await importModule("happy-dom");
|
|
361
|
-
const win = new Window();
|
|
362
|
-
const keys = getWindowKeys(global, win);
|
|
363
|
-
const overrideObject = /* @__PURE__ */ new Map();
|
|
364
|
-
for (const key of keys) {
|
|
365
|
-
Object.defineProperty(global, key, {
|
|
366
|
-
get() {
|
|
367
|
-
if (overrideObject.has(key))
|
|
368
|
-
return overrideObject.get(key);
|
|
369
|
-
return win[key];
|
|
370
|
-
},
|
|
371
|
-
set(v) {
|
|
372
|
-
overrideObject.set(key, v);
|
|
373
|
-
},
|
|
374
|
-
configurable: true
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
return {
|
|
378
|
-
teardown(global2) {
|
|
379
|
-
win.happyDOM.cancelAsync();
|
|
380
|
-
keys.forEach((key) => delete global2[key]);
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
};
|
|
385
|
-
|
|
386
|
-
const environments = {
|
|
387
|
-
node,
|
|
388
|
-
jsdom,
|
|
389
|
-
"happy-dom": happy
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
let globalSetup = false;
|
|
393
|
-
async function setupGlobalEnv(config) {
|
|
394
|
-
resetRunOnceCounter();
|
|
395
|
-
Object.defineProperty(globalThis, "__vitest_index__", {
|
|
396
|
-
value: index,
|
|
397
|
-
enumerable: false
|
|
398
|
-
});
|
|
399
|
-
setupDefines(config.defines);
|
|
400
|
-
if (globalSetup)
|
|
401
|
-
return;
|
|
402
|
-
globalSetup = true;
|
|
403
|
-
setupConsoleLogSpy();
|
|
404
|
-
if (config.globals)
|
|
405
|
-
(await import('./chunk-integrations-globals.c040aaa9.js')).registerApiGlobally();
|
|
406
|
-
}
|
|
407
|
-
function setupDefines(defines) {
|
|
408
|
-
for (const key in defines)
|
|
409
|
-
globalThis[key] = defines[key];
|
|
410
|
-
}
|
|
411
|
-
function setupConsoleLogSpy() {
|
|
412
|
-
const stdoutBuffer = /* @__PURE__ */ new Map();
|
|
413
|
-
const stderrBuffer = /* @__PURE__ */ new Map();
|
|
414
|
-
const timers = /* @__PURE__ */ new Map();
|
|
415
|
-
const unknownTestId = "__vitest__unknown_test__";
|
|
416
|
-
function schedule(taskId) {
|
|
417
|
-
const timer = timers.get(taskId);
|
|
418
|
-
const { stdoutTime, stderrTime } = timer;
|
|
419
|
-
clearTimeout(timer.timer);
|
|
420
|
-
timer.timer = setTimeout(() => {
|
|
421
|
-
if (stderrTime < stdoutTime) {
|
|
422
|
-
sendStderr(taskId);
|
|
423
|
-
sendStdout(taskId);
|
|
424
|
-
} else {
|
|
425
|
-
sendStdout(taskId);
|
|
426
|
-
sendStderr(taskId);
|
|
427
|
-
}
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
function sendStdout(taskId) {
|
|
431
|
-
const buffer = stdoutBuffer.get(taskId);
|
|
432
|
-
if (buffer) {
|
|
433
|
-
const timer = timers.get(taskId);
|
|
434
|
-
rpc().onUserConsoleLog({
|
|
435
|
-
type: "stdout",
|
|
436
|
-
content: buffer.map((i) => String(i)).join(""),
|
|
437
|
-
taskId,
|
|
438
|
-
time: timer.stdoutTime || RealDate.now(),
|
|
439
|
-
size: buffer.length
|
|
440
|
-
});
|
|
441
|
-
stdoutBuffer.set(taskId, []);
|
|
442
|
-
timer.stdoutTime = 0;
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
function sendStderr(taskId) {
|
|
446
|
-
const buffer = stderrBuffer.get(taskId);
|
|
447
|
-
if (buffer) {
|
|
448
|
-
const timer = timers.get(taskId);
|
|
449
|
-
rpc().onUserConsoleLog({
|
|
450
|
-
type: "stderr",
|
|
451
|
-
content: buffer.map((i) => String(i)).join(""),
|
|
452
|
-
taskId,
|
|
453
|
-
time: timer.stderrTime || RealDate.now(),
|
|
454
|
-
size: buffer.length
|
|
455
|
-
});
|
|
456
|
-
stderrBuffer.set(taskId, []);
|
|
457
|
-
timer.stderrTime = 0;
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
const stdout = new Writable({
|
|
461
|
-
write(data, encoding, callback) {
|
|
462
|
-
var _a, _b;
|
|
463
|
-
const id = ((_b = (_a = getWorkerState()) == null ? void 0 : _a.current) == null ? void 0 : _b.id) ?? unknownTestId;
|
|
464
|
-
let timer = timers.get(id);
|
|
465
|
-
if (timer) {
|
|
466
|
-
timer.stdoutTime = timer.stdoutTime || RealDate.now();
|
|
467
|
-
} else {
|
|
468
|
-
timer = { stdoutTime: RealDate.now(), stderrTime: RealDate.now(), timer: 0 };
|
|
469
|
-
timers.set(id, timer);
|
|
470
|
-
}
|
|
471
|
-
let buffer = stdoutBuffer.get(id);
|
|
472
|
-
if (!buffer) {
|
|
473
|
-
buffer = [];
|
|
474
|
-
stdoutBuffer.set(id, buffer);
|
|
475
|
-
}
|
|
476
|
-
buffer.push(data);
|
|
477
|
-
schedule(id);
|
|
478
|
-
callback();
|
|
479
|
-
}
|
|
480
|
-
});
|
|
481
|
-
const stderr = new Writable({
|
|
482
|
-
write(data, encoding, callback) {
|
|
483
|
-
var _a, _b;
|
|
484
|
-
const id = ((_b = (_a = getWorkerState()) == null ? void 0 : _a.current) == null ? void 0 : _b.id) ?? unknownTestId;
|
|
485
|
-
let timer = timers.get(id);
|
|
486
|
-
if (timer) {
|
|
487
|
-
timer.stderrTime = timer.stderrTime || RealDate.now();
|
|
488
|
-
} else {
|
|
489
|
-
timer = { stderrTime: RealDate.now(), stdoutTime: RealDate.now(), timer: 0 };
|
|
490
|
-
timers.set(id, timer);
|
|
491
|
-
}
|
|
492
|
-
let buffer = stderrBuffer.get(id);
|
|
493
|
-
if (!buffer) {
|
|
494
|
-
buffer = [];
|
|
495
|
-
stderrBuffer.set(id, buffer);
|
|
496
|
-
}
|
|
497
|
-
buffer.push(data);
|
|
498
|
-
schedule(id);
|
|
499
|
-
callback();
|
|
500
|
-
}
|
|
501
|
-
});
|
|
502
|
-
globalThis.console = new Console({
|
|
503
|
-
stdout,
|
|
504
|
-
stderr,
|
|
505
|
-
colorMode: true,
|
|
506
|
-
groupIndentation: 2
|
|
507
|
-
});
|
|
508
|
-
}
|
|
509
|
-
async function withEnv(name, options, fn) {
|
|
510
|
-
const env = await environments[name].setup(globalThis, options);
|
|
511
|
-
try {
|
|
512
|
-
await fn();
|
|
513
|
-
} finally {
|
|
514
|
-
await env.teardown(globalThis);
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
async function runSetupFiles(config) {
|
|
518
|
-
const files = toArray(config.setupFiles);
|
|
519
|
-
await Promise.all(files.map(async (file) => {
|
|
520
|
-
getWorkerState().moduleCache.delete(file);
|
|
521
|
-
await import(file);
|
|
522
|
-
}));
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
const OBJECT_PROTO = Object.getPrototypeOf({});
|
|
526
|
-
function serializeError(val, seen = /* @__PURE__ */ new WeakMap()) {
|
|
527
|
-
if (!val || typeof val === "string")
|
|
528
|
-
return val;
|
|
529
|
-
if (typeof val === "function")
|
|
530
|
-
return `Function<${val.name}>`;
|
|
531
|
-
if (typeof val !== "object")
|
|
532
|
-
return val;
|
|
533
|
-
if (val instanceof Promise || "then" in val || val.constructor && val.constructor.prototype === "AsyncFunction")
|
|
534
|
-
return "Promise";
|
|
535
|
-
if (typeof Element !== "undefined" && val instanceof Element)
|
|
536
|
-
return val.tagName;
|
|
537
|
-
if (typeof val.asymmetricMatch === "function")
|
|
538
|
-
return `${val.toString()} ${format(val.sample)}`;
|
|
539
|
-
if (seen.has(val))
|
|
540
|
-
return seen.get(val);
|
|
541
|
-
if (Array.isArray(val)) {
|
|
542
|
-
const clone = new Array(val.length);
|
|
543
|
-
seen.set(val, clone);
|
|
544
|
-
val.forEach((e, i) => {
|
|
545
|
-
clone[i] = serializeError(e, seen);
|
|
546
|
-
});
|
|
547
|
-
return clone;
|
|
548
|
-
} else {
|
|
549
|
-
const clone = /* @__PURE__ */ Object.create(null);
|
|
550
|
-
seen.set(val, clone);
|
|
551
|
-
let obj = val;
|
|
552
|
-
while (obj && obj !== OBJECT_PROTO) {
|
|
553
|
-
Object.getOwnPropertyNames(obj).forEach((key) => {
|
|
554
|
-
if (!(key in clone))
|
|
555
|
-
clone[key] = serializeError(obj[key], seen);
|
|
556
|
-
});
|
|
557
|
-
obj = Object.getPrototypeOf(obj);
|
|
558
|
-
}
|
|
559
|
-
return clone;
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
function processError(err) {
|
|
563
|
-
if (!err)
|
|
564
|
-
return err;
|
|
565
|
-
if (err.stack)
|
|
566
|
-
err.stackStr = String(err.stack);
|
|
567
|
-
if (err.name)
|
|
568
|
-
err.nameStr = String(err.name);
|
|
569
|
-
if (typeof err.expected !== "string")
|
|
570
|
-
err.expected = stringify(err.expected);
|
|
571
|
-
if (typeof err.actual !== "string")
|
|
572
|
-
err.actual = stringify(err.actual);
|
|
573
|
-
try {
|
|
574
|
-
return serializeError(err);
|
|
575
|
-
} catch (e) {
|
|
576
|
-
return serializeError(new Error(`Failed to fully serialize error: ${e == null ? void 0 : e.message}.
|
|
577
|
-
Inner error message: ${err == null ? void 0 : err.message}`));
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
const now$1 = Date.now;
|
|
582
|
-
function hash(str, length = 10) {
|
|
583
|
-
return createHash("md5").update(str).digest("hex").slice(0, length);
|
|
584
|
-
}
|
|
585
|
-
async function collectTests(paths, config) {
|
|
586
|
-
const files = [];
|
|
587
|
-
for (const filepath of paths) {
|
|
588
|
-
const path = relative(config.root, filepath);
|
|
589
|
-
const file = {
|
|
590
|
-
id: hash(path),
|
|
591
|
-
name: path,
|
|
592
|
-
type: "suite",
|
|
593
|
-
mode: "run",
|
|
594
|
-
filepath,
|
|
595
|
-
tasks: []
|
|
596
|
-
};
|
|
597
|
-
clearContext();
|
|
598
|
-
try {
|
|
599
|
-
await runSetupFiles(config);
|
|
600
|
-
await import(filepath);
|
|
601
|
-
const defaultTasks = await defaultSuite.collect(file);
|
|
602
|
-
setHooks(file, getHooks(defaultTasks));
|
|
603
|
-
for (const c of [...defaultTasks.tasks, ...context.tasks]) {
|
|
604
|
-
if (c.type === "test") {
|
|
605
|
-
file.tasks.push(c);
|
|
606
|
-
} else if (c.type === "suite") {
|
|
607
|
-
file.tasks.push(c);
|
|
608
|
-
} else {
|
|
609
|
-
const start = now$1();
|
|
610
|
-
const suite = await c.collect(file);
|
|
611
|
-
file.collectDuration = now$1() - start;
|
|
612
|
-
if (suite.name || suite.tasks.length)
|
|
613
|
-
file.tasks.push(suite);
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
} catch (e) {
|
|
617
|
-
file.result = {
|
|
618
|
-
state: "fail",
|
|
619
|
-
error: processError(e)
|
|
620
|
-
};
|
|
621
|
-
process.stdout.write("\0");
|
|
622
|
-
}
|
|
623
|
-
calculateHash(file);
|
|
624
|
-
const hasOnlyTasks = someTasksAreOnly(file);
|
|
625
|
-
interpretTaskModes(file, config.testNamePattern, hasOnlyTasks, false, config.allowOnly);
|
|
626
|
-
files.push(file);
|
|
627
|
-
}
|
|
628
|
-
return files;
|
|
629
|
-
}
|
|
630
|
-
function interpretTaskModes(suite, namePattern, onlyMode, parentIsOnly, allowOnly) {
|
|
631
|
-
const suiteIsOnly = parentIsOnly || suite.mode === "only";
|
|
632
|
-
suite.tasks.forEach((t) => {
|
|
633
|
-
const includeTask = suiteIsOnly || t.mode === "only";
|
|
634
|
-
if (onlyMode) {
|
|
635
|
-
if (t.type === "suite" && (includeTask || someTasksAreOnly(t))) {
|
|
636
|
-
if (t.mode === "only") {
|
|
637
|
-
checkAllowOnly(t, allowOnly);
|
|
638
|
-
t.mode = "run";
|
|
639
|
-
}
|
|
640
|
-
} else if (t.mode === "run" && !includeTask) {
|
|
641
|
-
t.mode = "skip";
|
|
642
|
-
} else if (t.mode === "only") {
|
|
643
|
-
checkAllowOnly(t, allowOnly);
|
|
644
|
-
t.mode = "run";
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
if (t.type === "test") {
|
|
648
|
-
if (namePattern && !getTaskFullName(t).match(namePattern))
|
|
649
|
-
t.mode = "skip";
|
|
650
|
-
} else if (t.type === "suite") {
|
|
651
|
-
if (t.mode === "skip")
|
|
652
|
-
skipAllTasks(t);
|
|
653
|
-
else
|
|
654
|
-
interpretTaskModes(t, namePattern, onlyMode, includeTask, allowOnly);
|
|
655
|
-
}
|
|
656
|
-
});
|
|
657
|
-
if (suite.mode === "run") {
|
|
658
|
-
if (suite.tasks.length && suite.tasks.every((i) => i.mode !== "run"))
|
|
659
|
-
suite.mode = "skip";
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
function getTaskFullName(task) {
|
|
663
|
-
return `${task.suite ? `${getTaskFullName(task.suite)} ` : ""}${task.name}`;
|
|
664
|
-
}
|
|
665
|
-
function someTasksAreOnly(suite) {
|
|
666
|
-
return suite.tasks.some((t) => t.mode === "only" || t.type === "suite" && someTasksAreOnly(t));
|
|
667
|
-
}
|
|
668
|
-
function skipAllTasks(suite) {
|
|
669
|
-
suite.tasks.forEach((t) => {
|
|
670
|
-
if (t.mode === "run") {
|
|
671
|
-
t.mode = "skip";
|
|
672
|
-
if (t.type === "suite")
|
|
673
|
-
skipAllTasks(t);
|
|
674
|
-
}
|
|
675
|
-
});
|
|
676
|
-
}
|
|
677
|
-
function checkAllowOnly(task, allowOnly) {
|
|
678
|
-
if (allowOnly)
|
|
679
|
-
return;
|
|
680
|
-
task.result = {
|
|
681
|
-
state: "fail",
|
|
682
|
-
error: processError(new Error("[Vitest] Unexpected .only modifier. Remove it or pass --allowOnly argument to bypass this error"))
|
|
683
|
-
};
|
|
684
|
-
}
|
|
685
|
-
function calculateHash(parent) {
|
|
686
|
-
parent.tasks.forEach((t, idx) => {
|
|
687
|
-
t.id = `${parent.id}_${idx}`;
|
|
688
|
-
if (t.type === "suite")
|
|
689
|
-
calculateHash(t);
|
|
690
|
-
});
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
var __defProp = Object.defineProperty;
|
|
694
|
-
var __defProps = Object.defineProperties;
|
|
695
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
696
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
697
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
698
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
699
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
700
|
-
var __spreadValues = (a, b) => {
|
|
701
|
-
for (var prop in b || (b = {}))
|
|
702
|
-
if (__hasOwnProp.call(b, prop))
|
|
703
|
-
__defNormalProp(a, prop, b[prop]);
|
|
704
|
-
if (__getOwnPropSymbols)
|
|
705
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
706
|
-
if (__propIsEnum.call(b, prop))
|
|
707
|
-
__defNormalProp(a, prop, b[prop]);
|
|
708
|
-
}
|
|
709
|
-
return a;
|
|
710
|
-
};
|
|
711
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
712
|
-
const now = Date.now;
|
|
713
|
-
function updateSuiteHookState(suite, name, state) {
|
|
714
|
-
var _a;
|
|
715
|
-
if (!suite.result)
|
|
716
|
-
suite.result = { state: "run" };
|
|
717
|
-
if (!((_a = suite.result) == null ? void 0 : _a.hooks))
|
|
718
|
-
suite.result.hooks = {};
|
|
719
|
-
const suiteHooks = suite.result.hooks;
|
|
720
|
-
if (suiteHooks) {
|
|
721
|
-
suiteHooks[name] = state;
|
|
722
|
-
updateTask(suite);
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
async function callSuiteHook(suite, currentTask, name, args) {
|
|
726
|
-
if (name === "beforeEach" && suite.suite)
|
|
727
|
-
await callSuiteHook(suite.suite, currentTask, name, args);
|
|
728
|
-
updateSuiteHookState(currentTask, name, "run");
|
|
729
|
-
await Promise.all(getHooks(suite)[name].map((fn) => fn(...args)));
|
|
730
|
-
updateSuiteHookState(currentTask, name, "pass");
|
|
731
|
-
if (name === "afterEach" && suite.suite)
|
|
732
|
-
await callSuiteHook(suite.suite, currentTask, name, args);
|
|
733
|
-
}
|
|
734
|
-
const packs = /* @__PURE__ */ new Map();
|
|
735
|
-
let updateTimer;
|
|
736
|
-
let previousUpdate;
|
|
737
|
-
function updateTask(task) {
|
|
738
|
-
packs.set(task.id, task.result);
|
|
739
|
-
clearTimeout(updateTimer);
|
|
740
|
-
updateTimer = setTimeout(() => {
|
|
741
|
-
previousUpdate = sendTasksUpdate();
|
|
742
|
-
}, 10);
|
|
743
|
-
}
|
|
744
|
-
async function sendTasksUpdate() {
|
|
745
|
-
clearTimeout(updateTimer);
|
|
746
|
-
await previousUpdate;
|
|
747
|
-
if (packs.size) {
|
|
748
|
-
const p = rpc().onTaskUpdate(Array.from(packs));
|
|
749
|
-
packs.clear();
|
|
750
|
-
return p;
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
async function runTest(test) {
|
|
754
|
-
var _a, _b;
|
|
755
|
-
if (test.mode !== "run")
|
|
756
|
-
return;
|
|
757
|
-
if (((_a = test.result) == null ? void 0 : _a.state) === "fail") {
|
|
758
|
-
updateTask(test);
|
|
759
|
-
return;
|
|
760
|
-
}
|
|
761
|
-
const start = now();
|
|
762
|
-
test.result = {
|
|
763
|
-
state: "run",
|
|
764
|
-
startTime: start
|
|
765
|
-
};
|
|
766
|
-
updateTask(test);
|
|
767
|
-
clearModuleMocks();
|
|
768
|
-
await getSnapshotClient().setTest(test);
|
|
769
|
-
const workerState = getWorkerState();
|
|
770
|
-
workerState.current = test;
|
|
771
|
-
try {
|
|
772
|
-
await callSuiteHook(test.suite, test, "beforeEach", [test, test.suite]);
|
|
773
|
-
setState({
|
|
774
|
-
assertionCalls: 0,
|
|
775
|
-
isExpectingAssertions: false,
|
|
776
|
-
isExpectingAssertionsError: null,
|
|
777
|
-
expectedAssertionsNumber: null,
|
|
778
|
-
expectedAssertionsNumberErrorGen: null,
|
|
779
|
-
testPath: (_b = test.suite.file) == null ? void 0 : _b.filepath,
|
|
780
|
-
currentTestName: getFullName(test)
|
|
781
|
-
});
|
|
782
|
-
await getFn(test)();
|
|
783
|
-
const { assertionCalls, expectedAssertionsNumber, expectedAssertionsNumberErrorGen, isExpectingAssertions, isExpectingAssertionsError } = getState();
|
|
784
|
-
if (expectedAssertionsNumber !== null && assertionCalls !== expectedAssertionsNumber)
|
|
785
|
-
throw expectedAssertionsNumberErrorGen();
|
|
786
|
-
if (isExpectingAssertions === true && assertionCalls === 0)
|
|
787
|
-
throw isExpectingAssertionsError;
|
|
788
|
-
test.result.state = "pass";
|
|
789
|
-
} catch (e) {
|
|
790
|
-
test.result.state = "fail";
|
|
791
|
-
test.result.error = processError(e);
|
|
792
|
-
}
|
|
793
|
-
try {
|
|
794
|
-
await callSuiteHook(test.suite, test, "afterEach", [test, test.suite]);
|
|
795
|
-
} catch (e) {
|
|
796
|
-
test.result.state = "fail";
|
|
797
|
-
test.result.error = processError(e);
|
|
798
|
-
}
|
|
799
|
-
if (test.fails) {
|
|
800
|
-
if (test.result.state === "pass") {
|
|
801
|
-
test.result.state = "fail";
|
|
802
|
-
test.result.error = processError(new Error("Expect test to fail"));
|
|
803
|
-
} else {
|
|
804
|
-
test.result.state = "pass";
|
|
805
|
-
test.result.error = void 0;
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
getSnapshotClient().clearTest();
|
|
809
|
-
test.result.duration = now() - start;
|
|
810
|
-
workerState.current = void 0;
|
|
811
|
-
updateTask(test);
|
|
812
|
-
}
|
|
813
|
-
function markTasksAsSkipped(suite) {
|
|
814
|
-
suite.tasks.forEach((t) => {
|
|
815
|
-
t.mode = "skip";
|
|
816
|
-
t.result = __spreadProps(__spreadValues({}, t.result), { state: "skip" });
|
|
817
|
-
updateTask(t);
|
|
818
|
-
if (t.type === "suite")
|
|
819
|
-
markTasksAsSkipped(t);
|
|
820
|
-
});
|
|
821
|
-
}
|
|
822
|
-
async function runSuite(suite) {
|
|
823
|
-
var _a;
|
|
824
|
-
if (((_a = suite.result) == null ? void 0 : _a.state) === "fail") {
|
|
825
|
-
markTasksAsSkipped(suite);
|
|
826
|
-
updateTask(suite);
|
|
827
|
-
return;
|
|
828
|
-
}
|
|
829
|
-
const start = now();
|
|
830
|
-
suite.result = {
|
|
831
|
-
state: "run",
|
|
832
|
-
startTime: start
|
|
833
|
-
};
|
|
834
|
-
updateTask(suite);
|
|
835
|
-
if (suite.mode === "skip") {
|
|
836
|
-
suite.result.state = "skip";
|
|
837
|
-
} else if (suite.mode === "todo") {
|
|
838
|
-
suite.result.state = "todo";
|
|
839
|
-
} else {
|
|
840
|
-
try {
|
|
841
|
-
await callSuiteHook(suite, suite, "beforeAll", [suite]);
|
|
842
|
-
for (const tasksGroup of partitionSuiteChildren(suite)) {
|
|
843
|
-
if (tasksGroup[0].concurrent === true) {
|
|
844
|
-
await Promise.all(tasksGroup.map((c) => runSuiteChild(c)));
|
|
845
|
-
} else {
|
|
846
|
-
for (const c of tasksGroup)
|
|
847
|
-
await runSuiteChild(c);
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
await callSuiteHook(suite, suite, "afterAll", [suite]);
|
|
851
|
-
} catch (e) {
|
|
852
|
-
suite.result.state = "fail";
|
|
853
|
-
suite.result.error = processError(e);
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
suite.result.duration = now() - start;
|
|
857
|
-
if (suite.mode === "run") {
|
|
858
|
-
if (!hasTests(suite)) {
|
|
859
|
-
suite.result.state = "fail";
|
|
860
|
-
if (!suite.result.error)
|
|
861
|
-
suite.result.error = new Error(`No test found in suite ${suite.name}`);
|
|
862
|
-
} else if (hasFailed(suite)) {
|
|
863
|
-
suite.result.state = "fail";
|
|
864
|
-
} else {
|
|
865
|
-
suite.result.state = "pass";
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
updateTask(suite);
|
|
869
|
-
}
|
|
870
|
-
async function runSuiteChild(c) {
|
|
871
|
-
return c.type === "test" ? runTest(c) : runSuite(c);
|
|
872
|
-
}
|
|
873
|
-
async function runFiles(files, config) {
|
|
874
|
-
var _a;
|
|
875
|
-
for (const file of files) {
|
|
876
|
-
if (!file.tasks.length && !config.passWithNoTests) {
|
|
877
|
-
if (!((_a = file.result) == null ? void 0 : _a.error)) {
|
|
878
|
-
file.result = {
|
|
879
|
-
state: "fail",
|
|
880
|
-
error: new Error(`No test suite found in file ${file.filepath}`)
|
|
881
|
-
};
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
await runSuite(file);
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
async function startTests(paths, config) {
|
|
888
|
-
const files = await collectTests(paths, config);
|
|
889
|
-
rpc().onCollected(files);
|
|
890
|
-
await runFiles(files, config);
|
|
891
|
-
takeCoverage();
|
|
892
|
-
await getSnapshotClient().saveSnap();
|
|
893
|
-
await sendTasksUpdate();
|
|
894
|
-
}
|
|
895
|
-
function clearModuleMocks() {
|
|
896
|
-
const { clearMocks, mockReset, restoreMocks } = getWorkerState().config;
|
|
897
|
-
if (restoreMocks)
|
|
898
|
-
vi.restoreAllMocks();
|
|
899
|
-
else if (mockReset)
|
|
900
|
-
vi.resetAllMocks();
|
|
901
|
-
else if (clearMocks)
|
|
902
|
-
vi.clearAllMocks();
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
async function run(files, config) {
|
|
906
|
-
var _a;
|
|
907
|
-
await setupGlobalEnv(config);
|
|
908
|
-
const workerState = getWorkerState();
|
|
909
|
-
for (const file of files) {
|
|
910
|
-
workerState.mockMap.clear();
|
|
911
|
-
resetModules();
|
|
912
|
-
const code = await promises.readFile(file, "utf-8");
|
|
913
|
-
const env = ((_a = code.match(/@(?:vitest|jest)-environment\s+?([\w-]+)\b/)) == null ? void 0 : _a[1]) || config.environment || "node";
|
|
914
|
-
if (!["node", "jsdom", "happy-dom"].includes(env))
|
|
915
|
-
throw new Error(`Unsupported environment: ${env}`);
|
|
916
|
-
workerState.filepath = file;
|
|
917
|
-
await withEnv(env, config.environmentOptions || {}, async () => {
|
|
918
|
-
await startTests([file], config);
|
|
919
|
-
});
|
|
920
|
-
workerState.filepath = void 0;
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
export { run };
|
|
20
|
+
import 'crypto';
|