vitest 2.0.0-beta.10 → 2.0.0-beta.12
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/browser.d.ts +1 -1
- package/dist/browser.js +3 -3
- package/dist/chunks/browser-creator.Bw94IHrL.js +673 -0
- package/dist/chunks/{environments-node.39w4gmlF.js → environments-node.XE5FbRPQ.js} +1 -1
- package/dist/chunks/{integrations-globals.C6Ah-pUW.js → integrations-globals.DSNOaUHv.js} +10 -10
- 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.Cukyr5-I.js → runtime-runBaseTests.BDt9gQFB.js} +41 -33
- package/dist/cli.js +3 -3
- package/dist/config.cjs +45 -21
- package/dist/config.d.ts +1 -1
- package/dist/config.js +45 -22
- package/dist/coverage.d.ts +5 -4
- package/dist/coverage.js +100 -37
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +1 -1
- package/dist/execute.js +2 -2
- package/dist/index.d.ts +37 -11
- package/dist/index.js +10 -10
- package/dist/node.d.ts +20 -7
- package/dist/node.js +29 -20
- package/dist/path.js +4 -1
- package/dist/{reporters-CYVC6LOl.d.ts → reporters-Cd1vkLMZ.d.ts} +134 -182
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +8 -8
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +99 -61
- package/dist/snapshot.js +2 -2
- package/dist/{suite-Dpu9EC_k.d.ts → suite-BS2CV79a.d.ts} +1 -1
- package/dist/suite.d.ts +2 -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.Dln9yllP.js → base.Cy97mmVC.js} +4 -3
- package/dist/vendor/{benchmark.BNLebNi5.js → benchmark.B6pblCp2.js} +13 -14
- package/dist/vendor/{cac.CtYFkoSJ.js → cac.DRNUX42m.js} +82 -38
- package/dist/vendor/{cli-api.CUtJc4r3.js → cli-api.Bu-PSdzx.js} +5908 -13271
- package/dist/vendor/{constants.TCjCaw2D.js → constants.BWsVtsAj.js} +5 -22
- 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.T3gg2ZK6.js} +174 -60
- package/dist/vendor/{index.B5SKBLvV.js → index.B7pSlOSa.js} +18 -10
- package/dist/vendor/{index._7XLd8Kd.js → index.BJmtb_7W.js} +3 -2
- package/dist/vendor/{index.CThipSqB.js → index.BMmMjLIQ.js} +2540 -2540
- package/dist/vendor/{index.kpsSqFiz.js → index.D4nqnQWz.js} +69 -73
- package/dist/vendor/index.D6GZqexG.js +6575 -0
- package/dist/vendor/{index.D3hs2WiI.js → index.Hqvcg1pf.js} +3 -3
- package/dist/vendor/{index.BOMEjpjj.js → index.ZtQtNPP2.js} +962 -471
- package/dist/vendor/{rpc.DRDE9Pu1.js → rpc.BGx7q_k2.js} +30 -19
- package/dist/vendor/{run-once.DLomgGUH.js → run-once.Db8Hgq9X.js} +2 -1
- package/dist/vendor/{setup-common.DAu7t7mY.js → setup-common.CWnv_2-5.js} +30 -15
- package/dist/vendor/{tasks.WC7M-K-v.js → tasks.DhVtQBtW.js} +3 -1
- package/dist/vendor/{utils.YuQ3LT2a.js → utils.DSO2UK15.js} +40 -25
- package/dist/vendor/{utils.CUjzkRH7.js → utils.DkxLWvS1.js} +12 -5
- package/dist/vendor/{vi.hATFzZbX.js → vi.DXACdGTu.js} +267 -138
- package/dist/vendor/{vm.Ow-X2mkS.js → vm.D9wVR14y.js} +152 -87
- package/dist/worker.js +31 -15
- package/dist/workers/forks.js +4 -4
- package/dist/workers/runVmTests.js +15 -14
- package/dist/workers/threads.js +4 -4
- package/dist/workers/vmForks.js +7 -7
- package/dist/workers/vmThreads.js +7 -7
- package/dist/workers.d.ts +2 -2
- package/dist/workers.js +10 -10
- package/package.json +11 -11
- package/suppress-warnings.cjs +1 -4
- 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;
|
|
@@ -502,12 +497,7 @@ var jsdom = {
|
|
|
502
497
|
};
|
|
503
498
|
},
|
|
504
499
|
async setup(global, { jsdom = {} }) {
|
|
505
|
-
const {
|
|
506
|
-
CookieJar,
|
|
507
|
-
JSDOM,
|
|
508
|
-
ResourceLoader,
|
|
509
|
-
VirtualConsole
|
|
510
|
-
} = await import('jsdom');
|
|
500
|
+
const { CookieJar, JSDOM, ResourceLoader, VirtualConsole } = await import('jsdom');
|
|
511
501
|
const {
|
|
512
502
|
html = "<!DOCTYPE html>",
|
|
513
503
|
userAgent,
|
|
@@ -521,22 +511,21 @@ var jsdom = {
|
|
|
521
511
|
cookieJar = false,
|
|
522
512
|
...restOptions
|
|
523
513
|
} = jsdom;
|
|
524
|
-
const dom = new JSDOM(
|
|
525
|
-
|
|
526
|
-
{
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
);
|
|
539
|
-
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
|
+
});
|
|
540
529
|
const clearWindowErrors = catchWindowErrors(global);
|
|
541
530
|
global.jsdom = dom;
|
|
542
531
|
return {
|
|
@@ -574,8 +563,9 @@ var happy = {
|
|
|
574
563
|
}
|
|
575
564
|
});
|
|
576
565
|
win.Buffer = Buffer;
|
|
577
|
-
if (typeof structuredClone !== "undefined" && !win.structuredClone)
|
|
566
|
+
if (typeof structuredClone !== "undefined" && !win.structuredClone) {
|
|
578
567
|
win.structuredClone = structuredClone;
|
|
568
|
+
}
|
|
579
569
|
return {
|
|
580
570
|
getVmContext() {
|
|
581
571
|
return win;
|
|
@@ -639,13 +629,16 @@ var edge = {
|
|
|
639
629
|
context.global = context;
|
|
640
630
|
context.Buffer = Buffer;
|
|
641
631
|
KEYS.forEach((key) => {
|
|
642
|
-
if (key in global)
|
|
632
|
+
if (key in global) {
|
|
643
633
|
context[key] = global[key];
|
|
634
|
+
}
|
|
644
635
|
});
|
|
645
636
|
return context;
|
|
646
637
|
}
|
|
647
638
|
});
|
|
648
|
-
const { keys, originals } = populateGlobal(global, vm.context, {
|
|
639
|
+
const { keys, originals } = populateGlobal(global, vm.context, {
|
|
640
|
+
bindFunctions: true
|
|
641
|
+
});
|
|
649
642
|
return {
|
|
650
643
|
teardown(global2) {
|
|
651
644
|
keys.forEach((key) => delete global2[key]);
|
|
@@ -667,12 +660,15 @@ const envPackageNames = {
|
|
|
667
660
|
"edge-runtime": "@edge-runtime/vm"
|
|
668
661
|
};
|
|
669
662
|
function getEnvPackageName(env) {
|
|
670
|
-
if (env === "node")
|
|
663
|
+
if (env === "node") {
|
|
671
664
|
return null;
|
|
672
|
-
|
|
665
|
+
}
|
|
666
|
+
if (env in envPackageNames) {
|
|
673
667
|
return envPackageNames[env];
|
|
674
|
-
|
|
668
|
+
}
|
|
669
|
+
if (env[0] === "." || env[0] === "/") {
|
|
675
670
|
return null;
|
|
671
|
+
}
|
|
676
672
|
return `vitest-environment-${env}`;
|
|
677
673
|
}
|
|
678
674
|
|