vitest 1.1.3 → 1.2.0
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 +5 -31
- package/dist/chunks/{api-setup.mFKdEKxa.js → api-setup.MAoRkVWJ.js} +60 -6
- package/dist/chunks/{integrations-globals.tnKXwyh5.js → integrations-globals.VbxbZ7hn.js} +9 -8
- package/dist/{entry.js → chunks/runtime-runBaseTests.LWFmrzDk.js} +20 -18
- package/dist/cli-wrapper.js +1 -1
- package/dist/cli.js +14 -14
- package/dist/config.cjs +12 -1
- package/dist/config.d.ts +5 -2
- package/dist/config.js +12 -2
- package/dist/coverage.d.ts +1 -1
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +8 -6
- package/dist/execute.js +4 -7
- package/dist/index.d.ts +4 -3
- package/dist/index.js +8 -7
- package/dist/node.d.ts +3 -3
- package/dist/node.js +12 -12
- package/dist/{reporters-qc5Smpt5.d.ts → reporters-trlZlObr.d.ts} +111 -27
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +4 -4
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +7 -5
- package/dist/{suite-WwpgKT7k.d.ts → suite-6Pt_ep5V.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/suite.js +3 -3
- package/dist/vendor/base.8wUUWReP.js +38 -0
- package/dist/vendor/{base._79unx2z.js → base.dzu0Y6Hj.js} +10 -1
- package/dist/vendor/{benchmark.WVm6DARl.js → benchmark.IlKmJkUU.js} +1 -1
- package/dist/vendor/{constants.WSvnD_fn.js → constants.i1PoEnhr.js} +9 -1
- package/dist/vendor/{coverage.v6aD8iAh.js → coverage.E7sG1b3r.js} +1 -1
- package/dist/vendor/{environments.QJtma9XQ.js → environments.sU0TD7wX.js} +19 -7
- package/dist/vendor/execute.3_hyGknJ.js +589 -0
- package/dist/vendor/{global.L7JRz1qU.js → global.CkGT_TMy.js} +10 -1
- package/dist/vendor/{index.IhksUGLR.js → index.3iX2R_Z5.js} +6 -6
- package/dist/vendor/{index.h0j9y5vy.js → index.D-jOsMas.js} +5 -5
- package/dist/vendor/{index.XU72Rmy8.js → index.rJjbcrrp.js} +1 -1
- package/dist/vendor/{node.wTZytysZ.js → node.xyYo9ZvH.js} +650 -274
- package/dist/vendor/{reporters.7Y4WN6gc.js → reporters.2PaQ2peU.js} +7 -4
- package/dist/vendor/{rpc.Bl-ysZIr.js → rpc.w4v8oCkK.js} +23 -2
- package/dist/vendor/{run-once.X3E7xx3F.js → run-once.Olz_Zkd8.js} +2 -2
- package/dist/vendor/setup-common.j9IXYrbN.js +29 -0
- package/dist/vendor/utils.GbToHGHI.js +41 -0
- package/dist/vendor/{vi.DTC--YO5.js → vi.smj1Ggd4.js} +9 -5
- package/dist/vendor/vm.vFKXXdo0.js +696 -0
- package/dist/worker.js +109 -82
- package/dist/workers/forks.js +33 -0
- package/dist/{entry-vm.js → workers/runVmTests.js} +20 -16
- package/dist/workers/threads.js +26 -0
- package/dist/workers/vmForks.js +43 -0
- package/dist/workers/vmThreads.js +36 -0
- package/dist/workers.d.ts +36 -0
- package/dist/workers.js +30 -0
- package/package.json +11 -7
- package/workers.d.ts +1 -0
- package/dist/child.js +0 -125
- package/dist/vendor/execute.cedv4NLQ.js +0 -1235
- package/dist/vendor/inspector.lFAeuaAt.js +0 -26
- package/dist/vendor/loader.L9CYwKn1.js +0 -39
- package/dist/vm.js +0 -126
- /package/dist/{paths.js → path.js} +0 -0
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
|
|
3
|
-
const __require = createRequire(import.meta.url);
|
|
4
|
-
let inspector;
|
|
5
|
-
function setupInspect(config) {
|
|
6
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7
|
-
const isEnabled = config.inspect || config.inspectBrk;
|
|
8
|
-
if (isEnabled) {
|
|
9
|
-
inspector = __require("node:inspector");
|
|
10
|
-
const isOpen = inspector.url() !== void 0;
|
|
11
|
-
if (!isOpen) {
|
|
12
|
-
inspector.open();
|
|
13
|
-
if (config.inspectBrk)
|
|
14
|
-
inspector.waitForDebugger();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
const isIsolatedSingleThread = config.pool === "threads" && ((_b = (_a = config.poolOptions) == null ? void 0 : _a.threads) == null ? void 0 : _b.isolate) === false && ((_d = (_c = config.poolOptions) == null ? void 0 : _c.threads) == null ? void 0 : _d.singleThread);
|
|
18
|
-
const isIsolatedSingleFork = config.pool === "forks" && ((_f = (_e = config.poolOptions) == null ? void 0 : _e.forks) == null ? void 0 : _f.isolate) === false && ((_h = (_g = config.poolOptions) == null ? void 0 : _g.forks) == null ? void 0 : _h.singleFork);
|
|
19
|
-
const keepOpen = config.watch && (isIsolatedSingleFork || isIsolatedSingleThread);
|
|
20
|
-
return function cleanup() {
|
|
21
|
-
if (isEnabled && !keepOpen && inspector)
|
|
22
|
-
inspector.close();
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { setupInspect as s };
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { resolve, normalize } from 'pathe';
|
|
2
|
-
import { ViteNodeRunner } from 'vite-node/client';
|
|
3
|
-
import { e as environments } from './environments.QJtma9XQ.js';
|
|
4
|
-
|
|
5
|
-
function isBuiltinEnvironment(env) {
|
|
6
|
-
return env in environments;
|
|
7
|
-
}
|
|
8
|
-
const _loaders = /* @__PURE__ */ new Map();
|
|
9
|
-
async function createEnvironmentLoader(options) {
|
|
10
|
-
if (!_loaders.has(options.root)) {
|
|
11
|
-
const loader = new ViteNodeRunner(options);
|
|
12
|
-
await loader.executeId("/@vite/env");
|
|
13
|
-
_loaders.set(options.root, loader);
|
|
14
|
-
}
|
|
15
|
-
return _loaders.get(options.root);
|
|
16
|
-
}
|
|
17
|
-
async function loadEnvironment(name, options) {
|
|
18
|
-
var _a;
|
|
19
|
-
if (isBuiltinEnvironment(name))
|
|
20
|
-
return environments[name];
|
|
21
|
-
const loader = await createEnvironmentLoader(options);
|
|
22
|
-
const root = loader.root;
|
|
23
|
-
const packageId = name[0] === "." || name[0] === "/" ? resolve(root, name) : ((_a = await options.resolveId(`vitest-environment-${name}`)) == null ? void 0 : _a.id) ?? resolve(root, name);
|
|
24
|
-
const pkg = await loader.executeId(normalize(packageId));
|
|
25
|
-
if (!pkg || !pkg.default || typeof pkg.default !== "object") {
|
|
26
|
-
throw new TypeError(
|
|
27
|
-
`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "setup" or/and "setupVM" method.`
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
const environment = pkg.default;
|
|
31
|
-
if (environment.transformMode !== "web" && environment.transformMode !== "ssr") {
|
|
32
|
-
throw new TypeError(
|
|
33
|
-
`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "transformMode" method equal to "ssr" or "web".`
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
return environment;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export { loadEnvironment as l };
|
package/dist/vm.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { pathToFileURL } from 'node:url';
|
|
2
|
-
import { performance } from 'node:perf_hooks';
|
|
3
|
-
import { isContext } from 'node:vm';
|
|
4
|
-
import { ModuleCacheMap } from 'vite-node/client';
|
|
5
|
-
import { workerId } from 'tinypool';
|
|
6
|
-
import { c as createBirpc } from './vendor/index.cAUulNDf.js';
|
|
7
|
-
import { resolve } from 'pathe';
|
|
8
|
-
import { installSourcemapsSupport } from 'vite-node/source-map';
|
|
9
|
-
import { distDir } from './paths.js';
|
|
10
|
-
import { l as loadEnvironment } from './vendor/loader.L9CYwKn1.js';
|
|
11
|
-
import { b as startVitestExecutor } from './vendor/execute.cedv4NLQ.js';
|
|
12
|
-
import { createCustomConsole } from './chunks/runtime-console.hf2msWA9.js';
|
|
13
|
-
import { c as createSafeRpc } from './vendor/rpc.Bl-ysZIr.js';
|
|
14
|
-
import './vendor/environments.QJtma9XQ.js';
|
|
15
|
-
import 'node:console';
|
|
16
|
-
import 'vite-node/utils';
|
|
17
|
-
import '@vitest/utils/error';
|
|
18
|
-
import 'node:fs';
|
|
19
|
-
import '@vitest/utils';
|
|
20
|
-
import './vendor/base._79unx2z.js';
|
|
21
|
-
import 'node:path';
|
|
22
|
-
import 'node:module';
|
|
23
|
-
import 'vite-node/constants';
|
|
24
|
-
import 'node:stream';
|
|
25
|
-
import './vendor/date.Ns1pGd_X.js';
|
|
26
|
-
import './vendor/global.L7JRz1qU.js';
|
|
27
|
-
|
|
28
|
-
const entryFile = pathToFileURL(resolve(distDir, "entry-vm.js")).href;
|
|
29
|
-
async function run(ctx) {
|
|
30
|
-
var _a;
|
|
31
|
-
const moduleCache = new ModuleCacheMap();
|
|
32
|
-
const mockMap = /* @__PURE__ */ new Map();
|
|
33
|
-
const { config, port, providedContext } = ctx;
|
|
34
|
-
let setCancel = (_reason) => {
|
|
35
|
-
};
|
|
36
|
-
const onCancel = new Promise((resolve2) => {
|
|
37
|
-
setCancel = resolve2;
|
|
38
|
-
});
|
|
39
|
-
const rpc = createSafeRpc(createBirpc(
|
|
40
|
-
{
|
|
41
|
-
onCancel: setCancel
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
eventNames: ["onUserConsoleLog", "onFinished", "onCollected", "onWorkerExit"],
|
|
45
|
-
post(v) {
|
|
46
|
-
port.postMessage(v);
|
|
47
|
-
},
|
|
48
|
-
on(fn) {
|
|
49
|
-
port.addListener("message", fn);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
));
|
|
53
|
-
const environment = await loadEnvironment(ctx.environment.name, {
|
|
54
|
-
root: ctx.config.root,
|
|
55
|
-
fetchModule: (id) => rpc.fetch(id, "ssr"),
|
|
56
|
-
resolveId: (id, importer) => rpc.resolveId(id, importer, "ssr")
|
|
57
|
-
});
|
|
58
|
-
if (!environment.setupVM) {
|
|
59
|
-
const envName = ctx.environment.name;
|
|
60
|
-
const packageId = envName[0] === "." ? envName : `vitest-environment-${envName}`;
|
|
61
|
-
throw new TypeError(
|
|
62
|
-
`Environment "${ctx.environment.name}" is not a valid environment. Path "${packageId}" doesn't support vm environment because it doesn't provide "setupVM" method.`
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
const state = {
|
|
66
|
-
ctx,
|
|
67
|
-
moduleCache,
|
|
68
|
-
config,
|
|
69
|
-
mockMap,
|
|
70
|
-
onCancel,
|
|
71
|
-
environment,
|
|
72
|
-
durations: {
|
|
73
|
-
environment: performance.now(),
|
|
74
|
-
prepare: performance.now()
|
|
75
|
-
},
|
|
76
|
-
rpc,
|
|
77
|
-
providedContext
|
|
78
|
-
};
|
|
79
|
-
installSourcemapsSupport({
|
|
80
|
-
getSourceMap: (source) => moduleCache.getSourceMap(source)
|
|
81
|
-
});
|
|
82
|
-
const vm = await environment.setupVM(ctx.environment.options || ctx.config.environmentOptions || {});
|
|
83
|
-
state.durations.environment = performance.now() - state.durations.environment;
|
|
84
|
-
process.env.VITEST_WORKER_ID = String(ctx.workerId);
|
|
85
|
-
process.env.VITEST_POOL_ID = String(workerId);
|
|
86
|
-
process.env.VITEST_VM_POOL = "1";
|
|
87
|
-
if (!vm.getVmContext)
|
|
88
|
-
throw new TypeError(`Environment ${ctx.environment.name} doesn't provide "getVmContext" method. It should return a context created by "vm.createContext" method.`);
|
|
89
|
-
const context = vm.getVmContext();
|
|
90
|
-
if (!isContext(context))
|
|
91
|
-
throw new TypeError(`Environment ${ctx.environment.name} doesn't provide a valid context. It should be created by "vm.createContext" method.`);
|
|
92
|
-
Object.defineProperty(context, "__vitest_worker__", {
|
|
93
|
-
value: state,
|
|
94
|
-
configurable: true,
|
|
95
|
-
writable: true,
|
|
96
|
-
enumerable: false
|
|
97
|
-
});
|
|
98
|
-
context.process = process;
|
|
99
|
-
context.global = context;
|
|
100
|
-
context.console = createCustomConsole(state);
|
|
101
|
-
context.setImmediate = setImmediate;
|
|
102
|
-
context.clearImmediate = clearImmediate;
|
|
103
|
-
if (ctx.invalidates) {
|
|
104
|
-
ctx.invalidates.forEach((fsPath) => {
|
|
105
|
-
moduleCache.delete(fsPath);
|
|
106
|
-
moduleCache.delete(`mock:${fsPath}`);
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
ctx.files.forEach((i) => moduleCache.delete(i));
|
|
110
|
-
const executor = await startVitestExecutor({
|
|
111
|
-
context,
|
|
112
|
-
moduleCache,
|
|
113
|
-
mockMap,
|
|
114
|
-
state
|
|
115
|
-
});
|
|
116
|
-
context.__vitest_mocker__ = executor.mocker;
|
|
117
|
-
const { run: run2 } = await executor.importExternalModule(entryFile);
|
|
118
|
-
try {
|
|
119
|
-
await run2(ctx.files, ctx.config, executor);
|
|
120
|
-
} finally {
|
|
121
|
-
await ((_a = vm.teardown) == null ? void 0 : _a.call(vm));
|
|
122
|
-
state.environmentTeardownRun = true;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export { run };
|
|
File without changes
|