vitest 1.0.0-beta.2 → 1.0.0-beta.4
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 +17 -29
- package/dist/browser.d.ts +1 -2
- package/dist/browser.js +3 -3
- package/dist/child.js +13 -7
- package/dist/{chunk-api-setup.5d9a93c7.js → chunk-api-setup.6d19ab38.js} +6 -4
- package/dist/{chunk-install-pkg.43d58972.js → chunk-install-pkg.e1d6323e.js} +12 -14
- package/dist/{chunk-integrations-globals.9df12d91.js → chunk-integrations-globals.2b099e04.js} +6 -6
- package/dist/{chunk-node-git.2f1df48f.js → chunk-node-git.6c12e560.js} +1 -1
- package/dist/cli-wrapper.js +1 -1
- package/dist/cli.js +16 -20
- package/dist/config.cjs +1 -0
- package/dist/config.d.ts +2 -3
- package/dist/config.js +1 -0
- package/dist/coverage.d.ts +1 -2
- package/dist/coverage.js +2 -2
- package/dist/entry-vm.js +8 -8
- package/dist/entry.js +8 -8
- package/dist/environments.d.ts +1 -2
- package/dist/environments.js +1 -13
- package/dist/execute.d.ts +2 -3
- package/dist/execute.js +1 -2
- package/dist/index.d.ts +232 -59
- package/dist/index.js +7 -7
- package/dist/node.d.ts +10 -4
- package/dist/node.js +16 -18
- package/dist/{reporters-d10f25e1.d.ts → reporters-50c2bd49.d.ts} +100 -35
- package/dist/reporters.d.ts +1 -2
- package/dist/reporters.js +3 -3
- package/dist/runners.d.ts +3 -3
- package/dist/runners.js +37 -41
- package/dist/{suite-919dd548.d.ts → suite-ad69b7cd.d.ts} +1 -1
- package/dist/suite.d.ts +2 -3
- package/dist/suite.js +3 -3
- package/dist/{vendor-benchmark.44931cfa.js → vendor-benchmark.b6befc50.js} +1 -1
- package/dist/{vendor-environments.094f240c.js → vendor-environments.dcc4a34e.js} +4 -37
- package/dist/{vendor-execute.07d1a420.js → vendor-execute.157302d6.js} +3 -3
- package/dist/vendor-global.c3664e75.js +14 -0
- package/dist/{vendor-index.29282562.js → vendor-index.2b92937b.js} +1 -1
- package/dist/{vendor-index.d36f5516.js → vendor-index.57925a34.js} +8 -3
- package/dist/{vendor-index.68ecee35.js → vendor-index.72df742e.js} +11 -4
- package/dist/{vendor-index.e006069f.js → vendor-index.8efe7746.js} +371 -371
- package/dist/{vendor-index.0b5b3600.js → vendor-loader.9c966f23.js} +36 -9
- package/dist/{vendor-node.e5a35bfe.js → vendor-node.65461b16.js} +2660 -2021
- package/dist/{vendor-reporters.2953082e.js → vendor-reporters.d24d80a4.js} +42 -25
- package/dist/{vendor-rpc.cbd8e972.js → vendor-rpc.171f65fb.js} +1 -1
- package/dist/{vendor-run-once.3e5ef7d7.js → vendor-run-once.fb836747.js} +1 -1
- package/dist/{vendor-vi.d30b47ae.js → vendor-vi.3baa7c4a.js} +32 -35
- package/dist/vm.js +14 -8
- package/dist/worker.js +14 -8
- package/package.json +12 -28
- package/dist/loader.js +0 -100
- package/dist/vendor-global.97e4527c.js +0 -9
- package/dist/vendor-index.98139333.js +0 -129
package/dist/loader.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
2
|
-
import { readFile } from 'node:fs/promises';
|
|
3
|
-
import { i as isNodeBuiltin, h as hasCJSSyntax } from './vendor-index.0b5b3600.js';
|
|
4
|
-
import { normalizeModuleId } from 'vite-node/utils';
|
|
5
|
-
import './vendor-index.29282562.js';
|
|
6
|
-
import { g as getWorkerState } from './vendor-global.97e4527c.js';
|
|
7
|
-
import 'acorn';
|
|
8
|
-
import 'node:module';
|
|
9
|
-
import 'node:fs';
|
|
10
|
-
import 'pathe';
|
|
11
|
-
import 'node:assert';
|
|
12
|
-
import 'node:process';
|
|
13
|
-
import 'node:path';
|
|
14
|
-
import 'node:v8';
|
|
15
|
-
import 'node:util';
|
|
16
|
-
import 'std-env';
|
|
17
|
-
import '@vitest/runner/utils';
|
|
18
|
-
import '@vitest/utils';
|
|
19
|
-
|
|
20
|
-
var ModuleFormat = /* @__PURE__ */ ((ModuleFormat2) => {
|
|
21
|
-
ModuleFormat2["Builtin"] = "builtin";
|
|
22
|
-
ModuleFormat2["Commonjs"] = "commonjs";
|
|
23
|
-
ModuleFormat2["Json"] = "json";
|
|
24
|
-
ModuleFormat2["Module"] = "module";
|
|
25
|
-
ModuleFormat2["Wasm"] = "wasm";
|
|
26
|
-
return ModuleFormat2;
|
|
27
|
-
})(ModuleFormat || {});
|
|
28
|
-
|
|
29
|
-
const ESM_RE = /([\s;}]|^)(import[\w,{}\s*]*from|import\s*['"*{]|export\b\s*(?:[*{]|default|class|type|function|const|var|let|async function)|import\.meta\b)/m;
|
|
30
|
-
function hasESMSyntax(code) {
|
|
31
|
-
return ESM_RE.test(code);
|
|
32
|
-
}
|
|
33
|
-
const cache = /* @__PURE__ */ new Map();
|
|
34
|
-
async function getPotentialSource(filepath, result) {
|
|
35
|
-
var _a;
|
|
36
|
-
if (!result.url.startsWith("file://") || result.format === "module")
|
|
37
|
-
return null;
|
|
38
|
-
let source = (_a = cache.get(result.url)) == null ? void 0 : _a.source;
|
|
39
|
-
if (source == null)
|
|
40
|
-
source = await readFile(filepath, "utf8");
|
|
41
|
-
return source;
|
|
42
|
-
}
|
|
43
|
-
function detectESM(url, source) {
|
|
44
|
-
const cached = cache.get(url);
|
|
45
|
-
if (cached)
|
|
46
|
-
return cached.isPseudoESM;
|
|
47
|
-
if (!source)
|
|
48
|
-
return false;
|
|
49
|
-
return hasESMSyntax(source) && !hasCJSSyntax(source);
|
|
50
|
-
}
|
|
51
|
-
const resolve = async (url, context, next) => {
|
|
52
|
-
var _a;
|
|
53
|
-
const { parentURL } = context;
|
|
54
|
-
const state = getWorkerState();
|
|
55
|
-
const resolver = state == null ? void 0 : state.rpc.resolveId;
|
|
56
|
-
const environment = state == null ? void 0 : state.ctx.environment;
|
|
57
|
-
if (!parentURL || isNodeBuiltin(url) || !resolver || !environment)
|
|
58
|
-
return next(url, context, next);
|
|
59
|
-
const id = normalizeModuleId(url);
|
|
60
|
-
const importer = normalizeModuleId(parentURL);
|
|
61
|
-
const resolved = await resolver(id, importer, environment.transformMode ?? ((_a = environment.environment) == null ? void 0 : _a.transformMode) ?? "ssr");
|
|
62
|
-
let result;
|
|
63
|
-
let filepath;
|
|
64
|
-
if (resolved) {
|
|
65
|
-
const resolvedUrl = pathToFileURL(resolved.id).toString();
|
|
66
|
-
filepath = resolved.id;
|
|
67
|
-
result = {
|
|
68
|
-
url: resolvedUrl,
|
|
69
|
-
shortCircuit: true
|
|
70
|
-
};
|
|
71
|
-
} else {
|
|
72
|
-
const { url: resolvedUrl, format } = await next(url, context, next);
|
|
73
|
-
filepath = fileURLToPath(resolvedUrl);
|
|
74
|
-
result = {
|
|
75
|
-
url: resolvedUrl,
|
|
76
|
-
format,
|
|
77
|
-
shortCircuit: true
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
const source = await getPotentialSource(filepath, result);
|
|
81
|
-
const isPseudoESM = detectESM(result.url, source);
|
|
82
|
-
if (typeof source === "string")
|
|
83
|
-
cache.set(result.url, { isPseudoESM, source });
|
|
84
|
-
if (isPseudoESM)
|
|
85
|
-
result.format = ModuleFormat.Module;
|
|
86
|
-
return result;
|
|
87
|
-
};
|
|
88
|
-
const load = async (url, context, next) => {
|
|
89
|
-
const result = await next(url, context, next);
|
|
90
|
-
const cached = cache.get(url);
|
|
91
|
-
if ((cached == null ? void 0 : cached.isPseudoESM) && result.format !== "module") {
|
|
92
|
-
return {
|
|
93
|
-
source: cached.source,
|
|
94
|
-
format: ModuleFormat.Module
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
return result;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export { load, resolve };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
function getWorkerState() {
|
|
2
|
-
return globalThis.__vitest_worker__;
|
|
3
|
-
}
|
|
4
|
-
function getCurrentEnvironment() {
|
|
5
|
-
const state = getWorkerState();
|
|
6
|
-
return state == null ? void 0 : state.environment.name;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export { getCurrentEnvironment as a, getWorkerState as g };
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.7d1333e8.js';
|
|
2
|
-
|
|
3
|
-
const root =
|
|
4
|
-
(typeof globalThis !== "undefined" && globalThis) ||
|
|
5
|
-
(typeof self !== "undefined" && self) ||
|
|
6
|
-
(typeof commonjsGlobal !== "undefined" && commonjsGlobal);
|
|
7
|
-
|
|
8
|
-
function isConstructor(fn) {
|
|
9
|
-
try {
|
|
10
|
-
new fn();
|
|
11
|
-
} catch (error) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (typeof root.Event !== "function" || !isConstructor(root.Event)) {
|
|
18
|
-
root.Event = (function () {
|
|
19
|
-
function Event(type, options) {
|
|
20
|
-
this.bubbles = !!options && !!options.bubbles;
|
|
21
|
-
this.cancelable = !!options && !!options.cancelable;
|
|
22
|
-
this.composed = !!options && !!options.composed;
|
|
23
|
-
this.type = type;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return Event;
|
|
27
|
-
})();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (typeof root.EventTarget === "undefined" || !isConstructor(root.Event)) {
|
|
31
|
-
root.EventTarget = (function () {
|
|
32
|
-
function EventTarget() {
|
|
33
|
-
this.__listeners = new Map();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
EventTarget.prototype = Object.create(Object.prototype);
|
|
37
|
-
|
|
38
|
-
EventTarget.prototype.addEventListener = function (
|
|
39
|
-
type,
|
|
40
|
-
listener,
|
|
41
|
-
options
|
|
42
|
-
) {
|
|
43
|
-
if (arguments.length < 2) {
|
|
44
|
-
throw new TypeError(
|
|
45
|
-
`TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only ${arguments.length} present.`
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
const __listeners = this.__listeners;
|
|
49
|
-
const actualType = type.toString();
|
|
50
|
-
if (!__listeners.has(actualType)) {
|
|
51
|
-
__listeners.set(actualType, new Map());
|
|
52
|
-
}
|
|
53
|
-
const listenersForType = __listeners.get(actualType);
|
|
54
|
-
if (!listenersForType.has(listener)) {
|
|
55
|
-
// Any given listener is only registered once
|
|
56
|
-
listenersForType.set(listener, options);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
EventTarget.prototype.removeEventListener = function (
|
|
61
|
-
type,
|
|
62
|
-
listener,
|
|
63
|
-
_options
|
|
64
|
-
) {
|
|
65
|
-
if (arguments.length < 2) {
|
|
66
|
-
throw new TypeError(
|
|
67
|
-
`TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only ${arguments.length} present.`
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
const __listeners = this.__listeners;
|
|
71
|
-
const actualType = type.toString();
|
|
72
|
-
if (__listeners.has(actualType)) {
|
|
73
|
-
const listenersForType = __listeners.get(actualType);
|
|
74
|
-
if (listenersForType.has(listener)) {
|
|
75
|
-
listenersForType.delete(listener);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
EventTarget.prototype.dispatchEvent = function (event) {
|
|
81
|
-
if (!(event instanceof Event)) {
|
|
82
|
-
throw new TypeError(
|
|
83
|
-
`Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.`
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
const type = event.type;
|
|
87
|
-
const __listeners = this.__listeners;
|
|
88
|
-
const listenersForType = __listeners.get(type);
|
|
89
|
-
if (listenersForType) {
|
|
90
|
-
for (const [listener, options] of listenersForType.entries()) {
|
|
91
|
-
try {
|
|
92
|
-
if (typeof listener === "function") {
|
|
93
|
-
// Listener functions must be executed with the EventTarget as the `this` context.
|
|
94
|
-
listener.call(this, event);
|
|
95
|
-
} else if (listener && typeof listener.handleEvent === "function") {
|
|
96
|
-
// Listener objects have their handleEvent method called, if they have one
|
|
97
|
-
listener.handleEvent(event);
|
|
98
|
-
}
|
|
99
|
-
} catch (err) {
|
|
100
|
-
// We need to report the error to the global error handling event,
|
|
101
|
-
// but we do not want to break the loop that is executing the events.
|
|
102
|
-
// Unfortunately, this is the best we can do, which isn't great, because the
|
|
103
|
-
// native EventTarget will actually do this synchronously before moving to the next
|
|
104
|
-
// event in the loop.
|
|
105
|
-
setTimeout(() => {
|
|
106
|
-
throw err;
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
if (options && options.once) {
|
|
110
|
-
// If this was registered with { once: true }, we need
|
|
111
|
-
// to remove it now.
|
|
112
|
-
listenersForType.delete(listener);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
// Since there are no cancellable events on a base EventTarget,
|
|
117
|
-
// this should always return true.
|
|
118
|
-
return true;
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
return EventTarget;
|
|
122
|
-
})();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
126
|
-
__proto__: null
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
export { index as i };
|