vitest 0.0.113 → 0.0.117
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 +61 -33
- package/dist/cli.js +1112 -35
- package/dist/{constants-900abe4a.js → constants-080f26e8.js} +2 -2
- package/dist/{diff-9c43ab50.js → diff-80c47cfa.js} +1 -2
- package/dist/entry.js +68 -26
- package/dist/{global-75208c77.js → global-d95ee155.js} +8 -9
- package/dist/{index-09437c50.js → index-2b1f526f.js} +2 -2
- package/dist/{index-c3f2f9fe.js → index-33d800eb.js} +182 -111
- package/dist/{index-61c8686f.js → index-648e7ab2.js} +62 -62
- package/dist/index-6e709f57.js +781 -0
- package/dist/index-bf29f0e6.js +386 -0
- package/dist/{index-9f4b9905.js → index-ce49e384.js} +33 -800
- package/dist/index-e909c175.js +62 -0
- package/dist/index.d.ts +97 -35
- package/dist/index.js +6 -4
- package/dist/{jest-mock-a57b745c.js → jest-mock-4a754991.js} +1 -12
- package/dist/node.d.ts +87 -16
- package/dist/node.js +10 -9
- package/dist/rpc-8c7cc374.js +5 -0
- package/dist/setup-95b119ff.js +4318 -0
- package/dist/utils.js +2 -2
- package/dist/{vi-51946984.js → vi-39f06eb7.js} +30 -6
- package/dist/worker.js +25 -40
- package/package.json +7 -6
- package/vitest.mjs +1 -20
- package/dist/index-041e627e.js +0 -168
- package/dist/index-1488b423.js +0 -186
- package/dist/middleware-0ebc5238.js +0 -79
- package/dist/rpc-7de86f29.js +0 -10
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
2
|
+
import require$$0 from 'tty';
|
|
3
|
+
import { isPackageExists } from 'local-pkg';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
|
|
6
|
+
var picocolors = {exports: {}};
|
|
7
|
+
|
|
8
|
+
let tty = require$$0;
|
|
9
|
+
|
|
10
|
+
let isColorSupported =
|
|
11
|
+
!("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
|
|
12
|
+
("FORCE_COLOR" in process.env ||
|
|
13
|
+
process.argv.includes("--color") ||
|
|
14
|
+
process.platform === "win32" ||
|
|
15
|
+
(tty.isatty(1) && process.env.TERM !== "dumb") ||
|
|
16
|
+
"CI" in process.env);
|
|
17
|
+
|
|
18
|
+
let formatter =
|
|
19
|
+
(open, close, replace = open) =>
|
|
20
|
+
input => {
|
|
21
|
+
let string = "" + input;
|
|
22
|
+
let index = string.indexOf(close, open.length);
|
|
23
|
+
return ~index
|
|
24
|
+
? open + replaceClose(string, close, replace, index) + close
|
|
25
|
+
: open + string + close
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
let replaceClose = (string, close, replace, index) => {
|
|
29
|
+
let start = string.substring(0, index) + replace;
|
|
30
|
+
let end = string.substring(index + close.length);
|
|
31
|
+
let nextIndex = end.indexOf(close);
|
|
32
|
+
return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
let createColors = (enabled = isColorSupported) => ({
|
|
36
|
+
isColorSupported: enabled,
|
|
37
|
+
reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
|
|
38
|
+
bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
|
|
39
|
+
dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
|
|
40
|
+
italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
|
|
41
|
+
underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
|
|
42
|
+
inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
|
|
43
|
+
hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
|
|
44
|
+
strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
|
|
45
|
+
black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
|
|
46
|
+
red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
|
|
47
|
+
green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
|
|
48
|
+
yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
|
|
49
|
+
blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
|
|
50
|
+
magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
|
|
51
|
+
cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
|
|
52
|
+
white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
|
|
53
|
+
gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
|
|
54
|
+
bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
|
|
55
|
+
bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
|
|
56
|
+
bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
|
|
57
|
+
bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
|
|
58
|
+
bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
|
|
59
|
+
bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
|
|
60
|
+
bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
|
|
61
|
+
bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
picocolors.exports = createColors();
|
|
65
|
+
picocolors.exports.createColors = createColors;
|
|
66
|
+
|
|
67
|
+
var c = picocolors.exports;
|
|
68
|
+
|
|
69
|
+
function normalizeWindowsPath(input = "") {
|
|
70
|
+
if (!input.includes("\\")) {
|
|
71
|
+
return input;
|
|
72
|
+
}
|
|
73
|
+
return input.replace(/\\/g, "/");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const _UNC_REGEX = /^[/][/]/;
|
|
77
|
+
const _UNC_DRIVE_REGEX = /^[/][/]([.]{1,2}[/])?([a-zA-Z]):[/]/;
|
|
78
|
+
const _IS_ABSOLUTE_RE = /^\/|^\\|^[a-zA-Z]:[/\\]/;
|
|
79
|
+
const sep = "/";
|
|
80
|
+
const delimiter = ":";
|
|
81
|
+
const normalize = function(path2) {
|
|
82
|
+
if (path2.length === 0) {
|
|
83
|
+
return ".";
|
|
84
|
+
}
|
|
85
|
+
path2 = normalizeWindowsPath(path2);
|
|
86
|
+
const isUNCPath = path2.match(_UNC_REGEX);
|
|
87
|
+
const hasUNCDrive = isUNCPath && path2.match(_UNC_DRIVE_REGEX);
|
|
88
|
+
const isPathAbsolute = isAbsolute(path2);
|
|
89
|
+
const trailingSeparator = path2[path2.length - 1] === "/";
|
|
90
|
+
path2 = normalizeString(path2, !isPathAbsolute);
|
|
91
|
+
if (path2.length === 0) {
|
|
92
|
+
if (isPathAbsolute) {
|
|
93
|
+
return "/";
|
|
94
|
+
}
|
|
95
|
+
return trailingSeparator ? "./" : ".";
|
|
96
|
+
}
|
|
97
|
+
if (trailingSeparator) {
|
|
98
|
+
path2 += "/";
|
|
99
|
+
}
|
|
100
|
+
if (isUNCPath) {
|
|
101
|
+
if (hasUNCDrive) {
|
|
102
|
+
return `//./${path2}`;
|
|
103
|
+
}
|
|
104
|
+
return `//${path2}`;
|
|
105
|
+
}
|
|
106
|
+
return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
|
|
107
|
+
};
|
|
108
|
+
const join = function(...args) {
|
|
109
|
+
if (args.length === 0) {
|
|
110
|
+
return ".";
|
|
111
|
+
}
|
|
112
|
+
let joined;
|
|
113
|
+
for (let i = 0; i < args.length; ++i) {
|
|
114
|
+
const arg = args[i];
|
|
115
|
+
if (arg.length > 0) {
|
|
116
|
+
if (joined === void 0) {
|
|
117
|
+
joined = arg;
|
|
118
|
+
} else {
|
|
119
|
+
joined += `/${arg}`;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (joined === void 0) {
|
|
124
|
+
return ".";
|
|
125
|
+
}
|
|
126
|
+
return normalize(joined);
|
|
127
|
+
};
|
|
128
|
+
const resolve = function(...args) {
|
|
129
|
+
args = args.map((arg) => normalizeWindowsPath(arg));
|
|
130
|
+
let resolvedPath = "";
|
|
131
|
+
let resolvedAbsolute = false;
|
|
132
|
+
for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
133
|
+
const path2 = i >= 0 ? args[i] : process.cwd();
|
|
134
|
+
if (path2.length === 0) {
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
resolvedPath = `${path2}/${resolvedPath}`;
|
|
138
|
+
resolvedAbsolute = isAbsolute(path2);
|
|
139
|
+
}
|
|
140
|
+
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
141
|
+
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
142
|
+
return `/${resolvedPath}`;
|
|
143
|
+
}
|
|
144
|
+
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
145
|
+
};
|
|
146
|
+
function normalizeString(path2, allowAboveRoot) {
|
|
147
|
+
let res = "";
|
|
148
|
+
let lastSegmentLength = 0;
|
|
149
|
+
let lastSlash = -1;
|
|
150
|
+
let dots = 0;
|
|
151
|
+
let char = null;
|
|
152
|
+
for (let i = 0; i <= path2.length; ++i) {
|
|
153
|
+
if (i < path2.length) {
|
|
154
|
+
char = path2[i];
|
|
155
|
+
} else if (char === "/") {
|
|
156
|
+
break;
|
|
157
|
+
} else {
|
|
158
|
+
char = "/";
|
|
159
|
+
}
|
|
160
|
+
if (char === "/") {
|
|
161
|
+
if (lastSlash === i - 1 || dots === 1) ; else if (dots === 2) {
|
|
162
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
163
|
+
if (res.length > 2) {
|
|
164
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
165
|
+
if (lastSlashIndex === -1) {
|
|
166
|
+
res = "";
|
|
167
|
+
lastSegmentLength = 0;
|
|
168
|
+
} else {
|
|
169
|
+
res = res.slice(0, lastSlashIndex);
|
|
170
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
171
|
+
}
|
|
172
|
+
lastSlash = i;
|
|
173
|
+
dots = 0;
|
|
174
|
+
continue;
|
|
175
|
+
} else if (res.length !== 0) {
|
|
176
|
+
res = "";
|
|
177
|
+
lastSegmentLength = 0;
|
|
178
|
+
lastSlash = i;
|
|
179
|
+
dots = 0;
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (allowAboveRoot) {
|
|
184
|
+
res += res.length > 0 ? "/.." : "..";
|
|
185
|
+
lastSegmentLength = 2;
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
if (res.length > 0) {
|
|
189
|
+
res += `/${path2.slice(lastSlash + 1, i)}`;
|
|
190
|
+
} else {
|
|
191
|
+
res = path2.slice(lastSlash + 1, i);
|
|
192
|
+
}
|
|
193
|
+
lastSegmentLength = i - lastSlash - 1;
|
|
194
|
+
}
|
|
195
|
+
lastSlash = i;
|
|
196
|
+
dots = 0;
|
|
197
|
+
} else if (char === "." && dots !== -1) {
|
|
198
|
+
++dots;
|
|
199
|
+
} else {
|
|
200
|
+
dots = -1;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return res;
|
|
204
|
+
}
|
|
205
|
+
const isAbsolute = function(p) {
|
|
206
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
207
|
+
};
|
|
208
|
+
const toNamespacedPath = function(p) {
|
|
209
|
+
return normalizeWindowsPath(p);
|
|
210
|
+
};
|
|
211
|
+
const extname = function(p) {
|
|
212
|
+
return path.posix.extname(normalizeWindowsPath(p));
|
|
213
|
+
};
|
|
214
|
+
const relative = function(from, to) {
|
|
215
|
+
return path.posix.relative(normalizeWindowsPath(from), normalizeWindowsPath(to));
|
|
216
|
+
};
|
|
217
|
+
const dirname = function(p) {
|
|
218
|
+
return path.posix.dirname(normalizeWindowsPath(p));
|
|
219
|
+
};
|
|
220
|
+
const format = function(p) {
|
|
221
|
+
return normalizeWindowsPath(path.posix.format(p));
|
|
222
|
+
};
|
|
223
|
+
const basename = function(p, ext) {
|
|
224
|
+
return path.posix.basename(normalizeWindowsPath(p), ext);
|
|
225
|
+
};
|
|
226
|
+
const parse = function(p) {
|
|
227
|
+
return path.posix.parse(normalizeWindowsPath(p));
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
const _path = /*#__PURE__*/Object.freeze({
|
|
231
|
+
__proto__: null,
|
|
232
|
+
sep: sep,
|
|
233
|
+
delimiter: delimiter,
|
|
234
|
+
normalize: normalize,
|
|
235
|
+
join: join,
|
|
236
|
+
resolve: resolve,
|
|
237
|
+
normalizeString: normalizeString,
|
|
238
|
+
isAbsolute: isAbsolute,
|
|
239
|
+
toNamespacedPath: toNamespacedPath,
|
|
240
|
+
extname: extname,
|
|
241
|
+
relative: relative,
|
|
242
|
+
dirname: dirname,
|
|
243
|
+
format: format,
|
|
244
|
+
basename: basename,
|
|
245
|
+
parse: parse
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
const index = {
|
|
249
|
+
..._path
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
const isWindows = process.platform === "win32";
|
|
253
|
+
function toArray(array) {
|
|
254
|
+
array = array || [];
|
|
255
|
+
if (Array.isArray(array))
|
|
256
|
+
return array;
|
|
257
|
+
return [array];
|
|
258
|
+
}
|
|
259
|
+
function notNullish(v) {
|
|
260
|
+
return v != null;
|
|
261
|
+
}
|
|
262
|
+
function slash(str) {
|
|
263
|
+
return str.replace(/\\/g, "/");
|
|
264
|
+
}
|
|
265
|
+
function mergeSlashes(str) {
|
|
266
|
+
return str.replace(/\/\//g, "/");
|
|
267
|
+
}
|
|
268
|
+
const noop = () => {
|
|
269
|
+
};
|
|
270
|
+
function partitionSuiteChildren(suite) {
|
|
271
|
+
let tasksGroup = [];
|
|
272
|
+
const tasksGroups = [];
|
|
273
|
+
for (const c2 of suite.tasks) {
|
|
274
|
+
if (tasksGroup.length === 0 || c2.computeMode === tasksGroup[0].computeMode) {
|
|
275
|
+
tasksGroup.push(c2);
|
|
276
|
+
} else {
|
|
277
|
+
tasksGroups.push(tasksGroup);
|
|
278
|
+
tasksGroup = [c2];
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (tasksGroup.length > 0)
|
|
282
|
+
tasksGroups.push(tasksGroup);
|
|
283
|
+
return tasksGroups;
|
|
284
|
+
}
|
|
285
|
+
function interpretOnlyMode(tasks) {
|
|
286
|
+
if (tasks.some((t) => t.mode === "only")) {
|
|
287
|
+
tasks.forEach((t) => {
|
|
288
|
+
if (t.mode === "run")
|
|
289
|
+
t.mode = "skip";
|
|
290
|
+
else if (t.mode === "only")
|
|
291
|
+
t.mode = "run";
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
tasks.forEach((t) => {
|
|
295
|
+
if (t.type === "suite") {
|
|
296
|
+
if (t.mode === "skip")
|
|
297
|
+
t.tasks.forEach((c2) => c2.mode === "run" && (c2.mode = "skip"));
|
|
298
|
+
else
|
|
299
|
+
interpretOnlyMode(t.tasks);
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
function getTests(suite) {
|
|
304
|
+
return toArray(suite).flatMap((s) => s.type === "test" ? [s] : s.tasks.flatMap((c2) => c2.type === "test" ? [c2] : getTests(c2)));
|
|
305
|
+
}
|
|
306
|
+
function getTasks(tasks) {
|
|
307
|
+
return toArray(tasks).flatMap((s) => s.type === "test" ? [s] : [s, ...getTasks(s.tasks)]);
|
|
308
|
+
}
|
|
309
|
+
function getSuites(suite) {
|
|
310
|
+
return toArray(suite).flatMap((s) => s.type === "suite" ? [s, ...getSuites(s.tasks)] : []);
|
|
311
|
+
}
|
|
312
|
+
function hasTests(suite) {
|
|
313
|
+
return toArray(suite).some((s) => s.tasks.some((c2) => c2.type === "test" || hasTests(c2)));
|
|
314
|
+
}
|
|
315
|
+
function hasFailed(suite) {
|
|
316
|
+
return toArray(suite).some((s) => {
|
|
317
|
+
var _a;
|
|
318
|
+
return ((_a = s.result) == null ? void 0 : _a.state) === "fail" || s.type === "suite" && hasFailed(s.tasks);
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
function getNames(task) {
|
|
322
|
+
const names = [task.name];
|
|
323
|
+
let current = task;
|
|
324
|
+
while ((current == null ? void 0 : current.suite) || (current == null ? void 0 : current.file)) {
|
|
325
|
+
current = current.suite || current.file;
|
|
326
|
+
if (current == null ? void 0 : current.name)
|
|
327
|
+
names.unshift(current.name);
|
|
328
|
+
}
|
|
329
|
+
return names;
|
|
330
|
+
}
|
|
331
|
+
function getFullName(task) {
|
|
332
|
+
return getNames(task).join(c.dim(" > "));
|
|
333
|
+
}
|
|
334
|
+
async function ensurePackageInstalled(dependency, promptInstall = !process.env.CI && process.stdout.isTTY) {
|
|
335
|
+
if (isPackageExists(dependency))
|
|
336
|
+
return true;
|
|
337
|
+
process.stderr.write(c.red(`${c.inverse(c.red(" MISSING DEP "))} Can not find dependency '${dependency}'
|
|
338
|
+
|
|
339
|
+
`));
|
|
340
|
+
if (!promptInstall)
|
|
341
|
+
return false;
|
|
342
|
+
const prompts = await import('./index-fa899e66.js').then(function (n) { return n.i; });
|
|
343
|
+
const { install } = await prompts.prompt({
|
|
344
|
+
type: "confirm",
|
|
345
|
+
name: "install",
|
|
346
|
+
message: c.reset(`Do you want to install ${c.green(dependency)}?`)
|
|
347
|
+
});
|
|
348
|
+
if (install) {
|
|
349
|
+
await (await import('./index-ce49e384.js')).installPackage(dependency, { dev: true });
|
|
350
|
+
return true;
|
|
351
|
+
}
|
|
352
|
+
return false;
|
|
353
|
+
}
|
|
354
|
+
function deepMerge(target, ...sources) {
|
|
355
|
+
if (!sources.length)
|
|
356
|
+
return target;
|
|
357
|
+
const source = sources.shift();
|
|
358
|
+
if (source === void 0)
|
|
359
|
+
return target;
|
|
360
|
+
if (isMergableObject(target) && isMergableObject(source)) {
|
|
361
|
+
Object.keys(source).forEach((key) => {
|
|
362
|
+
if (isMergableObject(source[key])) {
|
|
363
|
+
if (!target[key])
|
|
364
|
+
target[key] = {};
|
|
365
|
+
deepMerge(target[key], source[key]);
|
|
366
|
+
} else {
|
|
367
|
+
target[key] = source[key];
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
return deepMerge(target, ...sources);
|
|
372
|
+
}
|
|
373
|
+
function isMergableObject(item) {
|
|
374
|
+
return isObject(item) && !Array.isArray(item);
|
|
375
|
+
}
|
|
376
|
+
function isObject(val) {
|
|
377
|
+
return toString.call(val) === "[object Object]";
|
|
378
|
+
}
|
|
379
|
+
function toFilePath(id, root) {
|
|
380
|
+
let absolute = slash(id).startsWith("/@fs/") ? id.slice(4) : id.startsWith(dirname(root)) ? id : id.startsWith("/") ? slash(resolve(root, id.slice(1))) : id;
|
|
381
|
+
if (absolute.startsWith("//"))
|
|
382
|
+
absolute = absolute.slice(1);
|
|
383
|
+
return isWindows && absolute.startsWith("/") ? fileURLToPath(pathToFileURL(absolute.slice(1)).href) : absolute;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export { isAbsolute as a, basename as b, c, dirname as d, ensurePackageInstalled as e, getSuites as f, getFullName as g, hasFailed as h, isObject as i, getTests as j, resolve as k, deepMerge as l, toFilePath as m, noop as n, notNullish as o, mergeSlashes as p, index as q, relative as r, slash as s, toArray as t, getNames as u, interpretOnlyMode as v, partitionSuiteChildren as w, hasTests as x, isWindows as y, getTasks as z };
|