@rstest/core 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +658 -0
- package/dist/202.js +365 -0
- package/dist/353.js +1 -1
- package/dist/81.js +1467 -0
- package/dist/813.js +5 -3
- package/dist/{773.js → 867.js} +189 -163
- package/dist/973.js +0 -72
- package/dist/992.js +27 -13
- package/dist/cli.js +138 -122
- package/dist/worker.js +326 -168
- package/dist-types/node.d.ts +1 -2
- package/dist-types/public.d.ts +95 -3
- package/dist-types/worker.d.ts +1 -2
- package/package.json +30 -11
package/dist/202.js
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
export const __webpack_ids__ = [
|
|
2
|
+
"202"
|
|
3
|
+
];
|
|
4
|
+
export const __webpack_modules__ = {
|
|
5
|
+
"./src/runtime/worker/env/jsdom.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
7
|
+
environment: ()=>environment
|
|
8
|
+
});
|
|
9
|
+
const LIVING_KEYS = [
|
|
10
|
+
'DOMException',
|
|
11
|
+
'URL',
|
|
12
|
+
'URLSearchParams',
|
|
13
|
+
'EventTarget',
|
|
14
|
+
'NamedNodeMap',
|
|
15
|
+
'Node',
|
|
16
|
+
'Attr',
|
|
17
|
+
'Element',
|
|
18
|
+
'DocumentFragment',
|
|
19
|
+
'DOMImplementation',
|
|
20
|
+
'Document',
|
|
21
|
+
'XMLDocument',
|
|
22
|
+
'CharacterData',
|
|
23
|
+
'Text',
|
|
24
|
+
'CDATASection',
|
|
25
|
+
'ProcessingInstruction',
|
|
26
|
+
'Comment',
|
|
27
|
+
'DocumentType',
|
|
28
|
+
'NodeList',
|
|
29
|
+
'RadioNodeList',
|
|
30
|
+
'HTMLCollection',
|
|
31
|
+
'HTMLOptionsCollection',
|
|
32
|
+
'DOMStringMap',
|
|
33
|
+
'DOMTokenList',
|
|
34
|
+
'StyleSheetList',
|
|
35
|
+
'HTMLElement',
|
|
36
|
+
'HTMLHeadElement',
|
|
37
|
+
'HTMLTitleElement',
|
|
38
|
+
'HTMLBaseElement',
|
|
39
|
+
'HTMLLinkElement',
|
|
40
|
+
'HTMLMetaElement',
|
|
41
|
+
'HTMLStyleElement',
|
|
42
|
+
'HTMLBodyElement',
|
|
43
|
+
'HTMLHeadingElement',
|
|
44
|
+
'HTMLParagraphElement',
|
|
45
|
+
'HTMLHRElement',
|
|
46
|
+
'HTMLPreElement',
|
|
47
|
+
'HTMLUListElement',
|
|
48
|
+
'HTMLOListElement',
|
|
49
|
+
'HTMLLIElement',
|
|
50
|
+
'HTMLMenuElement',
|
|
51
|
+
'HTMLDListElement',
|
|
52
|
+
'HTMLDivElement',
|
|
53
|
+
'HTMLAnchorElement',
|
|
54
|
+
'HTMLAreaElement',
|
|
55
|
+
'HTMLBRElement',
|
|
56
|
+
'HTMLButtonElement',
|
|
57
|
+
'HTMLCanvasElement',
|
|
58
|
+
'HTMLDataElement',
|
|
59
|
+
'HTMLDataListElement',
|
|
60
|
+
'HTMLDetailsElement',
|
|
61
|
+
'HTMLDialogElement',
|
|
62
|
+
'HTMLDirectoryElement',
|
|
63
|
+
'HTMLFieldSetElement',
|
|
64
|
+
'HTMLFontElement',
|
|
65
|
+
'HTMLFormElement',
|
|
66
|
+
'HTMLHtmlElement',
|
|
67
|
+
'HTMLImageElement',
|
|
68
|
+
'HTMLInputElement',
|
|
69
|
+
'HTMLLabelElement',
|
|
70
|
+
'HTMLLegendElement',
|
|
71
|
+
'HTMLMapElement',
|
|
72
|
+
'HTMLMarqueeElement',
|
|
73
|
+
'HTMLMediaElement',
|
|
74
|
+
'HTMLMeterElement',
|
|
75
|
+
'HTMLModElement',
|
|
76
|
+
'HTMLOptGroupElement',
|
|
77
|
+
'HTMLOptionElement',
|
|
78
|
+
'HTMLOutputElement',
|
|
79
|
+
'HTMLPictureElement',
|
|
80
|
+
'HTMLProgressElement',
|
|
81
|
+
'HTMLQuoteElement',
|
|
82
|
+
'HTMLScriptElement',
|
|
83
|
+
'HTMLSelectElement',
|
|
84
|
+
'HTMLSlotElement',
|
|
85
|
+
'HTMLSourceElement',
|
|
86
|
+
'HTMLSpanElement',
|
|
87
|
+
'HTMLTableCaptionElement',
|
|
88
|
+
'HTMLTableCellElement',
|
|
89
|
+
'HTMLTableColElement',
|
|
90
|
+
'HTMLTableElement',
|
|
91
|
+
'HTMLTimeElement',
|
|
92
|
+
'HTMLTableRowElement',
|
|
93
|
+
'HTMLTableSectionElement',
|
|
94
|
+
'HTMLTemplateElement',
|
|
95
|
+
'HTMLTextAreaElement',
|
|
96
|
+
'HTMLUnknownElement',
|
|
97
|
+
'HTMLFrameElement',
|
|
98
|
+
'HTMLFrameSetElement',
|
|
99
|
+
'HTMLIFrameElement',
|
|
100
|
+
'HTMLEmbedElement',
|
|
101
|
+
'HTMLObjectElement',
|
|
102
|
+
'HTMLParamElement',
|
|
103
|
+
'HTMLVideoElement',
|
|
104
|
+
'HTMLAudioElement',
|
|
105
|
+
'HTMLTrackElement',
|
|
106
|
+
'HTMLFormControlsCollection',
|
|
107
|
+
'SVGElement',
|
|
108
|
+
'SVGGraphicsElement',
|
|
109
|
+
'SVGSVGElement',
|
|
110
|
+
'SVGGElement',
|
|
111
|
+
'SVGDefsElement',
|
|
112
|
+
'SVGDescElement',
|
|
113
|
+
'SVGMetadataElement',
|
|
114
|
+
'SVGTitleElement',
|
|
115
|
+
'SVGSymbolElement',
|
|
116
|
+
'SVGSwitchElement',
|
|
117
|
+
'SVGAnimatedPreserveAspectRatio',
|
|
118
|
+
'SVGAnimatedRect',
|
|
119
|
+
'SVGAnimatedString',
|
|
120
|
+
'SVGNumber',
|
|
121
|
+
'SVGPreserveAspectRatio',
|
|
122
|
+
'SVGRect',
|
|
123
|
+
'SVGStringList',
|
|
124
|
+
'Event',
|
|
125
|
+
'BeforeUnloadEvent',
|
|
126
|
+
'BlobEvent',
|
|
127
|
+
'CloseEvent',
|
|
128
|
+
'CustomEvent',
|
|
129
|
+
'MessageEvent',
|
|
130
|
+
'ErrorEvent',
|
|
131
|
+
'HashChangeEvent',
|
|
132
|
+
'PopStateEvent',
|
|
133
|
+
'StorageEvent',
|
|
134
|
+
'ProgressEvent',
|
|
135
|
+
'PageTransitionEvent',
|
|
136
|
+
'SubmitEvent',
|
|
137
|
+
'UIEvent',
|
|
138
|
+
'FocusEvent',
|
|
139
|
+
'InputEvent',
|
|
140
|
+
'MouseEvent',
|
|
141
|
+
'KeyboardEvent',
|
|
142
|
+
'TouchEvent',
|
|
143
|
+
'CompositionEvent',
|
|
144
|
+
'WheelEvent',
|
|
145
|
+
'BarProp',
|
|
146
|
+
'External',
|
|
147
|
+
'Location',
|
|
148
|
+
'History',
|
|
149
|
+
'Screen',
|
|
150
|
+
'Performance',
|
|
151
|
+
'Navigator',
|
|
152
|
+
'Crypto',
|
|
153
|
+
'PluginArray',
|
|
154
|
+
'MimeTypeArray',
|
|
155
|
+
'Plugin',
|
|
156
|
+
'MimeType',
|
|
157
|
+
'FileReader',
|
|
158
|
+
'Blob',
|
|
159
|
+
'File',
|
|
160
|
+
'FileList',
|
|
161
|
+
'ValidityState',
|
|
162
|
+
'DOMParser',
|
|
163
|
+
'XMLSerializer',
|
|
164
|
+
'FormData',
|
|
165
|
+
'XMLHttpRequestEventTarget',
|
|
166
|
+
'XMLHttpRequestUpload',
|
|
167
|
+
'XMLHttpRequest',
|
|
168
|
+
'WebSocket',
|
|
169
|
+
'NodeFilter',
|
|
170
|
+
'NodeIterator',
|
|
171
|
+
'TreeWalker',
|
|
172
|
+
'AbstractRange',
|
|
173
|
+
'Range',
|
|
174
|
+
'StaticRange',
|
|
175
|
+
'Selection',
|
|
176
|
+
'Storage',
|
|
177
|
+
'CustomElementRegistry',
|
|
178
|
+
'ElementInternals',
|
|
179
|
+
'ShadowRoot',
|
|
180
|
+
'MutationObserver',
|
|
181
|
+
'MutationRecord',
|
|
182
|
+
'Headers',
|
|
183
|
+
'AbortController',
|
|
184
|
+
'AbortSignal',
|
|
185
|
+
'Uint8Array',
|
|
186
|
+
'Uint16Array',
|
|
187
|
+
'Uint32Array',
|
|
188
|
+
'Uint8ClampedArray',
|
|
189
|
+
'Int8Array',
|
|
190
|
+
'Int16Array',
|
|
191
|
+
'Int32Array',
|
|
192
|
+
'Float32Array',
|
|
193
|
+
'Float64Array',
|
|
194
|
+
'ArrayBuffer',
|
|
195
|
+
'DeviceMotionEventAcceleration',
|
|
196
|
+
'DeviceMotionEventRotationRate',
|
|
197
|
+
'DOMRectReadOnly',
|
|
198
|
+
'DOMRect',
|
|
199
|
+
'Image',
|
|
200
|
+
'Audio',
|
|
201
|
+
'Option',
|
|
202
|
+
'CSS'
|
|
203
|
+
];
|
|
204
|
+
const OTHER_KEYS = [
|
|
205
|
+
'addEventListener',
|
|
206
|
+
'alert',
|
|
207
|
+
'blur',
|
|
208
|
+
'cancelAnimationFrame',
|
|
209
|
+
'close',
|
|
210
|
+
'confirm',
|
|
211
|
+
'createPopup',
|
|
212
|
+
'dispatchEvent',
|
|
213
|
+
'document',
|
|
214
|
+
'focus',
|
|
215
|
+
'frames',
|
|
216
|
+
'getComputedStyle',
|
|
217
|
+
'history',
|
|
218
|
+
'innerHeight',
|
|
219
|
+
'innerWidth',
|
|
220
|
+
'length',
|
|
221
|
+
'location',
|
|
222
|
+
'matchMedia',
|
|
223
|
+
'moveBy',
|
|
224
|
+
'moveTo',
|
|
225
|
+
'name',
|
|
226
|
+
'navigator',
|
|
227
|
+
'open',
|
|
228
|
+
'outerHeight',
|
|
229
|
+
'outerWidth',
|
|
230
|
+
'pageXOffset',
|
|
231
|
+
'pageYOffset',
|
|
232
|
+
'parent',
|
|
233
|
+
'postMessage',
|
|
234
|
+
'print',
|
|
235
|
+
'prompt',
|
|
236
|
+
'removeEventListener',
|
|
237
|
+
'requestAnimationFrame',
|
|
238
|
+
'resizeBy',
|
|
239
|
+
'resizeTo',
|
|
240
|
+
'screen',
|
|
241
|
+
'screenLeft',
|
|
242
|
+
'screenTop',
|
|
243
|
+
'screenX',
|
|
244
|
+
'screenY',
|
|
245
|
+
'scroll',
|
|
246
|
+
'scrollBy',
|
|
247
|
+
'scrollLeft',
|
|
248
|
+
'scrollTo',
|
|
249
|
+
'scrollTop',
|
|
250
|
+
'scrollX',
|
|
251
|
+
'scrollY',
|
|
252
|
+
'self',
|
|
253
|
+
'stop',
|
|
254
|
+
'top',
|
|
255
|
+
'Window',
|
|
256
|
+
'window'
|
|
257
|
+
];
|
|
258
|
+
const KEYS = LIVING_KEYS.concat(OTHER_KEYS);
|
|
259
|
+
const SKIP_KEYS = [
|
|
260
|
+
'window',
|
|
261
|
+
'self',
|
|
262
|
+
'top',
|
|
263
|
+
'parent'
|
|
264
|
+
];
|
|
265
|
+
function getWindowKeys(global, win, additionalKeys = []) {
|
|
266
|
+
const keysArray = [
|
|
267
|
+
...additionalKeys,
|
|
268
|
+
...KEYS
|
|
269
|
+
];
|
|
270
|
+
return new Set(keysArray.concat(Object.getOwnPropertyNames(win)).filter((k)=>{
|
|
271
|
+
if (SKIP_KEYS.includes(k)) return false;
|
|
272
|
+
if (k in global) return keysArray.includes(k);
|
|
273
|
+
return true;
|
|
274
|
+
}));
|
|
275
|
+
}
|
|
276
|
+
function installGlobal(global, win, options = {}) {
|
|
277
|
+
const keys = getWindowKeys(global, win, options.additionalKeys);
|
|
278
|
+
const isClassLike = (name)=>name[0] === name[0]?.toUpperCase();
|
|
279
|
+
const originals = new Map();
|
|
280
|
+
const overrides = new Map();
|
|
281
|
+
for (const key of keys){
|
|
282
|
+
const boundFunction = 'function' != typeof win[key] || isClassLike(key) ? void 0 : win[key].bind(win);
|
|
283
|
+
if (key in global) originals.set(key, global[key]);
|
|
284
|
+
Object.defineProperty(global, key, {
|
|
285
|
+
get () {
|
|
286
|
+
if (overrides.has(key)) return overrides.get(key);
|
|
287
|
+
if (boundFunction) return boundFunction;
|
|
288
|
+
return win[key];
|
|
289
|
+
},
|
|
290
|
+
set (v) {
|
|
291
|
+
overrides.set(key, v);
|
|
292
|
+
},
|
|
293
|
+
configurable: true
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
global.window = global;
|
|
297
|
+
global.self = global;
|
|
298
|
+
global.top = global;
|
|
299
|
+
global.parent = global;
|
|
300
|
+
if (global.global) global.global = global;
|
|
301
|
+
if (global.document?.defaultView) Object.defineProperty(global.document, 'defaultView', {
|
|
302
|
+
get: ()=>global,
|
|
303
|
+
enumerable: true,
|
|
304
|
+
configurable: true
|
|
305
|
+
});
|
|
306
|
+
for (const k of SKIP_KEYS)keys.add(k);
|
|
307
|
+
return ()=>{
|
|
308
|
+
for (const key of keys)delete global[key];
|
|
309
|
+
originals.forEach((v, k)=>{
|
|
310
|
+
global[k] = v;
|
|
311
|
+
});
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function addDefaultErrorHandler(window) {
|
|
315
|
+
let userErrorListenerCount = 0;
|
|
316
|
+
const throwUnhandledError = (e)=>{
|
|
317
|
+
if (0 === userErrorListenerCount && null != e.error) process.emit('uncaughtException', e.error);
|
|
318
|
+
};
|
|
319
|
+
const addEventListener = window.addEventListener.bind(window);
|
|
320
|
+
const removeEventListener = window.removeEventListener.bind(window);
|
|
321
|
+
window.addEventListener('error', throwUnhandledError);
|
|
322
|
+
window.addEventListener = function(...args) {
|
|
323
|
+
if ('error' === args[0]) userErrorListenerCount++;
|
|
324
|
+
return addEventListener.apply(this, args);
|
|
325
|
+
};
|
|
326
|
+
window.removeEventListener = function(...args) {
|
|
327
|
+
if ('error' === args[0] && userErrorListenerCount) userErrorListenerCount--;
|
|
328
|
+
return removeEventListener.apply(this, args);
|
|
329
|
+
};
|
|
330
|
+
return ()=>{
|
|
331
|
+
window.removeEventListener('error', throwUnhandledError);
|
|
332
|
+
};
|
|
333
|
+
}
|
|
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
|
+
}
|
|
365
|
+
};
|