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