vitest 2.0.0-beta.9 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -22
- package/dist/browser.d.ts +24 -7
- package/dist/browser.js +5 -19
- package/dist/chunks/browser-creator.DSqYDthP.js +673 -0
- package/dist/chunks/{environments-node.39w4gmlF.js → environments-node.XE5FbRPQ.js} +1 -1
- package/dist/chunks/{integrations-globals.BK0Cn4q1.js → integrations-globals.CzYWb38r.js} +10 -9
- package/dist/chunks/{node-git.CCI8evVZ.js → node-git.ZtkbKc8u.js} +14 -15
- package/dist/chunks/{runtime-console.DiVMr5d4.js → runtime-console.O41g23Zj.js} +26 -11
- package/dist/chunks/{runtime-runBaseTests.C-Bkopka.js → runtime-runBaseTests.DX3h28Mp.js} +47 -34
- package/dist/cli.js +3 -3
- package/dist/config.cjs +48 -23
- package/dist/config.d.ts +2 -1
- package/dist/config.js +48 -24
- package/dist/coverage.d.ts +6 -4
- package/dist/coverage.js +102 -38
- package/dist/environments.d.ts +2 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +4 -3
- package/dist/execute.js +2 -2
- package/dist/index.d.ts +1437 -7
- package/dist/index.js +10 -9
- package/dist/node.d.ts +34 -7
- package/dist/node.js +31 -20
- package/dist/path.js +4 -1
- package/dist/{reporters-DaDey3o0.d.ts → reporters-BU_vXAUX.d.ts} +216 -206
- package/dist/reporters.d.ts +2 -1
- package/dist/reporters.js +8 -8
- package/dist/runners.d.ts +3 -1
- package/dist/runners.js +100 -61
- package/dist/snapshot.js +2 -2
- package/dist/{suite-BHSUxUib.d.ts → suite-BRl_IYuM.d.ts} +1 -1
- package/dist/suite.d.ts +3 -2
- package/dist/suite.js +3 -3
- package/dist/utils.d.ts +1 -5
- package/dist/utils.js +1 -6
- package/dist/vendor/{base._gnK9Slw.js → base.CTYV4Gnz.js} +24 -17
- package/dist/vendor/{base.D4XK-wRp.js → base.CdA1i5tB.js} +6 -4
- package/dist/vendor/{benchmark.BNLebNi5.js → benchmark.B6pblCp2.js} +13 -14
- package/dist/vendor/{cac.DCg3FnEs.js → cac.BQc6bsef.js} +142 -47
- package/dist/vendor/{cli-api.LMvYagQ5.js → cli-api.BGRtK_Kj.js} +4189 -9537
- package/dist/vendor/{constants.TCjCaw2D.js → constants.CsnA4eRy.js} +5 -23
- package/dist/vendor/{coverage.ChSqD-qS.js → coverage.BhYSDdTT.js} +27 -11
- package/dist/vendor/{date.BKM1wewY.js → date.W2xKR2qe.js} +5 -3
- package/dist/vendor/env.2ltrQNq0.js +8 -0
- package/dist/vendor/{execute.BHj6OMh4.js → execute.Dx503nGn.js} +186 -64
- package/dist/vendor/{index.TBU3GqRP.js → index.3x3MdmUV.js} +1075 -526
- package/dist/vendor/{index._7XLd8Kd.js → index.BJmtb_7W.js} +3 -2
- package/dist/vendor/{index.DP-km6lF.js → index.BMmMjLIQ.js} +64 -51
- package/dist/vendor/{index.DHRpy7zp.js → index.CROIsoiT.js} +18 -10
- package/dist/vendor/{index.DeR1hhfY.js → index.D4nqnQWz.js} +71 -74
- package/dist/vendor/index.D6GZqexG.js +6575 -0
- package/dist/vendor/{index.DwR86H5i.js → index.Hqvcg1pf.js} +4 -27
- package/dist/vendor/{rpc.DRDE9Pu1.js → rpc.BGx7q_k2.js} +30 -19
- package/dist/vendor/run-once.Db8Hgq9X.js +28 -0
- package/dist/vendor/{setup-common.BhJvzjns.js → setup-common.yHaxjRhz.js} +30 -15
- package/dist/vendor/spy.Cf_4R5Oe.js +22 -0
- package/dist/vendor/{tasks.WC7M-K-v.js → tasks.DhVtQBtW.js} +3 -1
- package/dist/vendor/{utils.YuQ3LT2a.js → utils.BVMrsl6E.js} +55 -30
- package/dist/vendor/{utils.CUjzkRH7.js → utils.DkxLWvS1.js} +12 -5
- package/dist/vendor/{vi.C6AfDXK6.js → vi.DXACdGTu.js} +269 -136
- package/dist/vendor/{vm.Ow-X2mkS.js → vm.BrDS6p7h.js} +157 -90
- package/dist/worker.js +41 -18
- package/dist/workers/forks.js +12 -6
- package/dist/workers/runVmTests.js +22 -16
- package/dist/workers/threads.js +8 -5
- package/dist/workers/vmForks.js +15 -9
- package/dist/workers/vmThreads.js +11 -8
- package/dist/workers.d.ts +8 -5
- package/dist/workers.js +11 -11
- package/package.json +22 -21
- package/suppress-warnings.cjs +2 -4
- package/dist/index-B0dCycbN.d.ts +0 -1571
- package/dist/vendor/env.bmJgw1qP.js +0 -7
|
@@ -29,10 +29,7 @@ var node = {
|
|
|
29
29
|
async setupVM() {
|
|
30
30
|
const vm = await import('node:vm');
|
|
31
31
|
let context = vm.createContext();
|
|
32
|
-
let global = vm.runInContext(
|
|
33
|
-
"this",
|
|
34
|
-
context
|
|
35
|
-
);
|
|
32
|
+
let global = vm.runInContext("this", context);
|
|
36
33
|
const contextGlobals = new Set(Object.getOwnPropertyNames(global));
|
|
37
34
|
for (const [nodeGlobalsKey, descriptor] of nodeGlobals) {
|
|
38
35
|
if (!contextGlobals.has(nodeGlobalsKey)) {
|
|
@@ -345,21 +342,20 @@ const OTHER_KEYS = [
|
|
|
345
342
|
];
|
|
346
343
|
const KEYS = LIVING_KEYS.concat(OTHER_KEYS);
|
|
347
344
|
|
|
348
|
-
const skipKeys = [
|
|
349
|
-
"window",
|
|
350
|
-
"self",
|
|
351
|
-
"top",
|
|
352
|
-
"parent"
|
|
353
|
-
];
|
|
345
|
+
const skipKeys = ["window", "self", "top", "parent"];
|
|
354
346
|
function getWindowKeys(global, win, additionalKeys = []) {
|
|
355
347
|
const keysArray = [...additionalKeys, ...KEYS];
|
|
356
|
-
const keys = new Set(
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
348
|
+
const keys = new Set(
|
|
349
|
+
keysArray.concat(Object.getOwnPropertyNames(win)).filter((k) => {
|
|
350
|
+
if (skipKeys.includes(k)) {
|
|
351
|
+
return false;
|
|
352
|
+
}
|
|
353
|
+
if (k in global) {
|
|
354
|
+
return keysArray.includes(k);
|
|
355
|
+
}
|
|
356
|
+
return true;
|
|
357
|
+
})
|
|
358
|
+
);
|
|
363
359
|
return keys;
|
|
364
360
|
}
|
|
365
361
|
function isClassLikeName(name) {
|
|
@@ -372,14 +368,17 @@ function populateGlobal(global, win, options = {}) {
|
|
|
372
368
|
const overrideObject = /* @__PURE__ */ new Map();
|
|
373
369
|
for (const key of keys) {
|
|
374
370
|
const boundFunction = bindFunctions && typeof win[key] === "function" && !isClassLikeName(key) && win[key].bind(win);
|
|
375
|
-
if (KEYS.includes(key) && key in global)
|
|
371
|
+
if (KEYS.includes(key) && key in global) {
|
|
376
372
|
originals.set(key, global[key]);
|
|
373
|
+
}
|
|
377
374
|
Object.defineProperty(global, key, {
|
|
378
375
|
get() {
|
|
379
|
-
if (overrideObject.has(key))
|
|
376
|
+
if (overrideObject.has(key)) {
|
|
380
377
|
return overrideObject.get(key);
|
|
381
|
-
|
|
378
|
+
}
|
|
379
|
+
if (boundFunction) {
|
|
382
380
|
return boundFunction;
|
|
381
|
+
}
|
|
383
382
|
return win[key];
|
|
384
383
|
},
|
|
385
384
|
set(v) {
|
|
@@ -392,8 +391,9 @@ function populateGlobal(global, win, options = {}) {
|
|
|
392
391
|
global.self = global;
|
|
393
392
|
global.top = global;
|
|
394
393
|
global.parent = global;
|
|
395
|
-
if (global.global)
|
|
394
|
+
if (global.global) {
|
|
396
395
|
global.global = global;
|
|
396
|
+
}
|
|
397
397
|
if (global.document && global.document.defaultView) {
|
|
398
398
|
Object.defineProperty(global.document, "defaultView", {
|
|
399
399
|
get: () => global,
|
|
@@ -412,20 +412,23 @@ function populateGlobal(global, win, options = {}) {
|
|
|
412
412
|
function catchWindowErrors(window) {
|
|
413
413
|
let userErrorListenerCount = 0;
|
|
414
414
|
function throwUnhandlerError(e) {
|
|
415
|
-
if (userErrorListenerCount === 0 && e.error != null)
|
|
415
|
+
if (userErrorListenerCount === 0 && e.error != null) {
|
|
416
416
|
process.emit("uncaughtException", e.error);
|
|
417
|
+
}
|
|
417
418
|
}
|
|
418
419
|
const addEventListener = window.addEventListener.bind(window);
|
|
419
420
|
const removeEventListener = window.removeEventListener.bind(window);
|
|
420
421
|
window.addEventListener("error", throwUnhandlerError);
|
|
421
422
|
window.addEventListener = function(...args) {
|
|
422
|
-
if (args[0] === "error")
|
|
423
|
+
if (args[0] === "error") {
|
|
423
424
|
userErrorListenerCount++;
|
|
425
|
+
}
|
|
424
426
|
return addEventListener.apply(this, args);
|
|
425
427
|
};
|
|
426
428
|
window.removeEventListener = function(...args) {
|
|
427
|
-
if (args[0] === "error" && userErrorListenerCount)
|
|
429
|
+
if (args[0] === "error" && userErrorListenerCount) {
|
|
428
430
|
userErrorListenerCount--;
|
|
431
|
+
}
|
|
429
432
|
return removeEventListener.apply(this, args);
|
|
430
433
|
};
|
|
431
434
|
return function clearErrorHandlers() {
|
|
@@ -436,12 +439,7 @@ var jsdom = {
|
|
|
436
439
|
name: "jsdom",
|
|
437
440
|
transformMode: "web",
|
|
438
441
|
async setupVM({ jsdom = {} }) {
|
|
439
|
-
const {
|
|
440
|
-
CookieJar,
|
|
441
|
-
JSDOM,
|
|
442
|
-
ResourceLoader,
|
|
443
|
-
VirtualConsole
|
|
444
|
-
} = await import('jsdom');
|
|
442
|
+
const { CookieJar, JSDOM, ResourceLoader, VirtualConsole } = await import('jsdom');
|
|
445
443
|
const {
|
|
446
444
|
html = "<!DOCTYPE html>",
|
|
447
445
|
userAgent,
|
|
@@ -455,21 +453,18 @@ var jsdom = {
|
|
|
455
453
|
cookieJar = false,
|
|
456
454
|
...restOptions
|
|
457
455
|
} = jsdom;
|
|
458
|
-
let dom = new JSDOM(
|
|
459
|
-
|
|
460
|
-
{
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
...restOptions
|
|
471
|
-
}
|
|
472
|
-
);
|
|
456
|
+
let dom = new JSDOM(html, {
|
|
457
|
+
pretendToBeVisual,
|
|
458
|
+
resources: resources ?? (userAgent ? new ResourceLoader({ userAgent }) : void 0),
|
|
459
|
+
runScripts,
|
|
460
|
+
url,
|
|
461
|
+
virtualConsole: console && globalThis.console ? new VirtualConsole().sendTo(globalThis.console) : void 0,
|
|
462
|
+
cookieJar: cookieJar ? new CookieJar() : void 0,
|
|
463
|
+
includeNodeLocations,
|
|
464
|
+
contentType,
|
|
465
|
+
userAgent,
|
|
466
|
+
...restOptions
|
|
467
|
+
});
|
|
473
468
|
const clearWindowErrors = catchWindowErrors(dom.window);
|
|
474
469
|
dom.window.Buffer = Buffer;
|
|
475
470
|
dom.window.jsdom = dom;
|
|
@@ -486,8 +481,9 @@ var jsdom = {
|
|
|
486
481
|
];
|
|
487
482
|
for (const name of globalNames) {
|
|
488
483
|
const value = globalThis[name];
|
|
489
|
-
if (typeof value !== "undefined" && typeof dom.window[name] === "undefined")
|
|
484
|
+
if (typeof value !== "undefined" && typeof dom.window[name] === "undefined") {
|
|
490
485
|
dom.window[name] = value;
|
|
486
|
+
}
|
|
491
487
|
}
|
|
492
488
|
return {
|
|
493
489
|
getVmContext() {
|
|
@@ -501,12 +497,7 @@ var jsdom = {
|
|
|
501
497
|
};
|
|
502
498
|
},
|
|
503
499
|
async setup(global, { jsdom = {} }) {
|
|
504
|
-
const {
|
|
505
|
-
CookieJar,
|
|
506
|
-
JSDOM,
|
|
507
|
-
ResourceLoader,
|
|
508
|
-
VirtualConsole
|
|
509
|
-
} = await import('jsdom');
|
|
500
|
+
const { CookieJar, JSDOM, ResourceLoader, VirtualConsole } = await import('jsdom');
|
|
510
501
|
const {
|
|
511
502
|
html = "<!DOCTYPE html>",
|
|
512
503
|
userAgent,
|
|
@@ -520,22 +511,21 @@ var jsdom = {
|
|
|
520
511
|
cookieJar = false,
|
|
521
512
|
...restOptions
|
|
522
513
|
} = jsdom;
|
|
523
|
-
const dom = new JSDOM(
|
|
524
|
-
|
|
525
|
-
{
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
);
|
|
538
|
-
const { keys, originals } = populateGlobal(global, dom.window, { bindFunctions: true });
|
|
514
|
+
const dom = new JSDOM(html, {
|
|
515
|
+
pretendToBeVisual,
|
|
516
|
+
resources: resources ?? (userAgent ? new ResourceLoader({ userAgent }) : void 0),
|
|
517
|
+
runScripts,
|
|
518
|
+
url,
|
|
519
|
+
virtualConsole: console && global.console ? new VirtualConsole().sendTo(global.console) : void 0,
|
|
520
|
+
cookieJar: cookieJar ? new CookieJar() : void 0,
|
|
521
|
+
includeNodeLocations,
|
|
522
|
+
contentType,
|
|
523
|
+
userAgent,
|
|
524
|
+
...restOptions
|
|
525
|
+
});
|
|
526
|
+
const { keys, originals } = populateGlobal(global, dom.window, {
|
|
527
|
+
bindFunctions: true
|
|
528
|
+
});
|
|
539
529
|
const clearWindowErrors = catchWindowErrors(global);
|
|
540
530
|
global.jsdom = dom;
|
|
541
531
|
return {
|
|
@@ -573,8 +563,9 @@ var happy = {
|
|
|
573
563
|
}
|
|
574
564
|
});
|
|
575
565
|
win.Buffer = Buffer;
|
|
576
|
-
if (typeof structuredClone !== "undefined" && !win.structuredClone)
|
|
566
|
+
if (typeof structuredClone !== "undefined" && !win.structuredClone) {
|
|
577
567
|
win.structuredClone = structuredClone;
|
|
568
|
+
}
|
|
578
569
|
return {
|
|
579
570
|
getVmContext() {
|
|
580
571
|
return win;
|
|
@@ -638,13 +629,16 @@ var edge = {
|
|
|
638
629
|
context.global = context;
|
|
639
630
|
context.Buffer = Buffer;
|
|
640
631
|
KEYS.forEach((key) => {
|
|
641
|
-
if (key in global)
|
|
632
|
+
if (key in global) {
|
|
642
633
|
context[key] = global[key];
|
|
634
|
+
}
|
|
643
635
|
});
|
|
644
636
|
return context;
|
|
645
637
|
}
|
|
646
638
|
});
|
|
647
|
-
const { keys, originals } = populateGlobal(global, vm.context, {
|
|
639
|
+
const { keys, originals } = populateGlobal(global, vm.context, {
|
|
640
|
+
bindFunctions: true
|
|
641
|
+
});
|
|
648
642
|
return {
|
|
649
643
|
teardown(global2) {
|
|
650
644
|
keys.forEach((key) => delete global2[key]);
|
|
@@ -666,12 +660,15 @@ const envPackageNames = {
|
|
|
666
660
|
"edge-runtime": "@edge-runtime/vm"
|
|
667
661
|
};
|
|
668
662
|
function getEnvPackageName(env) {
|
|
669
|
-
if (env === "node")
|
|
663
|
+
if (env === "node") {
|
|
670
664
|
return null;
|
|
671
|
-
|
|
665
|
+
}
|
|
666
|
+
if (env in envPackageNames) {
|
|
672
667
|
return envPackageNames[env];
|
|
673
|
-
|
|
668
|
+
}
|
|
669
|
+
if (env[0] === "." || env[0] === "/") {
|
|
674
670
|
return null;
|
|
671
|
+
}
|
|
675
672
|
return `vitest-environment-${env}`;
|
|
676
673
|
}
|
|
677
674
|
|