vitest 5.0.0-beta.4 → 5.0.0-beta.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/LICENSE.md +0 -17
- package/dist/browser.d.ts +8 -6
- package/dist/browser.js +5 -3
- package/dist/chunks/artifact.BNnEI1sJ.js +2770 -0
- package/dist/chunks/{base.BEGVMQrS.js → base.BKfXyFN7.js} +12 -12
- package/dist/chunks/browser.d.DoM6vBOs.d.ts +64 -0
- package/dist/chunks/{cac.CyXAEMkE.js → cac.DKrA6qEB.js} +15 -7
- package/dist/chunks/{cli-api.DJMXq34b.js → cli-api.cZcvaUFI.js} +491 -852
- package/dist/chunks/config.d.CKWK3nld.d.ts +2920 -0
- package/dist/chunks/{console.B3IRP8fX.js → console.DjVIMaXT.js} +4 -4
- package/dist/chunks/{coverage.d.g2xbl2sP.d.ts → coverage.d.CCNrKR65.d.ts} +2 -0
- package/dist/chunks/{creator.D66cVXYh.js → creator.C4nK7Krt.js} +19 -4
- package/dist/chunks/{defaults.CUUnbOrq.js → defaults.B_pFOTYy.js} +1 -1
- package/dist/chunks/{globals.BuY-yD0m.js → globals.CzUA1xn8.js} +12 -12
- package/dist/chunks/{index.CcluKS59.js → index.B4UTDegh.js} +6 -6
- package/dist/chunks/{nativeModuleRunner.BOeMnHl4.js → index.CesbTg1C.js} +3 -34
- package/dist/chunks/{index.CE58PZNH.js → index.D6NDM5O1.js} +515 -121
- package/dist/chunks/{index.nQFVd50u.js → index.DNRmy2jU.js} +32 -10
- package/dist/chunks/{index.og1WyBLx.js → index.Djaij2xr.js} +660 -58
- package/dist/chunks/{init-forks.Ce3vGWgL.js → init-forks.BG4bCDny.js} +1 -1
- package/dist/chunks/{init-threads.8e1OLv5v.js → init-threads.DLtIP5Qq.js} +1 -1
- package/dist/chunks/{init.6qx-LaHs.js → init.DTAQFCjl.js} +10 -6
- package/dist/chunks/{nativeModuleMocker.DDZfQXLs.js → nativeModuleMocker.BKtCThoO.js} +2 -3
- package/dist/chunks/nativeModuleRunner.WlMdOB52.js +36 -0
- package/dist/chunks/{node.CwFbQqI1.js → node.C9I1sbE9.js} +1 -2
- package/dist/chunks/{plugin.d.B7MTG_Fe.d.ts → plugin.d.Bpge8Jye.d.ts} +94 -37
- package/dist/chunks/{rpc.DFRWVnRh.js → rpc.DZEh5xnQ.js} +1 -1
- package/dist/chunks/{rpc.d.OQ_EZi1Z.d.ts → rpc.d.C6-dGZ2f.d.ts} +1 -2
- package/dist/chunks/{setup-common.DdEF_hkE.js → setup-common.ZNdeu5wa.js} +2 -2
- package/dist/chunks/{global.d.BtKPuz2X.d.ts → task-utils.d.mMDXJF_I.d.ts} +30 -89
- package/dist/chunks/{utils.BX5Fg8C4.js → utils.DYj33du9.js} +1 -17
- package/dist/chunks/{vm.Bu7mmcZq.js → vm.CeHWcIrU.js} +4 -4
- package/dist/chunks/{worker.d.yR22cs6X.d.ts → worker.d.JES7ffPK.d.ts} +3 -3
- package/dist/cli.js +1 -1
- package/dist/config.cjs +1 -1
- package/dist/config.d.ts +12 -13
- package/dist/config.js +1 -1
- package/dist/index.d.ts +416 -21
- package/dist/index.js +9 -9
- package/dist/module-evaluator.d.ts +7 -4
- package/dist/module-evaluator.js +7 -0
- package/dist/node.d.ts +31 -18
- package/dist/node.js +22 -16
- package/dist/runtime.d.ts +9 -3
- package/dist/runtime.js +4 -5
- package/dist/task-utils.js +296 -0
- package/dist/worker.d.ts +7 -6
- package/dist/worker.js +15 -14
- package/dist/workers/forks.js +16 -15
- package/dist/workers/runVmTests.js +10 -10
- package/dist/workers/threads.js +16 -15
- package/dist/workers/vmForks.js +8 -8
- package/dist/workers/vmThreads.js +8 -8
- package/package.json +18 -19
- package/dist/chunks/browser.d.BGxB4Xum.d.ts +0 -878
- package/dist/chunks/config.d.DXq1aBpy.d.ts +0 -244
- package/dist/chunks/environment.d-DOJxxZV9.d.DOJxxZV9.d.ts +0 -17
- package/dist/chunks/general.d.DFAHgpC2.d.ts +0 -247
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs__default from 'node:fs';
|
|
2
|
-
import { isBareImport } from '@vitest/utils/helpers';
|
|
2
|
+
import { splitFileAndPostfix as splitFileAndPostfix$1, isBareImport } from '@vitest/utils/helpers';
|
|
3
3
|
import { i as isBuiltin, a as isBrowserExternal, t as toBuiltin } from './modules.BJuCwlRJ.js';
|
|
4
|
-
import { E as EnvironmentTeardownError, a as getSafeWorkerState } from './utils.
|
|
4
|
+
import { E as EnvironmentTeardownError, a as getSafeWorkerState } from './utils.DYj33du9.js';
|
|
5
5
|
import { pathToFileURL, URL as URL$1 } from 'node:url';
|
|
6
6
|
import { normalize, join } from 'pathe';
|
|
7
7
|
import { distDir } from '../path.js';
|
|
@@ -234,8 +234,11 @@ function fixLeadingSlashes(id) {
|
|
|
234
234
|
return id;
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
// copied from vite
|
|
237
|
+
// copied from vite
|
|
238
|
+
// https://github.com/vitejs/vite/blob/4417b4f305623b2850bd6ae6553834c017694672/packages/vite/src/shared/utils.ts
|
|
239
|
+
// https://github.com/vitejs/vite/blob/4417b4f305623b2850bd6ae6553834c017694672/packages/vite/src/node/utils.ts
|
|
238
240
|
const postfixRE = /[?#].*$/;
|
|
241
|
+
const trailingSeparatorRE = /[?&]$/;
|
|
239
242
|
function cleanUrl(url) {
|
|
240
243
|
return url.replace(postfixRE, "");
|
|
241
244
|
}
|
|
@@ -251,7 +254,7 @@ function injectQuery(url, queryToInject) {
|
|
|
251
254
|
return `${file}?${queryToInject}${postfix[0] === "?" ? `&${postfix.slice(1)}` : postfix}`;
|
|
252
255
|
}
|
|
253
256
|
function removeQuery(url, queryToRemove) {
|
|
254
|
-
return url.replace(new RegExp(`[?&]${queryToRemove}(
|
|
257
|
+
return url.replace(new RegExp(`([?&])${queryToRemove}(?:&|$)`), "$1").replace(trailingSeparatorRE, "");
|
|
255
258
|
}
|
|
256
259
|
|
|
257
260
|
const spyModulePath = resolve(distDir, "spy.js");
|
|
@@ -602,7 +605,8 @@ function getCachedVitestImport(id, state) {
|
|
|
602
605
|
const root = state().config.root;
|
|
603
606
|
const relativeRoot = relativeIds[root] ?? (relativeIds[root] = normalizedDistDir.slice(root.length));
|
|
604
607
|
if (id.includes(distDir) || id.includes(normalizedDistDir)) {
|
|
605
|
-
const
|
|
608
|
+
const { file, postfix } = splitFileAndPostfix$1(id);
|
|
609
|
+
const externalize = id.startsWith("file://") ? id : `${pathToFileURL(file)}${postfix}`;
|
|
606
610
|
externalizeMap.set(id, externalize);
|
|
607
611
|
return {
|
|
608
612
|
externalize,
|
|
@@ -610,7 +614,8 @@ function getCachedVitestImport(id, state) {
|
|
|
610
614
|
};
|
|
611
615
|
}
|
|
612
616
|
if (relativeRoot && relativeRoot !== "/" && id.startsWith(relativeRoot)) {
|
|
613
|
-
const
|
|
617
|
+
const { file, postfix } = splitFileAndPostfix$1(id);
|
|
618
|
+
const externalize = `${pathToFileURL(join(root, file))}${postfix}`;
|
|
614
619
|
externalizeMap.set(id, externalize);
|
|
615
620
|
return {
|
|
616
621
|
externalize,
|
|
@@ -927,6 +932,7 @@ const OTHER_KEYS = [
|
|
|
927
932
|
"innerHeight",
|
|
928
933
|
"innerWidth",
|
|
929
934
|
"length",
|
|
935
|
+
"localStorage",
|
|
930
936
|
"location",
|
|
931
937
|
"matchMedia",
|
|
932
938
|
"moveBy",
|
|
@@ -959,6 +965,7 @@ const OTHER_KEYS = [
|
|
|
959
965
|
"scrollX",
|
|
960
966
|
"scrollY",
|
|
961
967
|
"self",
|
|
968
|
+
"sessionStorage",
|
|
962
969
|
"stop",
|
|
963
970
|
"top",
|
|
964
971
|
"Window",
|
|
@@ -991,7 +998,18 @@ function populateGlobal(global, win, options = {}) {
|
|
|
991
998
|
const overrideObject = /* @__PURE__ */ new Map();
|
|
992
999
|
for (const key of keys) {
|
|
993
1000
|
const boundFunction = bindFunctions && typeof win[key] === "function" && !isClassLikeName(key) && win[key].bind(win);
|
|
994
|
-
if (overriddenKeys.has(key) && key in global)
|
|
1001
|
+
if (overriddenKeys.has(key) && key in global) {
|
|
1002
|
+
// capture the descriptor instead of the value to avoid invoking native
|
|
1003
|
+
// lazy getters such as Node's `localStorage`, which warns when accessed
|
|
1004
|
+
// without `--localstorage-file`
|
|
1005
|
+
const descriptor = Object.getOwnPropertyDescriptor(global, key) ?? {
|
|
1006
|
+
value: global[key],
|
|
1007
|
+
configurable: true,
|
|
1008
|
+
writable: true,
|
|
1009
|
+
enumerable: true
|
|
1010
|
+
};
|
|
1011
|
+
originals.set(key, descriptor);
|
|
1012
|
+
}
|
|
995
1013
|
Object.defineProperty(global, key, {
|
|
996
1014
|
get() {
|
|
997
1015
|
if (overrideObject.has(key)) return overrideObject.get(key);
|
|
@@ -1000,6 +1018,10 @@ function populateGlobal(global, win, options = {}) {
|
|
|
1000
1018
|
},
|
|
1001
1019
|
set(v) {
|
|
1002
1020
|
overrideObject.set(key, v);
|
|
1021
|
+
// propagate changes to underlying window implementation,
|
|
1022
|
+
// which can affect other window API behavior internally, e.g.
|
|
1023
|
+
// updating `innerWidth` affects `matchMedia("(max-width: *)")` on happy-dom.
|
|
1024
|
+
win[key] = v;
|
|
1003
1025
|
},
|
|
1004
1026
|
configurable: true
|
|
1005
1027
|
});
|
|
@@ -1054,7 +1076,7 @@ var edge = {
|
|
|
1054
1076
|
} }).context, { bindFunctions: true });
|
|
1055
1077
|
return { teardown(global) {
|
|
1056
1078
|
keys.forEach((key) => delete global[key]);
|
|
1057
|
-
originals.forEach((
|
|
1079
|
+
originals.forEach((d, k) => Object.defineProperty(global, k, d));
|
|
1058
1080
|
} };
|
|
1059
1081
|
}
|
|
1060
1082
|
};
|
|
@@ -1124,7 +1146,7 @@ var happy = {
|
|
|
1124
1146
|
return { async teardown(global) {
|
|
1125
1147
|
await teardownWindow(win);
|
|
1126
1148
|
keys.forEach((key) => delete global[key]);
|
|
1127
|
-
originals.forEach((
|
|
1149
|
+
originals.forEach((d, k) => Object.defineProperty(global, k, d));
|
|
1128
1150
|
} };
|
|
1129
1151
|
}
|
|
1130
1152
|
};
|
|
@@ -1265,7 +1287,7 @@ var jsdom = {
|
|
|
1265
1287
|
dom.window.close();
|
|
1266
1288
|
delete global.jsdom;
|
|
1267
1289
|
keys.forEach((key) => delete global[key]);
|
|
1268
|
-
originals.forEach((
|
|
1290
|
+
originals.forEach((d, k) => Object.defineProperty(global, k, d));
|
|
1269
1291
|
} };
|
|
1270
1292
|
}
|
|
1271
1293
|
};
|