@rstest/core 0.0.5 → 0.0.6
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 +9 -2
- package/dist/867.js +9 -6
- package/dist/{202.js → 965.js} +43 -33
- package/dist/cli.js +22 -13
- package/dist/worker.js +42 -19
- package/dist-types/node.d.ts +6 -1
- package/dist-types/public.d.ts +6 -1
- package/dist-types/worker.d.ts +7 -2
- package/package.json +9 -4
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.6",
|
|
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: {
|
|
@@ -595,10 +601,11 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
|
|
|
595
601
|
}
|
|
596
602
|
});
|
|
597
603
|
const { updateSnapshot } = context.snapshotManager.options;
|
|
598
|
-
const { testNamePattern, testTimeout, passWithNoTests, retry, globals, clearMocks, resetMocks, restoreMocks, unstubEnvs, unstubGlobals, maxConcurrency, printConsoleTrace, disableConsoleIntercept, testEnvironment } = context.normalizedConfig;
|
|
604
|
+
const { testNamePattern, testTimeout, passWithNoTests, retry, globals, clearMocks, resetMocks, restoreMocks, unstubEnvs, unstubGlobals, maxConcurrency, printConsoleTrace, disableConsoleIntercept, testEnvironment, hookTimeout } = context.normalizedConfig;
|
|
599
605
|
const runtimeConfig = {
|
|
600
606
|
testNamePattern,
|
|
601
607
|
testTimeout,
|
|
608
|
+
hookTimeout,
|
|
602
609
|
passWithNoTests,
|
|
603
610
|
retry,
|
|
604
611
|
globals,
|
package/dist/867.js
CHANGED
|
@@ -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 {
|
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
|
@@ -2238,6 +2238,7 @@ var __webpack_modules__ = {
|
|
|
2238
2238
|
passWithNoTests: false,
|
|
2239
2239
|
update: false,
|
|
2240
2240
|
testTimeout: 5000,
|
|
2241
|
+
hookTimeout: 10000,
|
|
2241
2242
|
testEnvironment: 'node',
|
|
2242
2243
|
retry: 0,
|
|
2243
2244
|
reporters: [
|
|
@@ -2332,18 +2333,23 @@ var __webpack_modules__ = {
|
|
|
2332
2333
|
}
|
|
2333
2334
|
return String(error);
|
|
2334
2335
|
}
|
|
2335
|
-
const prettyTime = (milliseconds
|
|
2336
|
-
|
|
2337
|
-
const indent = shouldFormat ? ' ' : '';
|
|
2338
|
-
if (milliseconds < 1000) return `${Math.round(milliseconds)}${indent}ms`;
|
|
2336
|
+
const prettyTime = (milliseconds)=>{
|
|
2337
|
+
if (milliseconds < 1000) return `${Math.round(milliseconds)}ms`;
|
|
2339
2338
|
const seconds = milliseconds / 1000;
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2339
|
+
const getSecond = (seconds, needDigits)=>{
|
|
2340
|
+
if (!needDigits || seconds === Math.ceil(seconds)) return `${Math.round(seconds).toString()}s`;
|
|
2341
|
+
const digits = seconds < 10 ? seconds >= 0.01 ? 2 : 3 : 1;
|
|
2342
|
+
return `${seconds.toFixed(digits)}s`;
|
|
2343
|
+
};
|
|
2344
|
+
const minutes = Math.floor(seconds / 60);
|
|
2345
|
+
const secondsRemainder = seconds % 60;
|
|
2346
|
+
let time = '';
|
|
2347
|
+
if (minutes > 0) time += `${minutes}m`;
|
|
2348
|
+
if (secondsRemainder > 0) {
|
|
2349
|
+
if (minutes > 0) time += ' ';
|
|
2350
|
+
time += getSecond(secondsRemainder, !minutes);
|
|
2343
2351
|
}
|
|
2344
|
-
|
|
2345
|
-
const minutes = seconds / 60;
|
|
2346
|
-
return `${format(minutes.toFixed(2))}${indent}m`;
|
|
2352
|
+
return time;
|
|
2347
2353
|
};
|
|
2348
2354
|
const getTaskNames = (test)=>(test.parentNames || []).concat(test.name).filter(Boolean);
|
|
2349
2355
|
const getTaskNameWithPrefix = (test, delimiter = _constants__WEBPACK_IMPORTED_MODULE_1__.Qd)=>getTaskNames(test).join(` ${delimiter} `);
|
|
@@ -3665,13 +3671,13 @@ function prepareCli() {
|
|
|
3665
3671
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
3666
3672
|
}
|
|
3667
3673
|
function showRstest() {
|
|
3668
|
-
logger.k.greet(" Rstest v0.0.
|
|
3674
|
+
logger.k.greet(" Rstest v0.0.6");
|
|
3669
3675
|
logger.k.log('');
|
|
3670
3676
|
}
|
|
3671
3677
|
const applyCommonOptions = (cli)=>{
|
|
3672
3678
|
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
3679
|
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');
|
|
3680
|
+
}).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
3681
|
};
|
|
3676
3682
|
async function initCli(options) {
|
|
3677
3683
|
const cwd = process.cwd();
|
|
@@ -3684,10 +3690,12 @@ async function initCli(options) {
|
|
|
3684
3690
|
const keys = [
|
|
3685
3691
|
'root',
|
|
3686
3692
|
'globals',
|
|
3693
|
+
'isolate',
|
|
3687
3694
|
'passWithNoTests',
|
|
3688
3695
|
'update',
|
|
3689
3696
|
'testNamePattern',
|
|
3690
3697
|
'testTimeout',
|
|
3698
|
+
'hookTimeout',
|
|
3691
3699
|
'clearMocks',
|
|
3692
3700
|
'resetMocks',
|
|
3693
3701
|
'restoreMocks',
|
|
@@ -3701,6 +3709,7 @@ async function initCli(options) {
|
|
|
3701
3709
|
'testEnvironment'
|
|
3702
3710
|
];
|
|
3703
3711
|
for (const key of keys)if (void 0 !== options[key]) config[key] = options[key];
|
|
3712
|
+
if (options.exclude) config.exclude = (0, helper.XQ)(options.exclude);
|
|
3704
3713
|
return {
|
|
3705
3714
|
config,
|
|
3706
3715
|
configFilePath
|
|
@@ -3709,7 +3718,7 @@ async function initCli(options) {
|
|
|
3709
3718
|
function setupCommands() {
|
|
3710
3719
|
const cli = dist('rstest');
|
|
3711
3720
|
cli.help();
|
|
3712
|
-
cli.version("0.0.
|
|
3721
|
+
cli.version("0.0.6");
|
|
3713
3722
|
applyCommonOptions(cli);
|
|
3714
3723
|
cli.command('[...filters]', 'run tests').action(async (filters, options)=>{
|
|
3715
3724
|
showRstest();
|
package/dist/worker.js
CHANGED
|
@@ -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} `);
|
|
@@ -5768,6 +5773,8 @@ const getGlobalApi = (api)=>constants.io.reduce((apis, key)=>{
|
|
|
5768
5773
|
apis[key] = api[key];
|
|
5769
5774
|
return apis;
|
|
5770
5775
|
}, {});
|
|
5776
|
+
const listeners = [];
|
|
5777
|
+
let isTeardown = false;
|
|
5771
5778
|
const preparePool = async ({ entryInfo: { distPath, testPath }, sourceMaps, updateSnapshot, context })=>{
|
|
5772
5779
|
context.runtimeConfig = (0, helper.PQ)(context.runtimeConfig);
|
|
5773
5780
|
const cleanupFns = [];
|
|
@@ -5806,25 +5813,36 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, sourceMaps, upda
|
|
|
5806
5813
|
return null;
|
|
5807
5814
|
}
|
|
5808
5815
|
});
|
|
5816
|
+
listeners.forEach((fn)=>fn());
|
|
5817
|
+
listeners.length = 0;
|
|
5809
5818
|
const unhandledErrors = [];
|
|
5810
5819
|
const handleError = (e, type)=>{
|
|
5811
5820
|
e.name = type;
|
|
5812
|
-
|
|
5813
|
-
|
|
5821
|
+
if (isTeardown) {
|
|
5822
|
+
e.stack = `${helper.$_.yellow('Caught error after test environment was torn down:')}\n\n${e.stack}`;
|
|
5823
|
+
console.error(e);
|
|
5824
|
+
} else {
|
|
5825
|
+
console.error(e);
|
|
5826
|
+
unhandledErrors.push(e);
|
|
5827
|
+
}
|
|
5814
5828
|
};
|
|
5815
5829
|
const uncaughtException = (e)=>handleError(e, 'uncaughtException');
|
|
5816
5830
|
const unhandledRejection = (e)=>handleError(e, 'unhandledRejection');
|
|
5817
5831
|
process.on('uncaughtException', uncaughtException);
|
|
5818
5832
|
process.on('unhandledRejection', unhandledRejection);
|
|
5819
|
-
|
|
5833
|
+
listeners.push(()=>{
|
|
5820
5834
|
process.off('uncaughtException', uncaughtException);
|
|
5821
5835
|
process.off('unhandledRejection', unhandledRejection);
|
|
5822
5836
|
});
|
|
5823
5837
|
const { api, runner } = createRstestRuntime(workerState);
|
|
5824
5838
|
if ('jsdom' === testEnvironment) {
|
|
5825
|
-
const { environment } = await __webpack_require__.e("
|
|
5839
|
+
const { environment } = await __webpack_require__.e("965").then(__webpack_require__.bind(__webpack_require__, "./src/runtime/worker/env/jsdom.ts"));
|
|
5826
5840
|
const { teardown } = await environment.setup(global, {});
|
|
5827
5841
|
cleanupFns.push(()=>teardown(global));
|
|
5842
|
+
} else if ('happy-dom' === testEnvironment) {
|
|
5843
|
+
const { environment } = await __webpack_require__.e("44").then(__webpack_require__.bind(__webpack_require__, "./src/runtime/worker/env/happyDom.ts"));
|
|
5844
|
+
const { teardown } = await environment.setup(global, {});
|
|
5845
|
+
cleanupFns.push(async ()=>await teardown(global));
|
|
5828
5846
|
}
|
|
5829
5847
|
const rstestContext = {
|
|
5830
5848
|
global,
|
|
@@ -5877,8 +5895,16 @@ const loadFiles = async ({ setupEntries, assetFiles, rstestContext, distPath, te
|
|
|
5877
5895
|
});
|
|
5878
5896
|
};
|
|
5879
5897
|
const runInPool = async (options)=>{
|
|
5898
|
+
isTeardown = false;
|
|
5880
5899
|
const { entryInfo: { distPath, testPath }, setupEntries, assetFiles, type, context: { runtimeConfig: { isolate } } } = options;
|
|
5881
5900
|
const cleanups = [];
|
|
5901
|
+
const exit = process.exit;
|
|
5902
|
+
process.exit = (code = process.exitCode || 0)=>{
|
|
5903
|
+
throw new Error(`process.exit unexpectedly called with "${code}"`);
|
|
5904
|
+
};
|
|
5905
|
+
cleanups.push(()=>{
|
|
5906
|
+
process.exit = exit;
|
|
5907
|
+
});
|
|
5882
5908
|
if ('collect' === type) try {
|
|
5883
5909
|
const { rstestContext, runner, cleanup, unhandledErrors, interopDefault } = await preparePool(options);
|
|
5884
5910
|
cleanups.push(cleanup);
|
|
@@ -5905,12 +5931,9 @@ const runInPool = async (options)=>{
|
|
|
5905
5931
|
};
|
|
5906
5932
|
} finally{
|
|
5907
5933
|
await Promise.all(cleanups.map((fn)=>fn()));
|
|
5934
|
+
isTeardown = true;
|
|
5908
5935
|
}
|
|
5909
|
-
const exit = process.exit;
|
|
5910
5936
|
try {
|
|
5911
|
-
process.exit = (code = process.exitCode || 0)=>{
|
|
5912
|
-
throw new Error(`process.exit unexpectedly called with "${code}"`);
|
|
5913
|
-
};
|
|
5914
5937
|
const { rstestContext, runner, rpc, api, cleanup, unhandledErrors, interopDefault } = await preparePool(options);
|
|
5915
5938
|
cleanups.push(cleanup);
|
|
5916
5939
|
await loadFiles({
|
|
@@ -5948,7 +5971,7 @@ const runInPool = async (options)=>{
|
|
|
5948
5971
|
};
|
|
5949
5972
|
} finally{
|
|
5950
5973
|
await Promise.all(cleanups.map((fn)=>fn()));
|
|
5951
|
-
|
|
5974
|
+
isTeardown = true;
|
|
5952
5975
|
}
|
|
5953
5976
|
};
|
|
5954
5977
|
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
|
@@ -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.6",
|
|
4
4
|
"description": "The Rsbuild-based test tool.",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rstest/issues"
|
|
@@ -59,18 +59,19 @@
|
|
|
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
65
|
"@rslib/core": "0.10.4",
|
|
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",
|
|
72
|
+
"happy-dom": "^18.0.1",
|
|
73
73
|
"jest-diff": "^30.0.3",
|
|
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
|
}
|