vitest 0.21.1 → 0.23.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/LICENSE.md +61 -33
- package/dist/browser.d.ts +5 -5
- package/dist/browser.mjs +12 -10
- package/dist/{chunk-api-setup.7a6ba7fb.mjs → chunk-api-setup.5fc06d1d.mjs} +94 -91
- package/dist/chunk-constants.6196597b.mjs +284 -0
- package/dist/chunk-env-node.ceb43f1c.mjs +403 -0
- package/dist/{chunk-install-pkg.6c6dc0c2.mjs → chunk-install-pkg.e081fc1b.mjs} +2 -1
- package/dist/chunk-integrations-coverage.99c020eb.mjs +166 -0
- package/dist/{chunk-integrations-globals.44a8f047.mjs → chunk-integrations-globals.ef598c23.mjs} +8 -9
- package/dist/{chunk-magic-string.efe26975.mjs → chunk-magic-string.56b2b543.mjs} +30 -10
- package/dist/chunk-mock-date.0d86eaa5.mjs +332 -0
- package/dist/chunk-node-git.6f289b0a.mjs +84 -0
- package/dist/{chunk-runtime-chain.98d42d89.mjs → chunk-runtime-chain.2af36ddf.mjs} +507 -172
- package/dist/{chunk-runtime-error.87a2b5a2.mjs → chunk-runtime-error.ed9b4f70.mjs} +208 -76
- package/dist/{chunk-runtime-hooks.453f8858.mjs → chunk-runtime-hooks.75ce0575.mjs} +18 -12
- package/dist/{chunk-runtime-mocker.23b62bfa.mjs → chunk-runtime-mocker.fc76f21d.mjs} +18 -11
- package/dist/{chunk-runtime-rpc.b50ab560.mjs → chunk-runtime-rpc.3fe371e9.mjs} +1 -2
- package/dist/{chunk-utils-source-map.94107ee8.mjs → chunk-utils-source-map.70ee97e1.mjs} +11 -4
- package/dist/{chunk-vite-node-client.fdd9592c.mjs → chunk-vite-node-client.74ebe3d5.mjs} +97 -31
- package/dist/{chunk-vite-node-debug.09afb76f.mjs → chunk-vite-node-debug.2d8a1dc3.mjs} +3 -3
- package/dist/{chunk-vite-node-externalize.27aee038.mjs → chunk-vite-node-externalize.41bf722e.mjs} +644 -222
- package/dist/{chunk-vite-node-utils.f34df9d3.mjs → chunk-vite-node-utils.68573626.mjs} +60 -42
- package/dist/cli-wrapper.mjs +128 -0
- package/dist/cli.mjs +29 -20
- package/dist/config.cjs +5 -2
- package/dist/config.d.ts +8 -4
- package/dist/config.mjs +4 -3
- package/dist/entry.mjs +20 -15
- package/dist/environments.d.ts +23 -0
- package/dist/environments.mjs +3 -0
- package/dist/{global-60f880c6.d.ts → global-ea084c9f.d.ts} +627 -178
- package/dist/{index-4a906fa4.d.ts → index-5f09f4d0.d.ts} +3 -50
- package/dist/index.d.ts +6 -6
- package/dist/index.mjs +7 -6
- package/dist/loader.mjs +3 -3
- package/dist/node.d.ts +5 -4
- package/dist/node.mjs +19 -16
- package/dist/suite.mjs +6 -5
- package/dist/vendor-index.0557b03a.mjs +147 -0
- package/dist/vendor-index.13e3bda3.mjs +61 -0
- package/dist/{chunk-node-git.c2be9c49.mjs → vendor-index.4aeeb598.mjs} +4 -72
- package/dist/{vendor-index.61438b77.mjs → vendor-index.731a22f2.mjs} +1 -61
- package/dist/worker.mjs +20 -18
- package/package.json +19 -16
- package/vitest.mjs +1 -1
- package/dist/chunk-constants.26dc9f85.mjs +0 -38
- package/dist/chunk-defaults.02abff90.mjs +0 -680
- package/dist/chunk-mock-date.bc81a3ac.mjs +0 -555
- package/dist/chunk-utils-global.fa20c2f6.mjs +0 -5
- package/dist/mocker-5e2a8e41.d.ts +0 -3
|
@@ -1,555 +0,0 @@
|
|
|
1
|
-
import path, { relative as relative$1 } from 'path';
|
|
2
|
-
import require$$0 from 'tty';
|
|
3
|
-
import { isPackageExists } from 'local-pkg';
|
|
4
|
-
|
|
5
|
-
var picocolors = {exports: {}};
|
|
6
|
-
|
|
7
|
-
let tty = require$$0;
|
|
8
|
-
|
|
9
|
-
let isColorSupported =
|
|
10
|
-
!("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
|
|
11
|
-
("FORCE_COLOR" in process.env ||
|
|
12
|
-
process.argv.includes("--color") ||
|
|
13
|
-
process.platform === "win32" ||
|
|
14
|
-
(tty.isatty(1) && process.env.TERM !== "dumb") ||
|
|
15
|
-
"CI" in process.env);
|
|
16
|
-
|
|
17
|
-
let formatter =
|
|
18
|
-
(open, close, replace = open) =>
|
|
19
|
-
input => {
|
|
20
|
-
let string = "" + input;
|
|
21
|
-
let index = string.indexOf(close, open.length);
|
|
22
|
-
return ~index
|
|
23
|
-
? open + replaceClose(string, close, replace, index) + close
|
|
24
|
-
: open + string + close
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
let replaceClose = (string, close, replace, index) => {
|
|
28
|
-
let start = string.substring(0, index) + replace;
|
|
29
|
-
let end = string.substring(index + close.length);
|
|
30
|
-
let nextIndex = end.indexOf(close);
|
|
31
|
-
return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
let createColors = (enabled = isColorSupported) => ({
|
|
35
|
-
isColorSupported: enabled,
|
|
36
|
-
reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
|
|
37
|
-
bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
|
|
38
|
-
dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
|
|
39
|
-
italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
|
|
40
|
-
underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
|
|
41
|
-
inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
|
|
42
|
-
hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
|
|
43
|
-
strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
|
|
44
|
-
black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
|
|
45
|
-
red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
|
|
46
|
-
green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
|
|
47
|
-
yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
|
|
48
|
-
blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
|
|
49
|
-
magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
|
|
50
|
-
cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
|
|
51
|
-
white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
|
|
52
|
-
gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
|
|
53
|
-
bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
|
|
54
|
-
bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
|
|
55
|
-
bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
|
|
56
|
-
bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
|
|
57
|
-
bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
|
|
58
|
-
bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
|
|
59
|
-
bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
|
|
60
|
-
bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
picocolors.exports = createColors();
|
|
64
|
-
picocolors.exports.createColors = createColors;
|
|
65
|
-
|
|
66
|
-
function normalizeWindowsPath(input = "") {
|
|
67
|
-
if (!input.includes("\\")) {
|
|
68
|
-
return input;
|
|
69
|
-
}
|
|
70
|
-
return input.replace(/\\/g, "/");
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const _UNC_REGEX = /^[/][/]/;
|
|
74
|
-
const _UNC_DRIVE_REGEX = /^[/][/]([.]{1,2}[/])?([a-zA-Z]):[/]/;
|
|
75
|
-
const _IS_ABSOLUTE_RE = /^\/|^\\|^[a-zA-Z]:[/\\]/;
|
|
76
|
-
const sep = "/";
|
|
77
|
-
const delimiter = ":";
|
|
78
|
-
const normalize = function(path2) {
|
|
79
|
-
if (path2.length === 0) {
|
|
80
|
-
return ".";
|
|
81
|
-
}
|
|
82
|
-
path2 = normalizeWindowsPath(path2);
|
|
83
|
-
const isUNCPath = path2.match(_UNC_REGEX);
|
|
84
|
-
const hasUNCDrive = isUNCPath && path2.match(_UNC_DRIVE_REGEX);
|
|
85
|
-
const isPathAbsolute = isAbsolute(path2);
|
|
86
|
-
const trailingSeparator = path2[path2.length - 1] === "/";
|
|
87
|
-
path2 = normalizeString(path2, !isPathAbsolute);
|
|
88
|
-
if (path2.length === 0) {
|
|
89
|
-
if (isPathAbsolute) {
|
|
90
|
-
return "/";
|
|
91
|
-
}
|
|
92
|
-
return trailingSeparator ? "./" : ".";
|
|
93
|
-
}
|
|
94
|
-
if (trailingSeparator) {
|
|
95
|
-
path2 += "/";
|
|
96
|
-
}
|
|
97
|
-
if (isUNCPath) {
|
|
98
|
-
if (hasUNCDrive) {
|
|
99
|
-
return `//./${path2}`;
|
|
100
|
-
}
|
|
101
|
-
return `//${path2}`;
|
|
102
|
-
}
|
|
103
|
-
return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
|
|
104
|
-
};
|
|
105
|
-
const join = function(...args) {
|
|
106
|
-
if (args.length === 0) {
|
|
107
|
-
return ".";
|
|
108
|
-
}
|
|
109
|
-
let joined;
|
|
110
|
-
for (let i = 0; i < args.length; ++i) {
|
|
111
|
-
const arg = args[i];
|
|
112
|
-
if (arg.length > 0) {
|
|
113
|
-
if (joined === void 0) {
|
|
114
|
-
joined = arg;
|
|
115
|
-
} else {
|
|
116
|
-
joined += `/${arg}`;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
if (joined === void 0) {
|
|
121
|
-
return ".";
|
|
122
|
-
}
|
|
123
|
-
return normalize(joined);
|
|
124
|
-
};
|
|
125
|
-
const resolve = function(...args) {
|
|
126
|
-
args = args.map((arg) => normalizeWindowsPath(arg));
|
|
127
|
-
let resolvedPath = "";
|
|
128
|
-
let resolvedAbsolute = false;
|
|
129
|
-
for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
130
|
-
const path2 = i >= 0 ? args[i] : process.cwd();
|
|
131
|
-
if (path2.length === 0) {
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
resolvedPath = `${path2}/${resolvedPath}`;
|
|
135
|
-
resolvedAbsolute = isAbsolute(path2);
|
|
136
|
-
}
|
|
137
|
-
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
138
|
-
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
139
|
-
return `/${resolvedPath}`;
|
|
140
|
-
}
|
|
141
|
-
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
142
|
-
};
|
|
143
|
-
function normalizeString(path2, allowAboveRoot) {
|
|
144
|
-
let res = "";
|
|
145
|
-
let lastSegmentLength = 0;
|
|
146
|
-
let lastSlash = -1;
|
|
147
|
-
let dots = 0;
|
|
148
|
-
let char = null;
|
|
149
|
-
for (let i = 0; i <= path2.length; ++i) {
|
|
150
|
-
if (i < path2.length) {
|
|
151
|
-
char = path2[i];
|
|
152
|
-
} else if (char === "/") {
|
|
153
|
-
break;
|
|
154
|
-
} else {
|
|
155
|
-
char = "/";
|
|
156
|
-
}
|
|
157
|
-
if (char === "/") {
|
|
158
|
-
if (lastSlash === i - 1 || dots === 1) ; else if (dots === 2) {
|
|
159
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
160
|
-
if (res.length > 2) {
|
|
161
|
-
const lastSlashIndex = res.lastIndexOf("/");
|
|
162
|
-
if (lastSlashIndex === -1) {
|
|
163
|
-
res = "";
|
|
164
|
-
lastSegmentLength = 0;
|
|
165
|
-
} else {
|
|
166
|
-
res = res.slice(0, lastSlashIndex);
|
|
167
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
168
|
-
}
|
|
169
|
-
lastSlash = i;
|
|
170
|
-
dots = 0;
|
|
171
|
-
continue;
|
|
172
|
-
} else if (res.length !== 0) {
|
|
173
|
-
res = "";
|
|
174
|
-
lastSegmentLength = 0;
|
|
175
|
-
lastSlash = i;
|
|
176
|
-
dots = 0;
|
|
177
|
-
continue;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
if (allowAboveRoot) {
|
|
181
|
-
res += res.length > 0 ? "/.." : "..";
|
|
182
|
-
lastSegmentLength = 2;
|
|
183
|
-
}
|
|
184
|
-
} else {
|
|
185
|
-
if (res.length > 0) {
|
|
186
|
-
res += `/${path2.slice(lastSlash + 1, i)}`;
|
|
187
|
-
} else {
|
|
188
|
-
res = path2.slice(lastSlash + 1, i);
|
|
189
|
-
}
|
|
190
|
-
lastSegmentLength = i - lastSlash - 1;
|
|
191
|
-
}
|
|
192
|
-
lastSlash = i;
|
|
193
|
-
dots = 0;
|
|
194
|
-
} else if (char === "." && dots !== -1) {
|
|
195
|
-
++dots;
|
|
196
|
-
} else {
|
|
197
|
-
dots = -1;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return res;
|
|
201
|
-
}
|
|
202
|
-
const isAbsolute = function(p) {
|
|
203
|
-
return _IS_ABSOLUTE_RE.test(p);
|
|
204
|
-
};
|
|
205
|
-
const toNamespacedPath = function(p) {
|
|
206
|
-
return normalizeWindowsPath(p);
|
|
207
|
-
};
|
|
208
|
-
const extname = function(p) {
|
|
209
|
-
return path.posix.extname(normalizeWindowsPath(p));
|
|
210
|
-
};
|
|
211
|
-
const relative = function(from, to) {
|
|
212
|
-
return path.posix.relative(normalizeWindowsPath(from), normalizeWindowsPath(to));
|
|
213
|
-
};
|
|
214
|
-
const dirname = function(p) {
|
|
215
|
-
return path.posix.dirname(normalizeWindowsPath(p));
|
|
216
|
-
};
|
|
217
|
-
const format = function(p) {
|
|
218
|
-
return normalizeWindowsPath(path.posix.format(p));
|
|
219
|
-
};
|
|
220
|
-
const basename = function(p, ext) {
|
|
221
|
-
return path.posix.basename(normalizeWindowsPath(p), ext);
|
|
222
|
-
};
|
|
223
|
-
const parse = function(p) {
|
|
224
|
-
return path.posix.parse(normalizeWindowsPath(p));
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
const _path = /*#__PURE__*/Object.freeze({
|
|
228
|
-
__proto__: null,
|
|
229
|
-
sep: sep,
|
|
230
|
-
delimiter: delimiter,
|
|
231
|
-
normalize: normalize,
|
|
232
|
-
join: join,
|
|
233
|
-
resolve: resolve,
|
|
234
|
-
normalizeString: normalizeString,
|
|
235
|
-
isAbsolute: isAbsolute,
|
|
236
|
-
toNamespacedPath: toNamespacedPath,
|
|
237
|
-
extname: extname,
|
|
238
|
-
relative: relative,
|
|
239
|
-
dirname: dirname,
|
|
240
|
-
format: format,
|
|
241
|
-
basename: basename,
|
|
242
|
-
parse: parse
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
({
|
|
246
|
-
..._path
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
const RealDate = Date;
|
|
250
|
-
let now = null;
|
|
251
|
-
class MockDate extends RealDate {
|
|
252
|
-
constructor(y, m, d, h, M, s, ms) {
|
|
253
|
-
super();
|
|
254
|
-
let date;
|
|
255
|
-
switch (arguments.length) {
|
|
256
|
-
case 0:
|
|
257
|
-
if (now !== null)
|
|
258
|
-
date = new RealDate(now.valueOf());
|
|
259
|
-
else
|
|
260
|
-
date = new RealDate();
|
|
261
|
-
break;
|
|
262
|
-
case 1:
|
|
263
|
-
date = new RealDate(y);
|
|
264
|
-
break;
|
|
265
|
-
default:
|
|
266
|
-
d = typeof d === "undefined" ? 1 : d;
|
|
267
|
-
h = h || 0;
|
|
268
|
-
M = M || 0;
|
|
269
|
-
s = s || 0;
|
|
270
|
-
ms = ms || 0;
|
|
271
|
-
date = new RealDate(y, m, d, h, M, s, ms);
|
|
272
|
-
break;
|
|
273
|
-
}
|
|
274
|
-
return date;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
MockDate.UTC = RealDate.UTC;
|
|
278
|
-
MockDate.now = function() {
|
|
279
|
-
return new MockDate().valueOf();
|
|
280
|
-
};
|
|
281
|
-
MockDate.parse = function(dateString) {
|
|
282
|
-
return RealDate.parse(dateString);
|
|
283
|
-
};
|
|
284
|
-
MockDate.toString = function() {
|
|
285
|
-
return RealDate.toString();
|
|
286
|
-
};
|
|
287
|
-
function mockDate(date) {
|
|
288
|
-
const dateObj = new RealDate(date.valueOf());
|
|
289
|
-
if (isNaN(dateObj.getTime()))
|
|
290
|
-
throw new TypeError(`mockdate: The time set is an invalid date: ${date}`);
|
|
291
|
-
globalThis.Date = MockDate;
|
|
292
|
-
now = dateObj.valueOf();
|
|
293
|
-
}
|
|
294
|
-
function resetDate() {
|
|
295
|
-
globalThis.Date = RealDate;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
function isFinalObj(obj) {
|
|
299
|
-
return obj === Object.prototype || obj === Function.prototype || obj === RegExp.prototype;
|
|
300
|
-
}
|
|
301
|
-
function collectOwnProperties(obj, collector) {
|
|
302
|
-
const collect = typeof collector === "function" ? collector : (key) => collector.add(key);
|
|
303
|
-
Object.getOwnPropertyNames(obj).forEach(collect);
|
|
304
|
-
Object.getOwnPropertySymbols(obj).forEach(collect);
|
|
305
|
-
}
|
|
306
|
-
function getAllMockableProperties(obj) {
|
|
307
|
-
const allProps = /* @__PURE__ */ new Set();
|
|
308
|
-
let curr = obj;
|
|
309
|
-
do {
|
|
310
|
-
if (isFinalObj(curr))
|
|
311
|
-
break;
|
|
312
|
-
collectOwnProperties(curr, (key) => {
|
|
313
|
-
const descriptor = Object.getOwnPropertyDescriptor(curr, key);
|
|
314
|
-
if (descriptor)
|
|
315
|
-
allProps.add({ key, descriptor });
|
|
316
|
-
});
|
|
317
|
-
} while (curr = Object.getPrototypeOf(curr));
|
|
318
|
-
return Array.from(allProps);
|
|
319
|
-
}
|
|
320
|
-
function notNullish(v) {
|
|
321
|
-
return v != null;
|
|
322
|
-
}
|
|
323
|
-
function slash(str) {
|
|
324
|
-
return str.replace(/\\/g, "/");
|
|
325
|
-
}
|
|
326
|
-
function mergeSlashes(str) {
|
|
327
|
-
return str.replace(/\/\//g, "/");
|
|
328
|
-
}
|
|
329
|
-
const noop = () => {
|
|
330
|
-
};
|
|
331
|
-
function getType(value) {
|
|
332
|
-
return Object.prototype.toString.apply(value).slice(8, -1);
|
|
333
|
-
}
|
|
334
|
-
function getOwnProperties(obj) {
|
|
335
|
-
const ownProps = /* @__PURE__ */ new Set();
|
|
336
|
-
if (isFinalObj(obj))
|
|
337
|
-
return [];
|
|
338
|
-
collectOwnProperties(obj, ownProps);
|
|
339
|
-
return Array.from(ownProps);
|
|
340
|
-
}
|
|
341
|
-
function deepClone(val) {
|
|
342
|
-
const seen = /* @__PURE__ */ new WeakMap();
|
|
343
|
-
return clone(val, seen);
|
|
344
|
-
}
|
|
345
|
-
function clone(val, seen) {
|
|
346
|
-
let k, out;
|
|
347
|
-
if (seen.has(val))
|
|
348
|
-
return seen.get(val);
|
|
349
|
-
if (Array.isArray(val)) {
|
|
350
|
-
out = Array(k = val.length);
|
|
351
|
-
seen.set(val, out);
|
|
352
|
-
while (k--)
|
|
353
|
-
out[k] = clone(val[k], seen);
|
|
354
|
-
return out;
|
|
355
|
-
}
|
|
356
|
-
if (Object.prototype.toString.call(val) === "[object Object]") {
|
|
357
|
-
out = Object.create(Object.getPrototypeOf(val));
|
|
358
|
-
seen.set(val, out);
|
|
359
|
-
const props = getOwnProperties(val);
|
|
360
|
-
for (const k2 of props)
|
|
361
|
-
out[k2] = clone(val[k2], seen);
|
|
362
|
-
return out;
|
|
363
|
-
}
|
|
364
|
-
return val;
|
|
365
|
-
}
|
|
366
|
-
function toArray(array) {
|
|
367
|
-
if (array === null || array === void 0)
|
|
368
|
-
array = [];
|
|
369
|
-
if (Array.isArray(array))
|
|
370
|
-
return array;
|
|
371
|
-
return [array];
|
|
372
|
-
}
|
|
373
|
-
const toString = (v) => Object.prototype.toString.call(v);
|
|
374
|
-
const isPlainObject = (val) => toString(val) === "[object Object]" && (!val.constructor || val.constructor.name === "Object");
|
|
375
|
-
function isObject(item) {
|
|
376
|
-
return item != null && typeof item === "object" && !Array.isArray(item);
|
|
377
|
-
}
|
|
378
|
-
function deepMerge(target, ...sources) {
|
|
379
|
-
if (!sources.length)
|
|
380
|
-
return target;
|
|
381
|
-
const source = sources.shift();
|
|
382
|
-
if (source === void 0)
|
|
383
|
-
return target;
|
|
384
|
-
if (isMergableObject(target) && isMergableObject(source)) {
|
|
385
|
-
Object.keys(source).forEach((key) => {
|
|
386
|
-
if (isMergableObject(source[key])) {
|
|
387
|
-
if (!target[key])
|
|
388
|
-
target[key] = {};
|
|
389
|
-
deepMerge(target[key], source[key]);
|
|
390
|
-
} else {
|
|
391
|
-
target[key] = source[key];
|
|
392
|
-
}
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
return deepMerge(target, ...sources);
|
|
396
|
-
}
|
|
397
|
-
function isMergableObject(item) {
|
|
398
|
-
return isPlainObject(item) && !Array.isArray(item);
|
|
399
|
-
}
|
|
400
|
-
function assertTypes(value, name, types) {
|
|
401
|
-
const receivedType = typeof value;
|
|
402
|
-
const pass = types.includes(receivedType);
|
|
403
|
-
if (!pass)
|
|
404
|
-
throw new TypeError(`${name} value must be ${types.join(" or ")}, received "${receivedType}"`);
|
|
405
|
-
}
|
|
406
|
-
function stdout() {
|
|
407
|
-
return console._stdout || process.stdout;
|
|
408
|
-
}
|
|
409
|
-
function random(seed) {
|
|
410
|
-
const x = Math.sin(seed++) * 1e4;
|
|
411
|
-
return x - Math.floor(x);
|
|
412
|
-
}
|
|
413
|
-
function shuffle(array, seed = RealDate.now()) {
|
|
414
|
-
let length = array.length;
|
|
415
|
-
while (length) {
|
|
416
|
-
const index = Math.floor(random(seed) * length--);
|
|
417
|
-
const previous = array[length];
|
|
418
|
-
array[length] = array[index];
|
|
419
|
-
array[index] = previous;
|
|
420
|
-
++seed;
|
|
421
|
-
}
|
|
422
|
-
return array;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
function getTests(suite) {
|
|
426
|
-
return toArray(suite).flatMap((s) => s.type === "test" ? [s] : s.tasks.flatMap((c) => c.type === "test" ? [c] : getTests(c)));
|
|
427
|
-
}
|
|
428
|
-
function getSuites(suite) {
|
|
429
|
-
return toArray(suite).flatMap((s) => s.type === "suite" ? [s, ...getSuites(s.tasks)] : []);
|
|
430
|
-
}
|
|
431
|
-
function hasTests(suite) {
|
|
432
|
-
return toArray(suite).some((s) => s.tasks.some((c) => c.type === "test" || hasTests(c)));
|
|
433
|
-
}
|
|
434
|
-
function hasFailed(suite) {
|
|
435
|
-
return toArray(suite).some((s) => {
|
|
436
|
-
var _a;
|
|
437
|
-
return ((_a = s.result) == null ? void 0 : _a.state) === "fail" || s.type === "suite" && hasFailed(s.tasks);
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
function hasFailedSnapshot(suite) {
|
|
441
|
-
return getTests(suite).some((s) => {
|
|
442
|
-
var _a, _b;
|
|
443
|
-
const message = (_b = (_a = s.result) == null ? void 0 : _a.error) == null ? void 0 : _b.message;
|
|
444
|
-
return message == null ? void 0 : message.match(/Snapshot .* mismatched/);
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
function getNames(task) {
|
|
448
|
-
const names = [task.name];
|
|
449
|
-
let current = task;
|
|
450
|
-
while ((current == null ? void 0 : current.suite) || (current == null ? void 0 : current.file)) {
|
|
451
|
-
current = current.suite || current.file;
|
|
452
|
-
if (current == null ? void 0 : current.name)
|
|
453
|
-
names.unshift(current.name);
|
|
454
|
-
}
|
|
455
|
-
return names;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
var _a;
|
|
459
|
-
const isNode = typeof process < "u" && typeof process.stdout < "u" && !((_a = process.versions) == null ? void 0 : _a.deno) && !globalThis.window;
|
|
460
|
-
const isBrowser = typeof window !== "undefined";
|
|
461
|
-
const isWindows = isNode && process.platform === "win32";
|
|
462
|
-
const relativePath = isBrowser ? relative$1 : relative;
|
|
463
|
-
function partitionSuiteChildren(suite) {
|
|
464
|
-
let tasksGroup = [];
|
|
465
|
-
const tasksGroups = [];
|
|
466
|
-
for (const c2 of suite.tasks) {
|
|
467
|
-
if (tasksGroup.length === 0 || c2.concurrent === tasksGroup[0].concurrent) {
|
|
468
|
-
tasksGroup.push(c2);
|
|
469
|
-
} else {
|
|
470
|
-
tasksGroups.push(tasksGroup);
|
|
471
|
-
tasksGroup = [c2];
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
if (tasksGroup.length > 0)
|
|
475
|
-
tasksGroups.push(tasksGroup);
|
|
476
|
-
return tasksGroups;
|
|
477
|
-
}
|
|
478
|
-
function resetModules(modules, resetMocks = false) {
|
|
479
|
-
const skipPaths = [
|
|
480
|
-
/\/vitest\/dist\//,
|
|
481
|
-
/vitest-virtual-\w+\/dist/,
|
|
482
|
-
/@vitest\/dist/,
|
|
483
|
-
...!resetMocks ? [/^mock:/] : []
|
|
484
|
-
];
|
|
485
|
-
modules.forEach((_, path) => {
|
|
486
|
-
if (skipPaths.some((re) => re.test(path)))
|
|
487
|
-
return;
|
|
488
|
-
modules.delete(path);
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
function getFullName(task) {
|
|
492
|
-
return getNames(task).join(picocolors.exports.dim(" > "));
|
|
493
|
-
}
|
|
494
|
-
async function ensurePackageInstalled(dependency, root) {
|
|
495
|
-
if (isPackageExists(dependency, { paths: [root] }))
|
|
496
|
-
return true;
|
|
497
|
-
const promptInstall = !process.env.CI && process.stdout.isTTY;
|
|
498
|
-
process.stderr.write(picocolors.exports.red(`${picocolors.exports.inverse(picocolors.exports.red(" MISSING DEP "))} Can not find dependency '${dependency}'
|
|
499
|
-
|
|
500
|
-
`));
|
|
501
|
-
if (!promptInstall)
|
|
502
|
-
return false;
|
|
503
|
-
const prompts = await import('./vendor-index.ae96af6e.mjs').then(function (n) { return n.i; });
|
|
504
|
-
const { install } = await prompts.prompt({
|
|
505
|
-
type: "confirm",
|
|
506
|
-
name: "install",
|
|
507
|
-
message: picocolors.exports.reset(`Do you want to install ${picocolors.exports.green(dependency)}?`)
|
|
508
|
-
});
|
|
509
|
-
if (install) {
|
|
510
|
-
await (await import('./chunk-install-pkg.6c6dc0c2.mjs')).installPackage(dependency, { dev: true });
|
|
511
|
-
process.stderr.write(picocolors.exports.yellow(`
|
|
512
|
-
Package ${dependency} installed, re-run the command to start.
|
|
513
|
-
`));
|
|
514
|
-
process.exit(1);
|
|
515
|
-
return true;
|
|
516
|
-
}
|
|
517
|
-
return false;
|
|
518
|
-
}
|
|
519
|
-
function getCallLastIndex(code) {
|
|
520
|
-
let charIndex = -1;
|
|
521
|
-
let inString = null;
|
|
522
|
-
let startedBracers = 0;
|
|
523
|
-
let endedBracers = 0;
|
|
524
|
-
let beforeChar = null;
|
|
525
|
-
while (charIndex <= code.length) {
|
|
526
|
-
beforeChar = code[charIndex];
|
|
527
|
-
charIndex++;
|
|
528
|
-
const char = code[charIndex];
|
|
529
|
-
const isCharString = char === '"' || char === "'" || char === "`";
|
|
530
|
-
if (isCharString && beforeChar !== "\\") {
|
|
531
|
-
if (inString === char)
|
|
532
|
-
inString = null;
|
|
533
|
-
else if (!inString)
|
|
534
|
-
inString = char;
|
|
535
|
-
}
|
|
536
|
-
if (!inString) {
|
|
537
|
-
if (char === "(")
|
|
538
|
-
startedBracers++;
|
|
539
|
-
if (char === ")")
|
|
540
|
-
endedBracers++;
|
|
541
|
-
}
|
|
542
|
-
if (startedBracers && endedBracers && startedBracers === endedBracers)
|
|
543
|
-
return charIndex;
|
|
544
|
-
}
|
|
545
|
-
return null;
|
|
546
|
-
}
|
|
547
|
-
isNode ? relative : relative$1;
|
|
548
|
-
class AggregateErrorPonyfill extends Error {
|
|
549
|
-
constructor(errors, message = "") {
|
|
550
|
-
super(message);
|
|
551
|
-
this.errors = [...errors];
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
export { AggregateErrorPonyfill as A, isAbsolute as B, relative as C, getTests as D, hasFailedSnapshot as E, getSuites as F, normalize as G, deepMerge as H, toNamespacedPath as I, ensurePackageInstalled as J, stdout as K, extname as L, isWindows as M, mergeSlashes as N, getAllMockableProperties as O, RealDate as R, resetModules as a, getNames as b, assertTypes as c, dirname as d, getFullName as e, notNullish as f, getCallLastIndex as g, deepClone as h, isObject as i, join as j, getType as k, isNode as l, mockDate as m, noop as n, relativePath as o, picocolors as p, isBrowser as q, resetDate as r, slash as s, toArray as t, partitionSuiteChildren as u, shuffle as v, hasTests as w, hasFailed as x, resolve as y, basename as z };
|