@rstest/core 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/353.js +7 -5
- package/dist/44.js +375 -0
- package/dist/612.js +12 -3
- package/dist/813.js +1 -0
- package/dist/867.js +11 -7
- package/dist/{202.js → 965.js} +43 -33
- package/dist/cli.js +56 -22
- package/dist/worker.js +60 -27
- package/dist-types/node.d.ts +6 -1
- package/dist-types/public.d.ts +7 -2
- package/dist-types/worker.d.ts +7 -2
- package/package.json +13 -8
package/dist/353.js
CHANGED
|
@@ -361,19 +361,21 @@ export const __webpack_modules__ = {
|
|
|
361
361
|
const relativePath = (0, external_pathe_.relative)(this.rootPath, test.testPath);
|
|
362
362
|
const { slowTestThreshold } = this.config;
|
|
363
363
|
let title = ` ${utils.$_.bold(statusColorfulStr[test.status])} ${(0, utils.aj)(relativePath)}`;
|
|
364
|
-
const formatDuration = (duration)=>utils.$_[duration > slowTestThreshold ? 'yellow' : 'green'](`${(0, utils.AS)(duration
|
|
364
|
+
const formatDuration = (duration)=>utils.$_[duration > slowTestThreshold ? 'yellow' : 'green'](`${(0, utils.AS)(duration)}`);
|
|
365
365
|
title += ` ${utils.$_.gray(`(${test.results.length})`)}`;
|
|
366
366
|
const isTooSlow = test.duration && test.duration > slowTestThreshold;
|
|
367
367
|
if (isTooSlow) title += ` ${formatDuration(test.duration)}`;
|
|
368
|
+
const hasRetryCase = test.results.some((result)=>(result.retryCount || 0) > 0);
|
|
368
369
|
utils.kg.log(title);
|
|
369
|
-
if ('fail' !== test.status && !isTooSlow) return;
|
|
370
|
+
if ('fail' !== test.status && !isTooSlow && !hasRetryCase) return;
|
|
370
371
|
const showAllCases = isTooSlow && !test.results.some((result)=>(result.duration || 0) > slowTestThreshold);
|
|
371
372
|
for (const result of test.results){
|
|
372
373
|
const isSlowCase = (result.duration || 0) > slowTestThreshold;
|
|
373
|
-
|
|
374
|
+
const retried = (result.retryCount || 0) > 0;
|
|
375
|
+
if (!showAllCases && 'fail' !== result.status && !isSlowCase && !retried) continue;
|
|
374
376
|
const icon = isSlowCase && 'pass' === result.status ? utils.$_.yellow(statusStr[result.status]) : statusColorfulStr[result.status];
|
|
375
377
|
const nameStr = (0, utils.Yz)(result);
|
|
376
|
-
const duration = void 0 !== result.duration ? ` (${(0, utils.AS)(result.duration
|
|
378
|
+
const duration = void 0 !== result.duration ? ` (${(0, utils.AS)(result.duration)})` : '';
|
|
377
379
|
const retry = result.retryCount ? utils.$_.yellow(` (retry x${result.retryCount})`) : '';
|
|
378
380
|
console.log(` ${icon} ${nameStr}${utils.$_.gray(duration)}${retry}`);
|
|
379
381
|
if (result.errors) for (const error of result.errors)console.error(utils.$_.red(` ${error.message}`));
|
|
@@ -452,7 +454,7 @@ export const __webpack_modules__ = {
|
|
|
452
454
|
});
|
|
453
455
|
return {
|
|
454
456
|
command,
|
|
455
|
-
version: "0.0.
|
|
457
|
+
version: "0.0.7",
|
|
456
458
|
rootPath,
|
|
457
459
|
reporters,
|
|
458
460
|
snapshotManager,
|
package/dist/44.js
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
export const __webpack_ids__ = [
|
|
2
|
+
"44"
|
|
3
|
+
];
|
|
4
|
+
export const __webpack_modules__ = {
|
|
5
|
+
"./src/runtime/worker/env/happyDom.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
7
|
+
environment: ()=>environment
|
|
8
|
+
});
|
|
9
|
+
var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/runtime/worker/env/utils.ts");
|
|
10
|
+
const environment = {
|
|
11
|
+
name: 'happy-dom',
|
|
12
|
+
async setup (global, { happyDom = {} }) {
|
|
13
|
+
const { Window } = await import("happy-dom");
|
|
14
|
+
const win = new Window({
|
|
15
|
+
...happyDom,
|
|
16
|
+
url: happyDom.url || 'http://localhost:3000',
|
|
17
|
+
console: console && global.console ? global.console : void 0
|
|
18
|
+
});
|
|
19
|
+
const cleanupGlobal = (0, _utils__WEBPACK_IMPORTED_MODULE_0__.Nc)(global, win, {
|
|
20
|
+
additionalKeys: [
|
|
21
|
+
'Request',
|
|
22
|
+
'Response',
|
|
23
|
+
'MessagePort',
|
|
24
|
+
'fetch'
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
const cleanupHandler = (0, _utils__WEBPACK_IMPORTED_MODULE_0__.xp)(global);
|
|
28
|
+
return {
|
|
29
|
+
async teardown () {
|
|
30
|
+
cleanupHandler();
|
|
31
|
+
if (win.close && win.happyDOM.abort) {
|
|
32
|
+
await win.happyDOM.abort();
|
|
33
|
+
win.close();
|
|
34
|
+
} else await win.happyDOM.cancelAsync();
|
|
35
|
+
cleanupGlobal();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
"./src/runtime/worker/env/utils.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
42
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
43
|
+
xp: ()=>addDefaultErrorHandler,
|
|
44
|
+
Nc: ()=>installGlobal
|
|
45
|
+
});
|
|
46
|
+
const LIVING_KEYS = [
|
|
47
|
+
'DOMException',
|
|
48
|
+
'URL',
|
|
49
|
+
'URLSearchParams',
|
|
50
|
+
'EventTarget',
|
|
51
|
+
'NamedNodeMap',
|
|
52
|
+
'Node',
|
|
53
|
+
'Attr',
|
|
54
|
+
'Element',
|
|
55
|
+
'DocumentFragment',
|
|
56
|
+
'DOMImplementation',
|
|
57
|
+
'Document',
|
|
58
|
+
'XMLDocument',
|
|
59
|
+
'CharacterData',
|
|
60
|
+
'Text',
|
|
61
|
+
'CDATASection',
|
|
62
|
+
'ProcessingInstruction',
|
|
63
|
+
'Comment',
|
|
64
|
+
'DocumentType',
|
|
65
|
+
'NodeList',
|
|
66
|
+
'RadioNodeList',
|
|
67
|
+
'HTMLCollection',
|
|
68
|
+
'HTMLOptionsCollection',
|
|
69
|
+
'DOMStringMap',
|
|
70
|
+
'DOMTokenList',
|
|
71
|
+
'StyleSheetList',
|
|
72
|
+
'HTMLElement',
|
|
73
|
+
'HTMLHeadElement',
|
|
74
|
+
'HTMLTitleElement',
|
|
75
|
+
'HTMLBaseElement',
|
|
76
|
+
'HTMLLinkElement',
|
|
77
|
+
'HTMLMetaElement',
|
|
78
|
+
'HTMLStyleElement',
|
|
79
|
+
'HTMLBodyElement',
|
|
80
|
+
'HTMLHeadingElement',
|
|
81
|
+
'HTMLParagraphElement',
|
|
82
|
+
'HTMLHRElement',
|
|
83
|
+
'HTMLPreElement',
|
|
84
|
+
'HTMLUListElement',
|
|
85
|
+
'HTMLOListElement',
|
|
86
|
+
'HTMLLIElement',
|
|
87
|
+
'HTMLMenuElement',
|
|
88
|
+
'HTMLDListElement',
|
|
89
|
+
'HTMLDivElement',
|
|
90
|
+
'HTMLAnchorElement',
|
|
91
|
+
'HTMLAreaElement',
|
|
92
|
+
'HTMLBRElement',
|
|
93
|
+
'HTMLButtonElement',
|
|
94
|
+
'HTMLCanvasElement',
|
|
95
|
+
'HTMLDataElement',
|
|
96
|
+
'HTMLDataListElement',
|
|
97
|
+
'HTMLDetailsElement',
|
|
98
|
+
'HTMLDialogElement',
|
|
99
|
+
'HTMLDirectoryElement',
|
|
100
|
+
'HTMLFieldSetElement',
|
|
101
|
+
'HTMLFontElement',
|
|
102
|
+
'HTMLFormElement',
|
|
103
|
+
'HTMLHtmlElement',
|
|
104
|
+
'HTMLImageElement',
|
|
105
|
+
'HTMLInputElement',
|
|
106
|
+
'HTMLLabelElement',
|
|
107
|
+
'HTMLLegendElement',
|
|
108
|
+
'HTMLMapElement',
|
|
109
|
+
'HTMLMarqueeElement',
|
|
110
|
+
'HTMLMediaElement',
|
|
111
|
+
'HTMLMeterElement',
|
|
112
|
+
'HTMLModElement',
|
|
113
|
+
'HTMLOptGroupElement',
|
|
114
|
+
'HTMLOptionElement',
|
|
115
|
+
'HTMLOutputElement',
|
|
116
|
+
'HTMLPictureElement',
|
|
117
|
+
'HTMLProgressElement',
|
|
118
|
+
'HTMLQuoteElement',
|
|
119
|
+
'HTMLScriptElement',
|
|
120
|
+
'HTMLSelectElement',
|
|
121
|
+
'HTMLSlotElement',
|
|
122
|
+
'HTMLSourceElement',
|
|
123
|
+
'HTMLSpanElement',
|
|
124
|
+
'HTMLTableCaptionElement',
|
|
125
|
+
'HTMLTableCellElement',
|
|
126
|
+
'HTMLTableColElement',
|
|
127
|
+
'HTMLTableElement',
|
|
128
|
+
'HTMLTimeElement',
|
|
129
|
+
'HTMLTableRowElement',
|
|
130
|
+
'HTMLTableSectionElement',
|
|
131
|
+
'HTMLTemplateElement',
|
|
132
|
+
'HTMLTextAreaElement',
|
|
133
|
+
'HTMLUnknownElement',
|
|
134
|
+
'HTMLFrameElement',
|
|
135
|
+
'HTMLFrameSetElement',
|
|
136
|
+
'HTMLIFrameElement',
|
|
137
|
+
'HTMLEmbedElement',
|
|
138
|
+
'HTMLObjectElement',
|
|
139
|
+
'HTMLParamElement',
|
|
140
|
+
'HTMLVideoElement',
|
|
141
|
+
'HTMLAudioElement',
|
|
142
|
+
'HTMLTrackElement',
|
|
143
|
+
'HTMLFormControlsCollection',
|
|
144
|
+
'SVGElement',
|
|
145
|
+
'SVGGraphicsElement',
|
|
146
|
+
'SVGSVGElement',
|
|
147
|
+
'SVGGElement',
|
|
148
|
+
'SVGDefsElement',
|
|
149
|
+
'SVGDescElement',
|
|
150
|
+
'SVGMetadataElement',
|
|
151
|
+
'SVGTitleElement',
|
|
152
|
+
'SVGSymbolElement',
|
|
153
|
+
'SVGSwitchElement',
|
|
154
|
+
'SVGAnimatedPreserveAspectRatio',
|
|
155
|
+
'SVGAnimatedRect',
|
|
156
|
+
'SVGAnimatedString',
|
|
157
|
+
'SVGNumber',
|
|
158
|
+
'SVGPreserveAspectRatio',
|
|
159
|
+
'SVGRect',
|
|
160
|
+
'SVGStringList',
|
|
161
|
+
'Event',
|
|
162
|
+
'BeforeUnloadEvent',
|
|
163
|
+
'BlobEvent',
|
|
164
|
+
'CloseEvent',
|
|
165
|
+
'CustomEvent',
|
|
166
|
+
'MessageEvent',
|
|
167
|
+
'ErrorEvent',
|
|
168
|
+
'HashChangeEvent',
|
|
169
|
+
'PopStateEvent',
|
|
170
|
+
'StorageEvent',
|
|
171
|
+
'ProgressEvent',
|
|
172
|
+
'PageTransitionEvent',
|
|
173
|
+
'SubmitEvent',
|
|
174
|
+
'UIEvent',
|
|
175
|
+
'FocusEvent',
|
|
176
|
+
'InputEvent',
|
|
177
|
+
'MouseEvent',
|
|
178
|
+
'KeyboardEvent',
|
|
179
|
+
'TouchEvent',
|
|
180
|
+
'CompositionEvent',
|
|
181
|
+
'WheelEvent',
|
|
182
|
+
'BarProp',
|
|
183
|
+
'External',
|
|
184
|
+
'Location',
|
|
185
|
+
'History',
|
|
186
|
+
'Screen',
|
|
187
|
+
'Performance',
|
|
188
|
+
'Navigator',
|
|
189
|
+
'Crypto',
|
|
190
|
+
'PluginArray',
|
|
191
|
+
'MimeTypeArray',
|
|
192
|
+
'Plugin',
|
|
193
|
+
'MimeType',
|
|
194
|
+
'FileReader',
|
|
195
|
+
'Blob',
|
|
196
|
+
'File',
|
|
197
|
+
'FileList',
|
|
198
|
+
'ValidityState',
|
|
199
|
+
'DOMParser',
|
|
200
|
+
'XMLSerializer',
|
|
201
|
+
'FormData',
|
|
202
|
+
'XMLHttpRequestEventTarget',
|
|
203
|
+
'XMLHttpRequestUpload',
|
|
204
|
+
'XMLHttpRequest',
|
|
205
|
+
'WebSocket',
|
|
206
|
+
'NodeFilter',
|
|
207
|
+
'NodeIterator',
|
|
208
|
+
'TreeWalker',
|
|
209
|
+
'AbstractRange',
|
|
210
|
+
'Range',
|
|
211
|
+
'StaticRange',
|
|
212
|
+
'Selection',
|
|
213
|
+
'Storage',
|
|
214
|
+
'CustomElementRegistry',
|
|
215
|
+
'ElementInternals',
|
|
216
|
+
'ShadowRoot',
|
|
217
|
+
'MutationObserver',
|
|
218
|
+
'MutationRecord',
|
|
219
|
+
'Headers',
|
|
220
|
+
'AbortController',
|
|
221
|
+
'AbortSignal',
|
|
222
|
+
'Uint8Array',
|
|
223
|
+
'Uint16Array',
|
|
224
|
+
'Uint32Array',
|
|
225
|
+
'Uint8ClampedArray',
|
|
226
|
+
'Int8Array',
|
|
227
|
+
'Int16Array',
|
|
228
|
+
'Int32Array',
|
|
229
|
+
'Float32Array',
|
|
230
|
+
'Float64Array',
|
|
231
|
+
'ArrayBuffer',
|
|
232
|
+
'DeviceMotionEventAcceleration',
|
|
233
|
+
'DeviceMotionEventRotationRate',
|
|
234
|
+
'DOMRectReadOnly',
|
|
235
|
+
'DOMRect',
|
|
236
|
+
'Image',
|
|
237
|
+
'Audio',
|
|
238
|
+
'Option',
|
|
239
|
+
'CSS'
|
|
240
|
+
];
|
|
241
|
+
const OTHER_KEYS = [
|
|
242
|
+
'addEventListener',
|
|
243
|
+
'alert',
|
|
244
|
+
'blur',
|
|
245
|
+
'cancelAnimationFrame',
|
|
246
|
+
'close',
|
|
247
|
+
'confirm',
|
|
248
|
+
'createPopup',
|
|
249
|
+
'dispatchEvent',
|
|
250
|
+
'document',
|
|
251
|
+
'focus',
|
|
252
|
+
'frames',
|
|
253
|
+
'getComputedStyle',
|
|
254
|
+
'history',
|
|
255
|
+
'innerHeight',
|
|
256
|
+
'innerWidth',
|
|
257
|
+
'length',
|
|
258
|
+
'location',
|
|
259
|
+
'matchMedia',
|
|
260
|
+
'moveBy',
|
|
261
|
+
'moveTo',
|
|
262
|
+
'name',
|
|
263
|
+
'navigator',
|
|
264
|
+
'open',
|
|
265
|
+
'outerHeight',
|
|
266
|
+
'outerWidth',
|
|
267
|
+
'pageXOffset',
|
|
268
|
+
'pageYOffset',
|
|
269
|
+
'parent',
|
|
270
|
+
'postMessage',
|
|
271
|
+
'print',
|
|
272
|
+
'prompt',
|
|
273
|
+
'removeEventListener',
|
|
274
|
+
'requestAnimationFrame',
|
|
275
|
+
'resizeBy',
|
|
276
|
+
'resizeTo',
|
|
277
|
+
'screen',
|
|
278
|
+
'screenLeft',
|
|
279
|
+
'screenTop',
|
|
280
|
+
'screenX',
|
|
281
|
+
'screenY',
|
|
282
|
+
'scroll',
|
|
283
|
+
'scrollBy',
|
|
284
|
+
'scrollLeft',
|
|
285
|
+
'scrollTo',
|
|
286
|
+
'scrollTop',
|
|
287
|
+
'scrollX',
|
|
288
|
+
'scrollY',
|
|
289
|
+
'self',
|
|
290
|
+
'stop',
|
|
291
|
+
'top',
|
|
292
|
+
'Window',
|
|
293
|
+
'window'
|
|
294
|
+
];
|
|
295
|
+
const KEYS = LIVING_KEYS.concat(OTHER_KEYS);
|
|
296
|
+
const SKIP_KEYS = [
|
|
297
|
+
'window',
|
|
298
|
+
'self',
|
|
299
|
+
'top',
|
|
300
|
+
'parent'
|
|
301
|
+
];
|
|
302
|
+
function getWindowKeys(global, win, additionalKeys = []) {
|
|
303
|
+
const keysArray = [
|
|
304
|
+
...additionalKeys,
|
|
305
|
+
...KEYS
|
|
306
|
+
];
|
|
307
|
+
return new Set(keysArray.concat(Object.getOwnPropertyNames(win)).filter((k)=>{
|
|
308
|
+
if (SKIP_KEYS.includes(k)) return false;
|
|
309
|
+
if (k in global) return keysArray.includes(k);
|
|
310
|
+
return true;
|
|
311
|
+
}));
|
|
312
|
+
}
|
|
313
|
+
function isClassLike(name) {
|
|
314
|
+
return name[0] === name[0]?.toUpperCase();
|
|
315
|
+
}
|
|
316
|
+
function installGlobal(global, win, options = {}) {
|
|
317
|
+
const { bindFunctions = true } = options || {};
|
|
318
|
+
const keys = getWindowKeys(global, win, options.additionalKeys);
|
|
319
|
+
const originals = new Map();
|
|
320
|
+
const overrides = new Map();
|
|
321
|
+
for (const key of keys){
|
|
322
|
+
const boundFunction = bindFunctions && 'function' == typeof win[key] && !isClassLike(key) && win[key].bind(win);
|
|
323
|
+
if (key in global) originals.set(key, global[key]);
|
|
324
|
+
Object.defineProperty(global, key, {
|
|
325
|
+
get () {
|
|
326
|
+
if (overrides.has(key)) return overrides.get(key);
|
|
327
|
+
if (boundFunction) return boundFunction;
|
|
328
|
+
return win[key];
|
|
329
|
+
},
|
|
330
|
+
set (v) {
|
|
331
|
+
overrides.set(key, v);
|
|
332
|
+
},
|
|
333
|
+
configurable: true
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
global.window = global;
|
|
337
|
+
global.self = global;
|
|
338
|
+
global.top = global;
|
|
339
|
+
global.parent = global;
|
|
340
|
+
if (global.global) global.global = global;
|
|
341
|
+
if (global.document?.defaultView) Object.defineProperty(global.document, 'defaultView', {
|
|
342
|
+
get: ()=>global,
|
|
343
|
+
enumerable: true,
|
|
344
|
+
configurable: true
|
|
345
|
+
});
|
|
346
|
+
for (const k of SKIP_KEYS)keys.add(k);
|
|
347
|
+
return ()=>{
|
|
348
|
+
for (const key of keys)delete global[key];
|
|
349
|
+
originals.forEach((v, k)=>{
|
|
350
|
+
global[k] = v;
|
|
351
|
+
});
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
function addDefaultErrorHandler(window) {
|
|
355
|
+
let userErrorListenerCount = 0;
|
|
356
|
+
const throwUnhandledError = (e)=>{
|
|
357
|
+
if (0 === userErrorListenerCount && null != e.error) process.emit('uncaughtException', e.error);
|
|
358
|
+
};
|
|
359
|
+
const addEventListener = window.addEventListener.bind(window);
|
|
360
|
+
const removeEventListener = window.removeEventListener.bind(window);
|
|
361
|
+
window.addEventListener('error', throwUnhandledError);
|
|
362
|
+
window.addEventListener = function(...args) {
|
|
363
|
+
if ('error' === args[0]) userErrorListenerCount++;
|
|
364
|
+
return addEventListener.apply(this, args);
|
|
365
|
+
};
|
|
366
|
+
window.removeEventListener = function(...args) {
|
|
367
|
+
if ('error' === args[0] && userErrorListenerCount) userErrorListenerCount--;
|
|
368
|
+
return removeEventListener.apply(this, args);
|
|
369
|
+
};
|
|
370
|
+
return ()=>{
|
|
371
|
+
window.removeEventListener('error', throwUnhandledError);
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
};
|
package/dist/612.js
CHANGED
|
@@ -287,7 +287,13 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
|
|
|
287
287
|
server: {
|
|
288
288
|
printUrls: false,
|
|
289
289
|
strictPort: false,
|
|
290
|
-
middlewareMode: true
|
|
290
|
+
middlewareMode: true,
|
|
291
|
+
compress: false,
|
|
292
|
+
cors: false,
|
|
293
|
+
publicDir: false
|
|
294
|
+
},
|
|
295
|
+
dev: {
|
|
296
|
+
hmr: false
|
|
291
297
|
},
|
|
292
298
|
performance,
|
|
293
299
|
environments: {
|
|
@@ -311,7 +317,8 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
|
|
|
311
317
|
target: 'node'
|
|
312
318
|
},
|
|
313
319
|
tools: {
|
|
314
|
-
rspack: (config)=>{
|
|
320
|
+
rspack: (config, { isProd })=>{
|
|
321
|
+
config.mode = isProd ? 'production' : 'development';
|
|
315
322
|
config.output ??= {};
|
|
316
323
|
config.output.iife = false;
|
|
317
324
|
config.output.importFunctionName = '__rstest_dynamic_import__';
|
|
@@ -346,6 +353,7 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
|
|
|
346
353
|
config.optimization = {
|
|
347
354
|
moduleIds: 'named',
|
|
348
355
|
chunkIds: 'named',
|
|
356
|
+
nodeEnv: false,
|
|
349
357
|
...config.optimization || {},
|
|
350
358
|
runtimeChunk: {
|
|
351
359
|
name: 'runtime'
|
|
@@ -595,10 +603,11 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
|
|
|
595
603
|
}
|
|
596
604
|
});
|
|
597
605
|
const { updateSnapshot } = context.snapshotManager.options;
|
|
598
|
-
const { testNamePattern, testTimeout, passWithNoTests, retry, globals, clearMocks, resetMocks, restoreMocks, unstubEnvs, unstubGlobals, maxConcurrency, printConsoleTrace, disableConsoleIntercept, testEnvironment } = context.normalizedConfig;
|
|
606
|
+
const { testNamePattern, testTimeout, passWithNoTests, retry, globals, clearMocks, resetMocks, restoreMocks, unstubEnvs, unstubGlobals, maxConcurrency, printConsoleTrace, disableConsoleIntercept, testEnvironment, hookTimeout } = context.normalizedConfig;
|
|
599
607
|
const runtimeConfig = {
|
|
600
608
|
testNamePattern,
|
|
601
609
|
testTimeout,
|
|
610
|
+
hookTimeout,
|
|
602
611
|
passWithNoTests,
|
|
603
612
|
retry,
|
|
604
613
|
globals,
|
package/dist/813.js
CHANGED
|
@@ -134,6 +134,7 @@ export const __webpack_modules__ = {
|
|
|
134
134
|
__webpack_require__("./src/utils/logger.ts");
|
|
135
135
|
__webpack_require__("node:fs");
|
|
136
136
|
__webpack_require__("node:fs/promises");
|
|
137
|
+
__webpack_require__("node:module");
|
|
137
138
|
__webpack_require__("pathe");
|
|
138
139
|
}
|
|
139
140
|
};
|
package/dist/867.js
CHANGED
|
@@ -586,7 +586,7 @@ export const __webpack_modules__ = {
|
|
|
586
586
|
}
|
|
587
587
|
};
|
|
588
588
|
}
|
|
589
|
-
function limitConcurrency(concurrency =
|
|
589
|
+
function limitConcurrency(concurrency = 1 / 0) {
|
|
590
590
|
let running = 0;
|
|
591
591
|
const queue = [];
|
|
592
592
|
const runNext = ()=>{
|
|
@@ -927,11 +927,12 @@ export const __webpack_modules__ = {
|
|
|
927
927
|
testPath;
|
|
928
928
|
collectStatus = 'lazy';
|
|
929
929
|
currentCollectList = [];
|
|
930
|
-
defaultHookTimeout
|
|
930
|
+
defaultHookTimeout;
|
|
931
931
|
defaultTestTimeout;
|
|
932
|
-
constructor({ testPath, testTimeout }){
|
|
932
|
+
constructor({ testPath, testTimeout, hookTimeout }){
|
|
933
933
|
this.testPath = testPath;
|
|
934
934
|
this.defaultTestTimeout = testTimeout;
|
|
935
|
+
this.defaultHookTimeout = hookTimeout;
|
|
935
936
|
}
|
|
936
937
|
afterAll(fn, timeout = this.defaultHookTimeout) {
|
|
937
938
|
const currentSuite = this.getCurrentSuite();
|
|
@@ -1139,10 +1140,11 @@ export const __webpack_modules__ = {
|
|
|
1139
1140
|
throw new Error('Expect to find a suite, but got undefined');
|
|
1140
1141
|
}
|
|
1141
1142
|
}
|
|
1142
|
-
const createRuntimeAPI = ({ testPath, testTimeout })=>{
|
|
1143
|
+
const createRuntimeAPI = ({ testPath, testTimeout, hookTimeout })=>{
|
|
1143
1144
|
const runtimeInstance = new RunnerRuntime({
|
|
1144
1145
|
testPath,
|
|
1145
|
-
testTimeout
|
|
1146
|
+
testTimeout,
|
|
1147
|
+
hookTimeout
|
|
1146
1148
|
});
|
|
1147
1149
|
const createTestAPI = (options = {})=>{
|
|
1148
1150
|
const testFn = (name, fn, timeout)=>runtimeInstance.it({
|
|
@@ -1290,10 +1292,11 @@ export const __webpack_modules__ = {
|
|
|
1290
1292
|
};
|
|
1291
1293
|
};
|
|
1292
1294
|
function createRunner({ workerState }) {
|
|
1293
|
-
const { testPath, runtimeConfig: { testTimeout, testNamePattern } } = workerState;
|
|
1295
|
+
const { testPath, runtimeConfig: { testTimeout, testNamePattern, hookTimeout } } = workerState;
|
|
1294
1296
|
const runtime = createRuntimeAPI({
|
|
1295
1297
|
testPath,
|
|
1296
|
-
testTimeout
|
|
1298
|
+
testTimeout,
|
|
1299
|
+
hookTimeout
|
|
1297
1300
|
});
|
|
1298
1301
|
const testRunner = new TestRunner();
|
|
1299
1302
|
return {
|
|
@@ -1736,6 +1739,7 @@ export const __webpack_modules__ = {
|
|
|
1736
1739
|
__webpack_require__("./src/utils/logger.ts");
|
|
1737
1740
|
__webpack_require__("node:fs");
|
|
1738
1741
|
__webpack_require__("node:fs/promises");
|
|
1742
|
+
__webpack_require__("node:module");
|
|
1739
1743
|
__webpack_require__("pathe");
|
|
1740
1744
|
}
|
|
1741
1745
|
};
|
package/dist/{202.js → 965.js}
RENAMED
|
@@ -1,11 +1,48 @@
|
|
|
1
1
|
export const __webpack_ids__ = [
|
|
2
|
-
"
|
|
2
|
+
"965"
|
|
3
3
|
];
|
|
4
4
|
export const __webpack_modules__ = {
|
|
5
5
|
"./src/runtime/worker/env/jsdom.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6
6
|
__webpack_require__.d(__webpack_exports__, {
|
|
7
7
|
environment: ()=>environment
|
|
8
8
|
});
|
|
9
|
+
var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/runtime/worker/env/utils.ts");
|
|
10
|
+
const environment = {
|
|
11
|
+
name: 'jsdom',
|
|
12
|
+
async setup (global, { jsdom = {} }) {
|
|
13
|
+
const { CookieJar, JSDOM, ResourceLoader, VirtualConsole } = await import("jsdom");
|
|
14
|
+
const { html = '<!DOCTYPE html>', userAgent, url = 'http://localhost:3000', contentType = 'text/html', pretendToBeVisual = true, includeNodeLocations = false, runScripts = 'dangerously', resources, console = false, cookieJar = false, ...restOptions } = jsdom;
|
|
15
|
+
const dom = new JSDOM(html, {
|
|
16
|
+
pretendToBeVisual,
|
|
17
|
+
resources: resources ?? (userAgent ? new ResourceLoader({
|
|
18
|
+
userAgent
|
|
19
|
+
}) : void 0),
|
|
20
|
+
runScripts,
|
|
21
|
+
url,
|
|
22
|
+
virtualConsole: console && global.console ? new VirtualConsole().sendTo(global.console) : void 0,
|
|
23
|
+
cookieJar: cookieJar ? new CookieJar() : void 0,
|
|
24
|
+
includeNodeLocations,
|
|
25
|
+
contentType,
|
|
26
|
+
userAgent,
|
|
27
|
+
...restOptions
|
|
28
|
+
});
|
|
29
|
+
const cleanupGlobal = (0, _utils__WEBPACK_IMPORTED_MODULE_0__.Nc)(global, dom.window);
|
|
30
|
+
const cleanupHandler = (0, _utils__WEBPACK_IMPORTED_MODULE_0__.xp)(global);
|
|
31
|
+
return {
|
|
32
|
+
teardown () {
|
|
33
|
+
cleanupHandler();
|
|
34
|
+
dom.window.close();
|
|
35
|
+
cleanupGlobal();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
"./src/runtime/worker/env/utils.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
42
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
43
|
+
xp: ()=>addDefaultErrorHandler,
|
|
44
|
+
Nc: ()=>installGlobal
|
|
45
|
+
});
|
|
9
46
|
const LIVING_KEYS = [
|
|
10
47
|
'DOMException',
|
|
11
48
|
'URL',
|
|
@@ -273,13 +310,16 @@ export const __webpack_modules__ = {
|
|
|
273
310
|
return true;
|
|
274
311
|
}));
|
|
275
312
|
}
|
|
313
|
+
function isClassLike(name) {
|
|
314
|
+
return name[0] === name[0]?.toUpperCase();
|
|
315
|
+
}
|
|
276
316
|
function installGlobal(global, win, options = {}) {
|
|
317
|
+
const { bindFunctions = true } = options || {};
|
|
277
318
|
const keys = getWindowKeys(global, win, options.additionalKeys);
|
|
278
|
-
const isClassLike = (name)=>name[0] === name[0]?.toUpperCase();
|
|
279
319
|
const originals = new Map();
|
|
280
320
|
const overrides = new Map();
|
|
281
321
|
for (const key of keys){
|
|
282
|
-
const boundFunction = 'function'
|
|
322
|
+
const boundFunction = bindFunctions && 'function' == typeof win[key] && !isClassLike(key) && win[key].bind(win);
|
|
283
323
|
if (key in global) originals.set(key, global[key]);
|
|
284
324
|
Object.defineProperty(global, key, {
|
|
285
325
|
get () {
|
|
@@ -331,35 +371,5 @@ export const __webpack_modules__ = {
|
|
|
331
371
|
window.removeEventListener('error', throwUnhandledError);
|
|
332
372
|
};
|
|
333
373
|
}
|
|
334
|
-
const environment = {
|
|
335
|
-
name: 'jsdom',
|
|
336
|
-
async setup (global, { jsdom = {} }) {
|
|
337
|
-
const { CookieJar, JSDOM, ResourceLoader, VirtualConsole } = await import("jsdom");
|
|
338
|
-
const { html = '<!DOCTYPE html>', userAgent, url = 'http://localhost:3000', contentType = 'text/html', pretendToBeVisual = true, includeNodeLocations = false, runScripts = 'dangerously', resources, console = false, cookieJar = false, ...restOptions } = jsdom;
|
|
339
|
-
const dom = new JSDOM(html, {
|
|
340
|
-
pretendToBeVisual,
|
|
341
|
-
resources: resources ?? (userAgent ? new ResourceLoader({
|
|
342
|
-
userAgent
|
|
343
|
-
}) : void 0),
|
|
344
|
-
runScripts,
|
|
345
|
-
url,
|
|
346
|
-
virtualConsole: console && global.console ? new VirtualConsole().sendTo(global.console) : void 0,
|
|
347
|
-
cookieJar: cookieJar ? new CookieJar() : void 0,
|
|
348
|
-
includeNodeLocations,
|
|
349
|
-
contentType,
|
|
350
|
-
userAgent,
|
|
351
|
-
...restOptions
|
|
352
|
-
});
|
|
353
|
-
const cleanupGlobal = installGlobal(global, dom.window);
|
|
354
|
-
const cleanupHandler = addDefaultErrorHandler(global);
|
|
355
|
-
return {
|
|
356
|
-
teardown () {
|
|
357
|
-
cleanupHandler();
|
|
358
|
-
dom.window.close();
|
|
359
|
-
cleanupGlobal();
|
|
360
|
-
}
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
};
|
|
364
374
|
}
|
|
365
375
|
};
|
package/dist/cli.js
CHANGED
|
@@ -7,6 +7,7 @@ import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
|
|
|
7
7
|
import * as __WEBPACK_EXTERNAL_MODULE_node_events_0a6aefe7__ from "node:events";
|
|
8
8
|
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
9
9
|
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__ from "node:fs/promises";
|
|
10
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
|
|
10
11
|
import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
|
|
11
12
|
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
12
13
|
import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
|
|
@@ -2238,6 +2239,7 @@ var __webpack_modules__ = {
|
|
|
2238
2239
|
passWithNoTests: false,
|
|
2239
2240
|
update: false,
|
|
2240
2241
|
testTimeout: 5000,
|
|
2242
|
+
hookTimeout: 10000,
|
|
2241
2243
|
testEnvironment: 'node',
|
|
2242
2244
|
retry: 0,
|
|
2243
2245
|
reporters: [
|
|
@@ -2332,18 +2334,23 @@ var __webpack_modules__ = {
|
|
|
2332
2334
|
}
|
|
2333
2335
|
return String(error);
|
|
2334
2336
|
}
|
|
2335
|
-
const prettyTime = (milliseconds
|
|
2336
|
-
|
|
2337
|
-
const indent = shouldFormat ? ' ' : '';
|
|
2338
|
-
if (milliseconds < 1000) return `${Math.round(milliseconds)}${indent}ms`;
|
|
2337
|
+
const prettyTime = (milliseconds)=>{
|
|
2338
|
+
if (milliseconds < 1000) return `${Math.round(milliseconds)}ms`;
|
|
2339
2339
|
const seconds = milliseconds / 1000;
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2340
|
+
const getSecond = (seconds, needDigits)=>{
|
|
2341
|
+
if (!needDigits || seconds === Math.ceil(seconds)) return `${Math.round(seconds).toString()}s`;
|
|
2342
|
+
const digits = seconds < 10 ? seconds >= 0.01 ? 2 : 3 : 1;
|
|
2343
|
+
return `${seconds.toFixed(digits)}s`;
|
|
2344
|
+
};
|
|
2345
|
+
const minutes = Math.floor(seconds / 60);
|
|
2346
|
+
const secondsRemainder = seconds % 60;
|
|
2347
|
+
let time = '';
|
|
2348
|
+
if (minutes > 0) time += `${minutes}m`;
|
|
2349
|
+
if (secondsRemainder > 0) {
|
|
2350
|
+
if (minutes > 0) time += ' ';
|
|
2351
|
+
time += getSecond(secondsRemainder, !minutes);
|
|
2343
2352
|
}
|
|
2344
|
-
|
|
2345
|
-
const minutes = seconds / 60;
|
|
2346
|
-
return `${format(minutes.toFixed(2))}${indent}m`;
|
|
2353
|
+
return time;
|
|
2347
2354
|
};
|
|
2348
2355
|
const getTaskNames = (test)=>(test.parentNames || []).concat(test.name).filter(Boolean);
|
|
2349
2356
|
const getTaskNameWithPrefix = (test, delimiter = _constants__WEBPACK_IMPORTED_MODULE_1__.Qd)=>getTaskNames(test).join(` ${delimiter} `);
|
|
@@ -2463,6 +2470,7 @@ var __webpack_modules__ = {
|
|
|
2463
2470
|
var logger = __webpack_require__("./src/utils/logger.ts");
|
|
2464
2471
|
var external_node_fs_ = __webpack_require__("node:fs");
|
|
2465
2472
|
var promises_ = __webpack_require__("node:fs/promises");
|
|
2473
|
+
var external_node_module_ = __webpack_require__("node:module");
|
|
2466
2474
|
var external_pathe_ = __webpack_require__("pathe");
|
|
2467
2475
|
var dist = __webpack_require__("../../node_modules/.pnpm/tinyglobby@0.2.14/node_modules/tinyglobby/dist/index.mjs");
|
|
2468
2476
|
const filterFiles = (testFiles, filters, dir)=>{
|
|
@@ -2512,18 +2520,38 @@ var __webpack_modules__ = {
|
|
|
2512
2520
|
];
|
|
2513
2521
|
}));
|
|
2514
2522
|
};
|
|
2523
|
+
const tryResolve = (request, rootPath)=>{
|
|
2524
|
+
try {
|
|
2525
|
+
const require1 = (0, external_node_module_.createRequire)(rootPath);
|
|
2526
|
+
return require1.resolve(request, {
|
|
2527
|
+
paths: [
|
|
2528
|
+
rootPath
|
|
2529
|
+
]
|
|
2530
|
+
});
|
|
2531
|
+
} catch (_err) {
|
|
2532
|
+
return;
|
|
2533
|
+
}
|
|
2534
|
+
};
|
|
2515
2535
|
const getSetupFiles = (setups, rootPath)=>Object.fromEntries((0, helper.XQ)(setups).map((setupFile)=>{
|
|
2516
2536
|
const setupFilePath = (0, helper.ZY)(rootPath, setupFile);
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2537
|
+
try {
|
|
2538
|
+
if (!(0, external_node_fs_.existsSync)(setupFilePath)) {
|
|
2539
|
+
let errorMessage = `Setup file ${helper.$_.red(setupFile)} not found`;
|
|
2540
|
+
if (setupFilePath !== setupFile) errorMessage += helper.$_.gray(` (resolved path: ${setupFilePath})`);
|
|
2541
|
+
throw errorMessage;
|
|
2542
|
+
}
|
|
2543
|
+
const relativePath = external_pathe_["default"].relative(rootPath, setupFilePath);
|
|
2544
|
+
return [
|
|
2545
|
+
formatTestEntryName(relativePath),
|
|
2546
|
+
setupFilePath
|
|
2547
|
+
];
|
|
2548
|
+
} catch (err) {
|
|
2549
|
+
if (tryResolve(setupFile, rootPath)) return [
|
|
2550
|
+
formatTestEntryName(setupFile),
|
|
2551
|
+
setupFile
|
|
2552
|
+
];
|
|
2553
|
+
throw err;
|
|
2521
2554
|
}
|
|
2522
|
-
const relativePath = external_pathe_["default"].relative(rootPath, setupFilePath);
|
|
2523
|
-
return [
|
|
2524
|
-
formatTestEntryName(relativePath),
|
|
2525
|
-
setupFilePath
|
|
2526
|
-
];
|
|
2527
2555
|
}));
|
|
2528
2556
|
const prettyTestPath = (testPath)=>{
|
|
2529
2557
|
const { dir, base } = (0, helper.H)(testPath);
|
|
@@ -2833,6 +2861,9 @@ var __webpack_modules__ = {
|
|
|
2833
2861
|
"node:fs/promises": function(module) {
|
|
2834
2862
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__;
|
|
2835
2863
|
},
|
|
2864
|
+
"node:module": function(module) {
|
|
2865
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__;
|
|
2866
|
+
},
|
|
2836
2867
|
"node:os": function(module) {
|
|
2837
2868
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__;
|
|
2838
2869
|
},
|
|
@@ -3665,13 +3696,13 @@ function prepareCli() {
|
|
|
3665
3696
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
3666
3697
|
}
|
|
3667
3698
|
function showRstest() {
|
|
3668
|
-
logger.k.greet(" Rstest v0.0.
|
|
3699
|
+
logger.k.greet(" Rstest v0.0.7");
|
|
3669
3700
|
logger.k.log('');
|
|
3670
3701
|
}
|
|
3671
3702
|
const applyCommonOptions = (cli)=>{
|
|
3672
3703
|
cli.option('-c, --config <config>', 'Specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'Specify the loader to load the config file, can be `jiti` or `native`', {
|
|
3673
3704
|
default: 'jiti'
|
|
3674
|
-
}).option('-r, --root <root>', 'Specify the project root directory, can be an absolute path or a path relative to cwd').option('--globals', 'Provide global APIs').option('-u, --update', 'Update snapshot files').option('--passWithNoTests', 'Allows the test suite to pass when no files are found').option('--printConsoleTrace', 'Print console traces when calling any console method').option('--disableConsoleIntercept', 'Disable console intercept').option('--slowTestThreshold <value>', 'The number of milliseconds after which a test or suite is considered slow').option('-t, --testNamePattern <value>', 'Run only tests with a name that matches the regex').option('--testEnvironment <name>', 'The environment that will be used for testing').option('--testTimeout <value>', 'Timeout of a test in milliseconds').option('--retry <retry>', 'Number of times to retry a test if it fails').option('--maxConcurrency <value>', 'Maximum number of concurrent tests').option('--clearMocks', 'Automatically clear mock calls, instances, contexts and results before every test').option('--resetMocks', 'Automatically reset mock state before every test').option('--restoreMocks', 'Automatically restore mock state and implementation before every test').option('--unstubGlobals', 'Restores all global variables that were changed with `rstest.stubGlobal` before every test').option('--unstubEnvs', 'Restores all `process.env` values that were changed with `rstest.stubEnv` before every test');
|
|
3705
|
+
}).option('-r, --root <root>', 'Specify the project root directory, can be an absolute path or a path relative to cwd').option('--globals', 'Provide global APIs').option('--isolate', 'Run tests in an isolated environment').option('--exclude <exclude>', 'Exclude files from test').option('-u, --update', 'Update snapshot files').option('--passWithNoTests', 'Allows the test suite to pass when no files are found').option('--printConsoleTrace', 'Print console traces when calling any console method').option('--disableConsoleIntercept', 'Disable console intercept').option('--slowTestThreshold <value>', 'The number of milliseconds after which a test or suite is considered slow').option('-t, --testNamePattern <value>', 'Run only tests with a name that matches the regex').option('--testEnvironment <name>', 'The environment that will be used for testing').option('--testTimeout <value>', 'Timeout of a test in milliseconds').option('--hookTimeout <value>', 'Timeout of hook in milliseconds').option('--retry <retry>', 'Number of times to retry a test if it fails').option('--maxConcurrency <value>', 'Maximum number of concurrent tests').option('--clearMocks', 'Automatically clear mock calls, instances, contexts and results before every test').option('--resetMocks', 'Automatically reset mock state before every test').option('--restoreMocks', 'Automatically restore mock state and implementation before every test').option('--unstubGlobals', 'Restores all global variables that were changed with `rstest.stubGlobal` before every test').option('--unstubEnvs', 'Restores all `process.env` values that were changed with `rstest.stubEnv` before every test');
|
|
3675
3706
|
};
|
|
3676
3707
|
async function initCli(options) {
|
|
3677
3708
|
const cwd = process.cwd();
|
|
@@ -3684,10 +3715,12 @@ async function initCli(options) {
|
|
|
3684
3715
|
const keys = [
|
|
3685
3716
|
'root',
|
|
3686
3717
|
'globals',
|
|
3718
|
+
'isolate',
|
|
3687
3719
|
'passWithNoTests',
|
|
3688
3720
|
'update',
|
|
3689
3721
|
'testNamePattern',
|
|
3690
3722
|
'testTimeout',
|
|
3723
|
+
'hookTimeout',
|
|
3691
3724
|
'clearMocks',
|
|
3692
3725
|
'resetMocks',
|
|
3693
3726
|
'restoreMocks',
|
|
@@ -3701,6 +3734,7 @@ async function initCli(options) {
|
|
|
3701
3734
|
'testEnvironment'
|
|
3702
3735
|
];
|
|
3703
3736
|
for (const key of keys)if (void 0 !== options[key]) config[key] = options[key];
|
|
3737
|
+
if (options.exclude) config.exclude = (0, helper.XQ)(options.exclude);
|
|
3704
3738
|
return {
|
|
3705
3739
|
config,
|
|
3706
3740
|
configFilePath
|
|
@@ -3709,7 +3743,7 @@ async function initCli(options) {
|
|
|
3709
3743
|
function setupCommands() {
|
|
3710
3744
|
const cli = dist('rstest');
|
|
3711
3745
|
cli.help();
|
|
3712
|
-
cli.version("0.0.
|
|
3746
|
+
cli.version("0.0.7");
|
|
3713
3747
|
applyCommonOptions(cli);
|
|
3714
3748
|
cli.command('[...filters]', 'run tests').action(async (filters, options)=>{
|
|
3715
3749
|
showRstest();
|
package/dist/worker.js
CHANGED
|
@@ -9,6 +9,7 @@ import * as __WEBPACK_EXTERNAL_MODULE_node_assert_3e74d44e__ from "node:assert";
|
|
|
9
9
|
import * as __WEBPACK_EXTERNAL_MODULE_node_console_8631dfae__ from "node:console";
|
|
10
10
|
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
11
11
|
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__ from "node:fs/promises";
|
|
12
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
|
|
12
13
|
import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
|
|
13
14
|
import * as __WEBPACK_EXTERNAL_MODULE_node_timers_7045d530__ from "node:timers";
|
|
14
15
|
import * as __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__ from "node:util";
|
|
@@ -17,7 +18,6 @@ import * as __WEBPACK_EXTERNAL_MODULE_path__ from "path";
|
|
|
17
18
|
import * as __WEBPACK_EXTERNAL_MODULE_pathe__ from "pathe";
|
|
18
19
|
import * as __WEBPACK_EXTERNAL_MODULE_tty__ from "tty";
|
|
19
20
|
import * as __WEBPACK_EXTERNAL_MODULE_util__ from "util";
|
|
20
|
-
import { createRequire } from "node:module";
|
|
21
21
|
import { isAbsolute } from "node:path";
|
|
22
22
|
import { pathToFileURL } from "node:url";
|
|
23
23
|
import node_vm from "node:vm";
|
|
@@ -2887,7 +2887,7 @@ var __webpack_modules__ = {
|
|
|
2887
2887
|
return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
|
|
2888
2888
|
};
|
|
2889
2889
|
},
|
|
2890
|
-
"../../node_modules/.pnpm/jest-diff@30.0.
|
|
2890
|
+
"../../node_modules/.pnpm/jest-diff@30.0.4/node_modules/jest-diff/build/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
2891
2891
|
/*!
|
|
2892
2892
|
* /**
|
|
2893
2893
|
* * Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -4556,8 +4556,8 @@ var __webpack_modules__ = {
|
|
|
4556
4556
|
escapeString: true,
|
|
4557
4557
|
highlight: false,
|
|
4558
4558
|
indent: 2,
|
|
4559
|
-
maxDepth:
|
|
4560
|
-
maxWidth:
|
|
4559
|
+
maxDepth: 1 / 0,
|
|
4560
|
+
maxWidth: 1 / 0,
|
|
4561
4561
|
min: false,
|
|
4562
4562
|
plugins: [],
|
|
4563
4563
|
printBasicPrototype: true,
|
|
@@ -4978,7 +4978,7 @@ var __webpack_modules__ = {
|
|
|
4978
4978
|
o: ()=>formatTestError
|
|
4979
4979
|
});
|
|
4980
4980
|
var external_node_util_ = __webpack_require__("node:util");
|
|
4981
|
-
var build = __webpack_require__("../../node_modules/.pnpm/jest-diff@30.0.
|
|
4981
|
+
var build = __webpack_require__("../../node_modules/.pnpm/jest-diff@30.0.4/node_modules/jest-diff/build/index.js");
|
|
4982
4982
|
build.DIFF_DELETE;
|
|
4983
4983
|
build.DIFF_EQUAL;
|
|
4984
4984
|
build.DIFF_INSERT;
|
|
@@ -5081,18 +5081,23 @@ var __webpack_modules__ = {
|
|
|
5081
5081
|
arr
|
|
5082
5082
|
];
|
|
5083
5083
|
};
|
|
5084
|
-
const prettyTime = (milliseconds
|
|
5085
|
-
|
|
5086
|
-
const indent = shouldFormat ? ' ' : '';
|
|
5087
|
-
if (milliseconds < 1000) return `${Math.round(milliseconds)}${indent}ms`;
|
|
5084
|
+
const prettyTime = (milliseconds)=>{
|
|
5085
|
+
if (milliseconds < 1000) return `${Math.round(milliseconds)}ms`;
|
|
5088
5086
|
const seconds = milliseconds / 1000;
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5087
|
+
const getSecond = (seconds, needDigits)=>{
|
|
5088
|
+
if (!needDigits || seconds === Math.ceil(seconds)) return `${Math.round(seconds).toString()}s`;
|
|
5089
|
+
const digits = seconds < 10 ? seconds >= 0.01 ? 2 : 3 : 1;
|
|
5090
|
+
return `${seconds.toFixed(digits)}s`;
|
|
5091
|
+
};
|
|
5092
|
+
const minutes = Math.floor(seconds / 60);
|
|
5093
|
+
const secondsRemainder = seconds % 60;
|
|
5094
|
+
let time = '';
|
|
5095
|
+
if (minutes > 0) time += `${minutes}m`;
|
|
5096
|
+
if (secondsRemainder > 0) {
|
|
5097
|
+
if (minutes > 0) time += ' ';
|
|
5098
|
+
time += getSecond(secondsRemainder, !minutes);
|
|
5092
5099
|
}
|
|
5093
|
-
|
|
5094
|
-
const minutes = seconds / 60;
|
|
5095
|
-
return `${format(minutes.toFixed(2))}${indent}m`;
|
|
5100
|
+
return time;
|
|
5096
5101
|
};
|
|
5097
5102
|
const getTaskNames = (test)=>(test.parentNames || []).concat(test.name).filter(Boolean);
|
|
5098
5103
|
const getTaskNameWithPrefix = (test, delimiter = _constants__WEBPACK_IMPORTED_MODULE_1__.Qd)=>getTaskNames(test).join(` ${delimiter} `);
|
|
@@ -5422,6 +5427,9 @@ var __webpack_modules__ = {
|
|
|
5422
5427
|
"node:fs/promises": function(module) {
|
|
5423
5428
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__;
|
|
5424
5429
|
},
|
|
5430
|
+
"node:module": function(module) {
|
|
5431
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__;
|
|
5432
|
+
},
|
|
5425
5433
|
"node:os": function(module) {
|
|
5426
5434
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__;
|
|
5427
5435
|
},
|
|
@@ -5576,6 +5584,7 @@ __webpack_require__("./src/runtime/worker/setup.ts");
|
|
|
5576
5584
|
var constants = __webpack_require__("./src/utils/constants.ts");
|
|
5577
5585
|
var helper = __webpack_require__("./src/utils/helper.ts");
|
|
5578
5586
|
var util = __webpack_require__("./src/runtime/util.ts");
|
|
5587
|
+
var external_node_module_ = __webpack_require__("node:module");
|
|
5579
5588
|
var external_pathe_ = __webpack_require__("pathe");
|
|
5580
5589
|
var logger = __webpack_require__("./src/utils/logger.ts");
|
|
5581
5590
|
const shouldInterop = ({ interopDefault = true, modulePath, mod })=>{
|
|
@@ -5621,8 +5630,14 @@ const asModule = async (something, defaultExport, context, unlinked)=>{
|
|
|
5621
5630
|
return m;
|
|
5622
5631
|
};
|
|
5623
5632
|
const isRelativePath = (p)=>/^\.\.?\//.test(p);
|
|
5624
|
-
const
|
|
5625
|
-
const _require =
|
|
5633
|
+
const createRequire = (filename, distPath, rstestContext, assetFiles, interopDefault)=>{
|
|
5634
|
+
const _require = (()=>{
|
|
5635
|
+
try {
|
|
5636
|
+
return (0, external_node_module_.createRequire)(filename);
|
|
5637
|
+
} catch (_err) {
|
|
5638
|
+
return (0, external_node_module_.createRequire)(distPath);
|
|
5639
|
+
}
|
|
5640
|
+
})();
|
|
5626
5641
|
const require1 = (id)=>{
|
|
5627
5642
|
const currentDirectory = external_pathe_["default"].dirname(distPath);
|
|
5628
5643
|
const joinedPath = isRelativePath(id) ? external_pathe_["default"].join(currentDirectory, id) : id;
|
|
@@ -5694,7 +5709,7 @@ const loadModule = ({ codeContent, distPath, testPath, rstestContext, assetFiles
|
|
|
5694
5709
|
const context = {
|
|
5695
5710
|
module: localModule,
|
|
5696
5711
|
exports: localModule.exports,
|
|
5697
|
-
require:
|
|
5712
|
+
require: createRequire(testPath, distPath, rstestContext, assetFiles, interopDefault),
|
|
5698
5713
|
__rstest_dynamic_import__: defineRstestDynamicImport({
|
|
5699
5714
|
testPath,
|
|
5700
5715
|
interopDefault
|
|
@@ -5768,6 +5783,8 @@ const getGlobalApi = (api)=>constants.io.reduce((apis, key)=>{
|
|
|
5768
5783
|
apis[key] = api[key];
|
|
5769
5784
|
return apis;
|
|
5770
5785
|
}, {});
|
|
5786
|
+
const listeners = [];
|
|
5787
|
+
let isTeardown = false;
|
|
5771
5788
|
const preparePool = async ({ entryInfo: { distPath, testPath }, sourceMaps, updateSnapshot, context })=>{
|
|
5772
5789
|
context.runtimeConfig = (0, helper.PQ)(context.runtimeConfig);
|
|
5773
5790
|
const cleanupFns = [];
|
|
@@ -5806,25 +5823,36 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, sourceMaps, upda
|
|
|
5806
5823
|
return null;
|
|
5807
5824
|
}
|
|
5808
5825
|
});
|
|
5826
|
+
listeners.forEach((fn)=>fn());
|
|
5827
|
+
listeners.length = 0;
|
|
5809
5828
|
const unhandledErrors = [];
|
|
5810
5829
|
const handleError = (e, type)=>{
|
|
5811
5830
|
e.name = type;
|
|
5812
|
-
|
|
5813
|
-
|
|
5831
|
+
if (isTeardown) {
|
|
5832
|
+
e.stack = `${helper.$_.yellow('Caught error after test environment was torn down:')}\n\n${e.stack}`;
|
|
5833
|
+
console.error(e);
|
|
5834
|
+
} else {
|
|
5835
|
+
console.error(e);
|
|
5836
|
+
unhandledErrors.push(e);
|
|
5837
|
+
}
|
|
5814
5838
|
};
|
|
5815
5839
|
const uncaughtException = (e)=>handleError(e, 'uncaughtException');
|
|
5816
5840
|
const unhandledRejection = (e)=>handleError(e, 'unhandledRejection');
|
|
5817
5841
|
process.on('uncaughtException', uncaughtException);
|
|
5818
5842
|
process.on('unhandledRejection', unhandledRejection);
|
|
5819
|
-
|
|
5843
|
+
listeners.push(()=>{
|
|
5820
5844
|
process.off('uncaughtException', uncaughtException);
|
|
5821
5845
|
process.off('unhandledRejection', unhandledRejection);
|
|
5822
5846
|
});
|
|
5823
5847
|
const { api, runner } = createRstestRuntime(workerState);
|
|
5824
5848
|
if ('jsdom' === testEnvironment) {
|
|
5825
|
-
const { environment } = await __webpack_require__.e("
|
|
5849
|
+
const { environment } = await __webpack_require__.e("965").then(__webpack_require__.bind(__webpack_require__, "./src/runtime/worker/env/jsdom.ts"));
|
|
5826
5850
|
const { teardown } = await environment.setup(global, {});
|
|
5827
5851
|
cleanupFns.push(()=>teardown(global));
|
|
5852
|
+
} else if ('happy-dom' === testEnvironment) {
|
|
5853
|
+
const { environment } = await __webpack_require__.e("44").then(__webpack_require__.bind(__webpack_require__, "./src/runtime/worker/env/happyDom.ts"));
|
|
5854
|
+
const { teardown } = await environment.setup(global, {});
|
|
5855
|
+
cleanupFns.push(async ()=>await teardown(global));
|
|
5828
5856
|
}
|
|
5829
5857
|
const rstestContext = {
|
|
5830
5858
|
global,
|
|
@@ -5877,8 +5905,16 @@ const loadFiles = async ({ setupEntries, assetFiles, rstestContext, distPath, te
|
|
|
5877
5905
|
});
|
|
5878
5906
|
};
|
|
5879
5907
|
const runInPool = async (options)=>{
|
|
5908
|
+
isTeardown = false;
|
|
5880
5909
|
const { entryInfo: { distPath, testPath }, setupEntries, assetFiles, type, context: { runtimeConfig: { isolate } } } = options;
|
|
5881
5910
|
const cleanups = [];
|
|
5911
|
+
const exit = process.exit;
|
|
5912
|
+
process.exit = (code = process.exitCode || 0)=>{
|
|
5913
|
+
throw new Error(`process.exit unexpectedly called with "${code}"`);
|
|
5914
|
+
};
|
|
5915
|
+
cleanups.push(()=>{
|
|
5916
|
+
process.exit = exit;
|
|
5917
|
+
});
|
|
5882
5918
|
if ('collect' === type) try {
|
|
5883
5919
|
const { rstestContext, runner, cleanup, unhandledErrors, interopDefault } = await preparePool(options);
|
|
5884
5920
|
cleanups.push(cleanup);
|
|
@@ -5905,12 +5941,9 @@ const runInPool = async (options)=>{
|
|
|
5905
5941
|
};
|
|
5906
5942
|
} finally{
|
|
5907
5943
|
await Promise.all(cleanups.map((fn)=>fn()));
|
|
5944
|
+
isTeardown = true;
|
|
5908
5945
|
}
|
|
5909
|
-
const exit = process.exit;
|
|
5910
5946
|
try {
|
|
5911
|
-
process.exit = (code = process.exitCode || 0)=>{
|
|
5912
|
-
throw new Error(`process.exit unexpectedly called with "${code}"`);
|
|
5913
|
-
};
|
|
5914
5947
|
const { rstestContext, runner, rpc, api, cleanup, unhandledErrors, interopDefault } = await preparePool(options);
|
|
5915
5948
|
cleanups.push(cleanup);
|
|
5916
5949
|
await loadFiles({
|
|
@@ -5948,7 +5981,7 @@ const runInPool = async (options)=>{
|
|
|
5948
5981
|
};
|
|
5949
5982
|
} finally{
|
|
5950
5983
|
await Promise.all(cleanups.map((fn)=>fn()));
|
|
5951
|
-
|
|
5984
|
+
isTeardown = true;
|
|
5952
5985
|
}
|
|
5953
5986
|
};
|
|
5954
5987
|
const worker = runInPool;
|
package/dist-types/node.d.ts
CHANGED
|
@@ -197,7 +197,7 @@ export declare interface RstestConfig {
|
|
|
197
197
|
*
|
|
198
198
|
* @default 'node'
|
|
199
199
|
*/
|
|
200
|
-
testEnvironment?: 'node' | 'jsdom';
|
|
200
|
+
testEnvironment?: 'node' | 'jsdom' | 'happy-dom';
|
|
201
201
|
/**
|
|
202
202
|
* print console traces when calling any console method.
|
|
203
203
|
*
|
|
@@ -230,6 +230,11 @@ export declare interface RstestConfig {
|
|
|
230
230
|
* @default 5000
|
|
231
231
|
*/
|
|
232
232
|
testTimeout?: number;
|
|
233
|
+
/**
|
|
234
|
+
* Timeout of hook in milliseconds.
|
|
235
|
+
* @default 10000
|
|
236
|
+
*/
|
|
237
|
+
hookTimeout?: number;
|
|
233
238
|
/**
|
|
234
239
|
* Automatically clear mock calls, instances, contexts and results before every test.
|
|
235
240
|
* @default false
|
package/dist-types/public.d.ts
CHANGED
|
@@ -297,7 +297,7 @@ declare interface MatcherState extends MatcherState_2 {
|
|
|
297
297
|
|
|
298
298
|
declare type MaybePromise<T> = T | Promise<T>;
|
|
299
299
|
|
|
300
|
-
declare interface Mock<T extends FunctionLike = FunctionLike> extends MockInstance<T> {
|
|
300
|
+
export declare interface Mock<T extends FunctionLike = FunctionLike> extends MockInstance<T> {
|
|
301
301
|
new (...args: Parameters<T>): ReturnType<T>;
|
|
302
302
|
(...args: Parameters<T>): ReturnType<T>;
|
|
303
303
|
}
|
|
@@ -587,7 +587,7 @@ export declare interface RstestConfig {
|
|
|
587
587
|
*
|
|
588
588
|
* @default 'node'
|
|
589
589
|
*/
|
|
590
|
-
testEnvironment?: 'node' | 'jsdom';
|
|
590
|
+
testEnvironment?: 'node' | 'jsdom' | 'happy-dom';
|
|
591
591
|
/**
|
|
592
592
|
* print console traces when calling any console method.
|
|
593
593
|
*
|
|
@@ -620,6 +620,11 @@ export declare interface RstestConfig {
|
|
|
620
620
|
* @default 5000
|
|
621
621
|
*/
|
|
622
622
|
testTimeout?: number;
|
|
623
|
+
/**
|
|
624
|
+
* Timeout of hook in milliseconds.
|
|
625
|
+
* @default 10000
|
|
626
|
+
*/
|
|
627
|
+
hookTimeout?: number;
|
|
623
628
|
/**
|
|
624
629
|
* Automatically clear mock calls, instances, contexts and results before every test.
|
|
625
630
|
* @default false
|
package/dist-types/worker.d.ts
CHANGED
|
@@ -335,7 +335,7 @@ declare interface RstestConfig {
|
|
|
335
335
|
*
|
|
336
336
|
* @default 'node'
|
|
337
337
|
*/
|
|
338
|
-
testEnvironment?: 'node' | 'jsdom';
|
|
338
|
+
testEnvironment?: 'node' | 'jsdom' | 'happy-dom';
|
|
339
339
|
/**
|
|
340
340
|
* print console traces when calling any console method.
|
|
341
341
|
*
|
|
@@ -368,6 +368,11 @@ declare interface RstestConfig {
|
|
|
368
368
|
* @default 5000
|
|
369
369
|
*/
|
|
370
370
|
testTimeout?: number;
|
|
371
|
+
/**
|
|
372
|
+
* Timeout of hook in milliseconds.
|
|
373
|
+
* @default 10000
|
|
374
|
+
*/
|
|
375
|
+
hookTimeout?: number;
|
|
371
376
|
/**
|
|
372
377
|
* Automatically clear mock calls, instances, contexts and results before every test.
|
|
373
378
|
* @default false
|
|
@@ -457,7 +462,7 @@ declare const runInPool: (options: RunWorkerOptions["options"]) => Promise<{
|
|
|
457
462
|
} | TestFileResult>;
|
|
458
463
|
export default runInPool;
|
|
459
464
|
|
|
460
|
-
declare type RuntimeConfig = Pick<RstestContext['normalizedConfig'], 'testTimeout' | 'testNamePattern' | 'globals' | 'passWithNoTests' | 'retry' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'unstubEnvs' | 'unstubGlobals' | 'maxConcurrency' | 'printConsoleTrace' | 'disableConsoleIntercept' | 'testEnvironment' | 'isolate'>;
|
|
465
|
+
declare type RuntimeConfig = Pick<RstestContext['normalizedConfig'], 'testTimeout' | 'testNamePattern' | 'globals' | 'passWithNoTests' | 'retry' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'unstubEnvs' | 'unstubGlobals' | 'maxConcurrency' | 'printConsoleTrace' | 'disableConsoleIntercept' | 'testEnvironment' | 'isolate' | 'hookTimeout'>;
|
|
461
466
|
|
|
462
467
|
/** Runtime to Server */
|
|
463
468
|
declare type RuntimeRPC = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rstest/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "The Rsbuild-based test tool.",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rstest/issues"
|
|
@@ -48,29 +48,30 @@
|
|
|
48
48
|
"importMeta.d.ts"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@rsbuild/core": "1.4.
|
|
51
|
+
"@rsbuild/core": "1.4.6",
|
|
52
52
|
"@types/chai": "^5.2.2",
|
|
53
53
|
"@vitest/expect": "^3.2.4",
|
|
54
54
|
"@vitest/snapshot": "^3.2.4",
|
|
55
55
|
"birpc": "2.4.0",
|
|
56
|
-
"chai": "^5.2.
|
|
56
|
+
"chai": "^5.2.1",
|
|
57
57
|
"pathe": "^2.0.3",
|
|
58
58
|
"std-env": "^3.9.0",
|
|
59
59
|
"tinypool": "^1.1.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@sinonjs/fake-timers": "^14.0.0",
|
|
63
62
|
"@babel/code-frame": "^7.27.1",
|
|
64
63
|
"@jridgewell/trace-mapping": "0.3.29",
|
|
65
64
|
"@microsoft/api-extractor": "^7.52.8",
|
|
66
|
-
"@rslib/core": "0.10.
|
|
65
|
+
"@rslib/core": "0.10.5",
|
|
66
|
+
"@sinonjs/fake-timers": "^14.0.0",
|
|
67
67
|
"@types/babel__code-frame": "^7.0.6",
|
|
68
|
-
"@types/sinonjs__fake-timers": "^8.1.5",
|
|
69
68
|
"@types/jsdom": "^21.1.7",
|
|
70
|
-
"
|
|
69
|
+
"@types/sinonjs__fake-timers": "^8.1.5",
|
|
71
70
|
"@types/source-map-support": "^0.5.10",
|
|
72
71
|
"cac": "^6.7.14",
|
|
73
|
-
"
|
|
72
|
+
"happy-dom": "^18.0.1",
|
|
73
|
+
"jest-diff": "^30.0.4",
|
|
74
|
+
"jsdom": "^26.1.0",
|
|
74
75
|
"license-webpack-plugin": "^4.0.2",
|
|
75
76
|
"picocolors": "^1.1.1",
|
|
76
77
|
"rslog": "^1.2.9",
|
|
@@ -81,9 +82,13 @@
|
|
|
81
82
|
"@rstest/tsconfig": "0.0.1"
|
|
82
83
|
},
|
|
83
84
|
"peerDependencies": {
|
|
85
|
+
"happy-dom": "*",
|
|
84
86
|
"jsdom": "*"
|
|
85
87
|
},
|
|
86
88
|
"peerDependenciesMeta": {
|
|
89
|
+
"happy-dom": {
|
|
90
|
+
"optional": true
|
|
91
|
+
},
|
|
87
92
|
"jsdom": {
|
|
88
93
|
"optional": true
|
|
89
94
|
}
|