vitest 0.26.3 → 0.27.1
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 +15 -66
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +15 -15
- package/dist/{chunk-api-setup.47a09f0f.js → chunk-api-setup.2be3cc38.js} +60 -31
- package/dist/{chunk-install-pkg.6dd2bae6.js → chunk-install-pkg.7b006b3e.js} +8 -8
- package/dist/{chunk-integrations-coverage.befed097.js → chunk-integrations-coverage.44413252.js} +19 -1
- package/dist/chunk-integrations-globals.02f1259c.js +27 -0
- package/dist/{chunk-typecheck-constants.06e1fe5b.js → chunk-mock-date.149ed990.js} +19 -32
- package/dist/{chunk-node-git.a90c0582.js → chunk-node-git.125c9008.js} +3 -4
- package/dist/{chunk-runtime-chain.f51aa930.js → chunk-runtime-chain.4e2aa823.js} +1193 -1029
- package/dist/{chunk-runtime-error.f5c8aaf2.js → chunk-runtime-error.97854396.js} +2 -2
- package/dist/{chunk-runtime-mocker.887bf8c8.js → chunk-runtime-mocker.4755840f.js} +10 -8
- package/dist/{chunk-runtime-rpc.54d72169.js → chunk-runtime-rpc.25cc9413.js} +2 -2
- package/dist/{chunk-runtime-setup.a06d5c72.js → chunk-runtime-setup.56d71d30.js} +51 -52
- package/dist/{chunk-snapshot-manager.70695b70.js → chunk-snapshot-manager.1a2dbf96.js} +468 -302
- package/dist/{chunk-utils-env.3fdc1793.js → chunk-utils-env.f4a39d2c.js} +8 -70
- package/dist/{chunk-utils-import.e7f64637.js → chunk-utils-import.16d9fb0d.js} +22 -8
- package/dist/chunk-utils-source-map.4e9b891d.js +408 -0
- package/dist/{chunk-utils-timers.715da787.js → chunk-utils-timers.52534f96.js} +2977 -3458
- package/dist/cli-wrapper.js +15 -15
- package/dist/cli.js +15 -627
- package/dist/config.cjs +2 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +2 -1
- package/dist/entry.js +14 -14
- package/dist/environments.d.ts +1 -1
- package/dist/{index-761e769b.d.ts → index-1cfc7f58.d.ts} +4 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +12 -12
- package/dist/loader.js +9 -10
- package/dist/node.d.ts +2 -2
- package/dist/node.js +14 -12
- package/dist/spy.js +2 -102
- package/dist/suite.js +10 -10
- package/dist/{types-bae746aa.d.ts → types-5617096e.d.ts} +97 -77
- package/dist/{vendor-index.b2fdde54.js → vendor-index.451e37bc.js} +1 -1
- package/dist/vendor-index.723a074f.js +102 -0
- package/dist/vendor-index.b0346fe4.js +395 -0
- package/dist/{vendor-index.7a2cebfe.js → vendor-index.e6c27006.js} +12 -12
- package/dist/worker.js +24 -19
- package/package.json +13 -8
- package/dist/chunk-integrations-globals.ee28730b.js +0 -27
- package/dist/chunk-utils-source-map.5278ee22.js +0 -86
- package/dist/vendor-index.2e96c50b.js +0 -215
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { b as resolve } from './chunk-utils-env.3fdc1793.js';
|
|
2
|
-
import { k as notNullish } from './chunk-typecheck-constants.06e1fe5b.js';
|
|
3
|
-
|
|
4
|
-
const lineSplitRE = /\r?\n/;
|
|
5
|
-
const stackIgnorePatterns = [
|
|
6
|
-
"node:internal",
|
|
7
|
-
"/vitest/dist/",
|
|
8
|
-
"/vitest/src/",
|
|
9
|
-
"/vite-node/dist/",
|
|
10
|
-
"/vite-node/src/",
|
|
11
|
-
"/node_modules/chai/",
|
|
12
|
-
"/node_modules/tinypool/",
|
|
13
|
-
"/node_modules/tinyspy/"
|
|
14
|
-
];
|
|
15
|
-
function extractLocation(urlLike) {
|
|
16
|
-
if (!urlLike.includes(":"))
|
|
17
|
-
return [urlLike];
|
|
18
|
-
const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
|
|
19
|
-
const parts = regExp.exec(urlLike.replace(/[()]/g, ""));
|
|
20
|
-
if (!parts)
|
|
21
|
-
return [urlLike];
|
|
22
|
-
return [parts[1], parts[2] || void 0, parts[3] || void 0];
|
|
23
|
-
}
|
|
24
|
-
function parseStacktrace(e, full = false) {
|
|
25
|
-
if (!e)
|
|
26
|
-
return [];
|
|
27
|
-
if (e.stacks)
|
|
28
|
-
return e.stacks;
|
|
29
|
-
const stackStr = e.stack || e.stackStr || "";
|
|
30
|
-
const stackFrames = stackStr.split("\n").map((raw) => {
|
|
31
|
-
let line = raw.trim();
|
|
32
|
-
if (line.includes("(eval "))
|
|
33
|
-
line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
|
|
34
|
-
let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
|
|
35
|
-
const location = sanitizedLine.match(/ (\(.+\)$)/);
|
|
36
|
-
sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
|
|
37
|
-
const [url, lineNumber, columnNumber] = extractLocation(location ? location[1] : sanitizedLine);
|
|
38
|
-
let method = location && sanitizedLine || "";
|
|
39
|
-
let file = url && ["eval", "<anonymous>"].includes(url) ? void 0 : url;
|
|
40
|
-
if (!file || !lineNumber || !columnNumber)
|
|
41
|
-
return null;
|
|
42
|
-
if (method.startsWith("async "))
|
|
43
|
-
method = method.slice(6);
|
|
44
|
-
if (file.startsWith("file://"))
|
|
45
|
-
file = file.slice(7);
|
|
46
|
-
file = resolve(file);
|
|
47
|
-
if (!full && stackIgnorePatterns.some((p) => file && file.includes(p)))
|
|
48
|
-
return null;
|
|
49
|
-
return {
|
|
50
|
-
method,
|
|
51
|
-
file,
|
|
52
|
-
line: parseInt(lineNumber),
|
|
53
|
-
column: parseInt(columnNumber)
|
|
54
|
-
};
|
|
55
|
-
}).filter(notNullish);
|
|
56
|
-
e.stacks = stackFrames;
|
|
57
|
-
return stackFrames;
|
|
58
|
-
}
|
|
59
|
-
function positionToOffset(source, lineNumber, columnNumber) {
|
|
60
|
-
const lines = source.split(lineSplitRE);
|
|
61
|
-
let start = 0;
|
|
62
|
-
if (lineNumber > lines.length)
|
|
63
|
-
return source.length;
|
|
64
|
-
for (let i = 0; i < lineNumber - 1; i++)
|
|
65
|
-
start += lines[i].length + 1;
|
|
66
|
-
return start + columnNumber;
|
|
67
|
-
}
|
|
68
|
-
function offsetToLineNumber(source, offset) {
|
|
69
|
-
if (offset > source.length) {
|
|
70
|
-
throw new Error(
|
|
71
|
-
`offset is longer than source length! offset ${offset} > length ${source.length}`
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
const lines = source.split(lineSplitRE);
|
|
75
|
-
let counted = 0;
|
|
76
|
-
let line = 0;
|
|
77
|
-
for (; line < lines.length; line++) {
|
|
78
|
-
const lineLength = lines[line].length + 1;
|
|
79
|
-
if (counted + lineLength >= offset)
|
|
80
|
-
break;
|
|
81
|
-
counted += lineLength;
|
|
82
|
-
}
|
|
83
|
-
return line + 1;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export { positionToOffset as a, lineSplitRE as l, offsetToLineNumber as o, parseStacktrace as p };
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import 'acorn';
|
|
2
|
-
import { builtinModules } from 'node:module';
|
|
3
|
-
import 'node:fs';
|
|
4
|
-
import { pathToFileURL } from 'node:url';
|
|
5
|
-
import 'url';
|
|
6
|
-
import 'fs';
|
|
7
|
-
import 'path';
|
|
8
|
-
import 'module';
|
|
9
|
-
import assert from 'assert';
|
|
10
|
-
import { format, inspect } from 'util';
|
|
11
|
-
import 'node:path';
|
|
12
|
-
|
|
13
|
-
const BUILTIN_MODULES = new Set(builtinModules);
|
|
14
|
-
|
|
15
|
-
const isWindows = process.platform === "win32";
|
|
16
|
-
const own$1 = {}.hasOwnProperty;
|
|
17
|
-
const messages = /* @__PURE__ */ new Map();
|
|
18
|
-
const nodeInternalPrefix = "__node_internal_";
|
|
19
|
-
let userStackTraceLimit;
|
|
20
|
-
createError(
|
|
21
|
-
"ERR_INVALID_MODULE_SPECIFIER",
|
|
22
|
-
(request, reason, base = void 0) => {
|
|
23
|
-
return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
|
|
24
|
-
},
|
|
25
|
-
TypeError
|
|
26
|
-
);
|
|
27
|
-
createError(
|
|
28
|
-
"ERR_INVALID_PACKAGE_CONFIG",
|
|
29
|
-
(path, base, message) => {
|
|
30
|
-
return `Invalid package config ${path}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
|
|
31
|
-
},
|
|
32
|
-
Error
|
|
33
|
-
);
|
|
34
|
-
createError(
|
|
35
|
-
"ERR_INVALID_PACKAGE_TARGET",
|
|
36
|
-
(pkgPath, key, target, isImport = false, base = void 0) => {
|
|
37
|
-
const relError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
|
|
38
|
-
if (key === ".") {
|
|
39
|
-
assert(isImport === false);
|
|
40
|
-
return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ""}${relError ? '; targets must start with "./"' : ""}`;
|
|
41
|
-
}
|
|
42
|
-
return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(
|
|
43
|
-
target
|
|
44
|
-
)} defined for '${key}' in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ""}${relError ? '; targets must start with "./"' : ""}`;
|
|
45
|
-
},
|
|
46
|
-
Error
|
|
47
|
-
);
|
|
48
|
-
createError(
|
|
49
|
-
"ERR_MODULE_NOT_FOUND",
|
|
50
|
-
(path, base, type = "package") => {
|
|
51
|
-
return `Cannot find ${type} '${path}' imported from ${base}`;
|
|
52
|
-
},
|
|
53
|
-
Error
|
|
54
|
-
);
|
|
55
|
-
createError(
|
|
56
|
-
"ERR_PACKAGE_IMPORT_NOT_DEFINED",
|
|
57
|
-
(specifier, packagePath, base) => {
|
|
58
|
-
return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ""} imported from ${base}`;
|
|
59
|
-
},
|
|
60
|
-
TypeError
|
|
61
|
-
);
|
|
62
|
-
createError(
|
|
63
|
-
"ERR_PACKAGE_PATH_NOT_EXPORTED",
|
|
64
|
-
(pkgPath, subpath, base = void 0) => {
|
|
65
|
-
if (subpath === ".") {
|
|
66
|
-
return `No "exports" main defined in ${pkgPath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
67
|
-
}
|
|
68
|
-
return `Package subpath '${subpath}' is not defined by "exports" in ${pkgPath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
69
|
-
},
|
|
70
|
-
Error
|
|
71
|
-
);
|
|
72
|
-
createError(
|
|
73
|
-
"ERR_UNSUPPORTED_DIR_IMPORT",
|
|
74
|
-
"Directory import '%s' is not supported resolving ES modules imported from %s",
|
|
75
|
-
Error
|
|
76
|
-
);
|
|
77
|
-
createError(
|
|
78
|
-
"ERR_UNKNOWN_FILE_EXTENSION",
|
|
79
|
-
'Unknown file extension "%s" for %s',
|
|
80
|
-
TypeError
|
|
81
|
-
);
|
|
82
|
-
createError(
|
|
83
|
-
"ERR_INVALID_ARG_VALUE",
|
|
84
|
-
(name, value, reason = "is invalid") => {
|
|
85
|
-
let inspected = inspect(value);
|
|
86
|
-
if (inspected.length > 128) {
|
|
87
|
-
inspected = `${inspected.slice(0, 128)}...`;
|
|
88
|
-
}
|
|
89
|
-
const type = name.includes(".") ? "property" : "argument";
|
|
90
|
-
return `The ${type} '${name}' ${reason}. Received ${inspected}`;
|
|
91
|
-
},
|
|
92
|
-
TypeError
|
|
93
|
-
);
|
|
94
|
-
createError(
|
|
95
|
-
"ERR_UNSUPPORTED_ESM_URL_SCHEME",
|
|
96
|
-
(url) => {
|
|
97
|
-
let message = "Only file and data URLs are supported by the default ESM loader";
|
|
98
|
-
if (isWindows && url.protocol.length === 2) {
|
|
99
|
-
message += ". On Windows, absolute paths must be valid file:// URLs";
|
|
100
|
-
}
|
|
101
|
-
message += `. Received protocol '${url.protocol}'`;
|
|
102
|
-
return message;
|
|
103
|
-
},
|
|
104
|
-
Error
|
|
105
|
-
);
|
|
106
|
-
function createError(sym, value, def) {
|
|
107
|
-
messages.set(sym, value);
|
|
108
|
-
return makeNodeErrorWithCode(def, sym);
|
|
109
|
-
}
|
|
110
|
-
function makeNodeErrorWithCode(Base, key) {
|
|
111
|
-
return NodeError;
|
|
112
|
-
function NodeError(...args) {
|
|
113
|
-
const limit = Error.stackTraceLimit;
|
|
114
|
-
if (isErrorStackTraceLimitWritable()) {
|
|
115
|
-
Error.stackTraceLimit = 0;
|
|
116
|
-
}
|
|
117
|
-
const error = new Base();
|
|
118
|
-
if (isErrorStackTraceLimitWritable()) {
|
|
119
|
-
Error.stackTraceLimit = limit;
|
|
120
|
-
}
|
|
121
|
-
const message = getMessage(key, args, error);
|
|
122
|
-
Object.defineProperty(error, "message", {
|
|
123
|
-
value: message,
|
|
124
|
-
enumerable: false,
|
|
125
|
-
writable: true,
|
|
126
|
-
configurable: true
|
|
127
|
-
});
|
|
128
|
-
Object.defineProperty(error, "toString", {
|
|
129
|
-
value() {
|
|
130
|
-
return `${this.name} [${key}]: ${this.message}`;
|
|
131
|
-
},
|
|
132
|
-
enumerable: false,
|
|
133
|
-
writable: true,
|
|
134
|
-
configurable: true
|
|
135
|
-
});
|
|
136
|
-
addCodeToName(error, Base.name, key);
|
|
137
|
-
error.code = key;
|
|
138
|
-
return error;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
const addCodeToName = hideStackFrames(
|
|
142
|
-
function(error, name, code) {
|
|
143
|
-
error = captureLargerStackTrace(error);
|
|
144
|
-
error.name = `${name} [${code}]`;
|
|
145
|
-
error.stack;
|
|
146
|
-
if (name === "SystemError") {
|
|
147
|
-
Object.defineProperty(error, "name", {
|
|
148
|
-
value: name,
|
|
149
|
-
enumerable: false,
|
|
150
|
-
writable: true,
|
|
151
|
-
configurable: true
|
|
152
|
-
});
|
|
153
|
-
} else {
|
|
154
|
-
delete error.name;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
);
|
|
158
|
-
function isErrorStackTraceLimitWritable() {
|
|
159
|
-
const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
|
|
160
|
-
if (desc === void 0) {
|
|
161
|
-
return Object.isExtensible(Error);
|
|
162
|
-
}
|
|
163
|
-
return own$1.call(desc, "writable") ? desc.writable : desc.set !== void 0;
|
|
164
|
-
}
|
|
165
|
-
function hideStackFrames(fn) {
|
|
166
|
-
const hidden = nodeInternalPrefix + fn.name;
|
|
167
|
-
Object.defineProperty(fn, "name", { value: hidden });
|
|
168
|
-
return fn;
|
|
169
|
-
}
|
|
170
|
-
const captureLargerStackTrace = hideStackFrames(
|
|
171
|
-
function(error) {
|
|
172
|
-
const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
|
|
173
|
-
if (stackTraceLimitIsWritable) {
|
|
174
|
-
userStackTraceLimit = Error.stackTraceLimit;
|
|
175
|
-
Error.stackTraceLimit = Number.POSITIVE_INFINITY;
|
|
176
|
-
}
|
|
177
|
-
Error.captureStackTrace(error);
|
|
178
|
-
if (stackTraceLimitIsWritable) {
|
|
179
|
-
Error.stackTraceLimit = userStackTraceLimit;
|
|
180
|
-
}
|
|
181
|
-
return error;
|
|
182
|
-
}
|
|
183
|
-
);
|
|
184
|
-
function getMessage(key, args, self) {
|
|
185
|
-
const message = messages.get(key);
|
|
186
|
-
if (typeof message === "function") {
|
|
187
|
-
assert(
|
|
188
|
-
message.length <= args.length,
|
|
189
|
-
`Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${message.length}).`
|
|
190
|
-
);
|
|
191
|
-
return Reflect.apply(message, self, args);
|
|
192
|
-
}
|
|
193
|
-
const expectedLength = (message.match(/%[dfijoOs]/g) || []).length;
|
|
194
|
-
assert(
|
|
195
|
-
expectedLength === args.length,
|
|
196
|
-
`Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${expectedLength}).`
|
|
197
|
-
);
|
|
198
|
-
if (args.length === 0) {
|
|
199
|
-
return message;
|
|
200
|
-
}
|
|
201
|
-
args.unshift(message);
|
|
202
|
-
return Reflect.apply(format, null, args);
|
|
203
|
-
}
|
|
204
|
-
Object.freeze(["node", "import"]);
|
|
205
|
-
function isNodeBuiltin(id = "") {
|
|
206
|
-
id = id.replace(/^node:/, "").split("/")[0];
|
|
207
|
-
return BUILTIN_MODULES.has(id);
|
|
208
|
-
}
|
|
209
|
-
pathToFileURL(process.cwd());
|
|
210
|
-
const CJS_RE = /([\s;]|^)(module.exports\b|exports\.\w|require\s*\(|global\.\w)/m;
|
|
211
|
-
function hasCJSSyntax(code) {
|
|
212
|
-
return CJS_RE.test(code);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
export { hasCJSSyntax as h, isNodeBuiltin as i };
|