vitest 1.0.0-beta.1 → 1.0.0-beta.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/LICENSE.md +0 -29
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +2 -2
- package/dist/child.js +9 -4
- package/dist/{chunk-api-setup.0aeabd21.js → chunk-api-setup.37a43981.js} +3 -2
- package/dist/{chunk-install-pkg.a430b45e.js → chunk-install-pkg.6349b322.js} +22 -21
- package/dist/{chunk-integrations-globals.c3c5e678.js → chunk-integrations-globals.9df12d91.js} +2 -3
- package/dist/{chunk-node-git.36288174.js → chunk-node-git.6c12e560.js} +1 -1
- package/dist/{chunk-runtime-console.ea222ffb.js → chunk-runtime-console.f3263f87.js} +19 -4
- package/dist/cli-wrapper.js +1 -1
- package/dist/cli.js +14 -18
- package/dist/config.cjs +2 -1
- package/dist/config.d.ts +3 -3
- package/dist/config.js +2 -1
- package/dist/coverage.d.ts +1 -1
- package/dist/coverage.js +2 -2
- package/dist/entry-vm.js +9 -4
- package/dist/entry.js +10 -5
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -13
- package/dist/execute.d.ts +1 -1
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +3 -4
- package/dist/node.d.ts +5 -3
- package/dist/node.js +14 -13
- package/dist/{reporters-7bd09217.d.ts → reporters-1678fe04.d.ts} +84 -47
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +6 -1
- package/dist/runners.d.ts +3 -2
- package/dist/runners.js +33 -37
- package/dist/{suite-543d56bd.d.ts → suite-0579b50d.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/{vendor-environments.e73c5410.js → vendor-environments.dcc4a34e.js} +6 -37
- package/dist/{vendor-execute.07d1a420.js → vendor-execute.e6e4e89b.js} +1 -0
- package/dist/{vendor-index.d36f5516.js → vendor-index.3d079eea.js} +6 -1
- package/dist/{vendor-index.f7fcd5e8.js → vendor-index.68ecee35.js} +1 -1
- package/dist/{vendor-index.85fc950a.js → vendor-index.8efe7746.js} +375 -375
- package/dist/{vendor-index.0b5b3600.js → vendor-loader.9c966f23.js} +36 -9
- package/dist/{vendor-node.bde9fb47.js → vendor-node.327f8f1f.js} +1996 -1984
- package/dist/{vendor-reporters.f6975b8d.js → vendor-reporters.b9600369.js} +42 -24
- package/dist/vendor-vi.d30b47ae.js +3510 -0
- package/dist/vm.js +10 -5
- package/dist/worker.js +9 -4
- package/package.json +12 -28
- package/dist/loader.js +0 -100
- package/dist/vendor-index.98139333.js +0 -129
- package/dist/vendor-vi.7f2b988f.js +0 -3491
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { isAbsolute, resolve, normalize } from 'pathe';
|
|
1
2
|
import 'acorn';
|
|
2
3
|
import { builtinModules } from 'node:module';
|
|
3
4
|
import fs, { existsSync, realpathSync, statSync, Stats } from 'node:fs';
|
|
4
5
|
import { pathToFileURL, fileURLToPath as fileURLToPath$1, URL as URL$1 } from 'node:url';
|
|
5
|
-
import { isAbsolute } from 'pathe';
|
|
6
6
|
import assert from 'node:assert';
|
|
7
7
|
import process$1 from 'node:process';
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import v8 from 'node:v8';
|
|
10
10
|
import { format, inspect } from 'node:util';
|
|
11
|
+
import { ViteNodeRunner } from 'vite-node/client';
|
|
12
|
+
import { e as environments } from './vendor-environments.dcc4a34e.js';
|
|
11
13
|
|
|
12
14
|
const TRAILING_SLASH_RE = /\/$|\/\?/;
|
|
13
15
|
function hasTrailingSlash(input = "", queryParameters = false) {
|
|
@@ -1959,10 +1961,6 @@ function normalizeid(id) {
|
|
|
1959
1961
|
}
|
|
1960
1962
|
return "file://" + encodeURI(normalizeSlash(id));
|
|
1961
1963
|
}
|
|
1962
|
-
function isNodeBuiltin(id = "") {
|
|
1963
|
-
id = id.replace(/^node:/, "").split("/")[0];
|
|
1964
|
-
return BUILTIN_MODULES.has(id);
|
|
1965
|
-
}
|
|
1966
1964
|
|
|
1967
1965
|
const DEFAULT_CONDITIONS_SET = /* @__PURE__ */ new Set(["node", "import"]);
|
|
1968
1966
|
const DEFAULT_URL = pathToFileURL(process.cwd());
|
|
@@ -2054,9 +2052,38 @@ function resolvePathSync(id, options) {
|
|
|
2054
2052
|
function resolvePath(id, options) {
|
|
2055
2053
|
return pcall(resolvePathSync, id, options);
|
|
2056
2054
|
}
|
|
2057
|
-
|
|
2058
|
-
function
|
|
2059
|
-
return
|
|
2055
|
+
|
|
2056
|
+
function isBuiltinEnvironment(env) {
|
|
2057
|
+
return env in environments;
|
|
2058
|
+
}
|
|
2059
|
+
const _loaders = /* @__PURE__ */ new Map();
|
|
2060
|
+
async function createEnvironmentLoader(options) {
|
|
2061
|
+
if (!_loaders.has(options.root)) {
|
|
2062
|
+
const loader = new ViteNodeRunner(options);
|
|
2063
|
+
await loader.executeId("/@vite/env");
|
|
2064
|
+
_loaders.set(options.root, loader);
|
|
2065
|
+
}
|
|
2066
|
+
return _loaders.get(options.root);
|
|
2067
|
+
}
|
|
2068
|
+
async function loadEnvironment(name, options) {
|
|
2069
|
+
if (isBuiltinEnvironment(name))
|
|
2070
|
+
return environments[name];
|
|
2071
|
+
const loader = await createEnvironmentLoader(options);
|
|
2072
|
+
const root = loader.root;
|
|
2073
|
+
const packageId = name[0] === "." || name[0] === "/" ? resolve(root, name) : await resolvePath(`vitest-environment-${name}`, { url: [root] }) ?? resolve(root, name);
|
|
2074
|
+
const pkg = await loader.executeId(normalize(packageId));
|
|
2075
|
+
if (!pkg || !pkg.default || typeof pkg.default !== "object") {
|
|
2076
|
+
throw new TypeError(
|
|
2077
|
+
`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "setup" or/and "setupVM" method.`
|
|
2078
|
+
);
|
|
2079
|
+
}
|
|
2080
|
+
const environment = pkg.default;
|
|
2081
|
+
if (environment.transformMode !== "web" && environment.transformMode !== "ssr") {
|
|
2082
|
+
throw new TypeError(
|
|
2083
|
+
`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "transformMode" method equal to "ssr" or "web".`
|
|
2084
|
+
);
|
|
2085
|
+
}
|
|
2086
|
+
return environment;
|
|
2060
2087
|
}
|
|
2061
2088
|
|
|
2062
|
-
export {
|
|
2089
|
+
export { loadEnvironment as l };
|