vitest 1.4.0 → 1.5.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/dist/browser.d.ts +5 -1
- package/dist/browser.js +1 -1
- package/dist/chunks/{integrations-globals.trMeEBob.js → integrations-globals.k0N5-dd1.js} +3 -3
- package/dist/chunks/{runtime-console.tUKE_2UJ.js → runtime-console.kbFEN7E-.js} +14 -6
- package/dist/chunks/{runtime-runBaseTests.SKlFOhuq.js → runtime-runBaseTests.-x-nNuJ_.js} +11 -9
- package/dist/cli-wrapper.js +1 -1
- package/dist/cli.js +3 -61
- package/dist/config.cjs +1 -0
- package/dist/config.d.ts +2 -1
- package/dist/config.js +1 -0
- package/dist/coverage.d.ts +4 -2
- package/dist/coverage.js +2 -2
- package/dist/environments.d.ts +2 -1
- package/dist/execute.d.ts +2 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +3 -3
- package/dist/node.d.ts +26 -4
- package/dist/node.js +15 -13
- package/dist/{reporters-P7C2ytIv.d.ts → reporters-xEmem8D4.d.ts} +124 -49
- package/dist/reporters.d.ts +2 -1
- package/dist/reporters.js +5 -4
- package/dist/runners.d.ts +2 -1
- package/dist/runners.js +3 -3
- package/dist/{suite-a18diDsI.d.ts → suite-HPAKvIxA.d.ts} +1 -1
- package/dist/suite.d.ts +3 -2
- package/dist/vendor/{base.nhvUBzQY.js → base.gAwDs8Jc.js} +1 -1
- package/dist/vendor/cac.4YOY8W-L.js +1406 -0
- package/dist/vendor/{cac.RvTIWZBK.js → cli-api.5cFYj0Lq.js} +178 -1499
- package/dist/vendor/{constants.K-Wf1PUy.js → constants.5J7I254_.js} +2 -1
- package/dist/vendor/{index.BeX1oZht.js → index.0RrMQKD8.js} +1 -1
- package/dist/vendor/{index.LNWuEnUT.js → index.gHZzsRJQ.js} +1 -1
- package/dist/vendor/{index.e9RDLAeW.js → index.waF5pgqJ.js} +52 -214
- package/dist/vendor/inspector.IgLX3ur5.js +54 -0
- package/dist/vendor/{setup-common.vyF1kALR.js → setup-common.7SXMSI--.js} +11 -1
- package/dist/vendor/{utils.w0xgzP1h.js → utils.0uYuCbzo.js} +5 -2
- package/dist/vendor/utils.VYmeMh-u.js +217 -0
- package/dist/vendor/{vi.JYQecGiw.js → vi.Y_w82WR8.js} +26 -21
- package/dist/vendor/{vm.cAHVDF92.js → vm.I_IsyNig.js} +2 -2
- package/dist/worker.js +2 -39
- package/dist/workers/forks.js +2 -2
- package/dist/workers/runVmTests.js +10 -4
- package/dist/workers/threads.js +2 -2
- package/dist/workers/vmForks.js +7 -7
- package/dist/workers/vmThreads.js +7 -7
- package/dist/workers.d.ts +2 -1
- package/dist/workers.js +8 -7
- package/package.json +11 -11
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { dirname, resolve, relative, normalize, join, basename, toNamespacedPath } from 'pathe';
|
|
2
|
-
import
|
|
3
|
-
import c from 'picocolors';
|
|
4
|
-
import { b as removeUndefinedValues, c as isWindows } from './index.ir9i0ywP.js';
|
|
5
|
-
import { w as wrapSerializableConfig, f as Typechecker, R as ReportersMap, e as BenchmarkReportsMap, g as RandomSequencer, B as BaseSequencer, h as generateCodeFrame, i as highlightCode, j as divider, L as Logger, s as stripAnsi } from './index.e9RDLAeW.js';
|
|
6
|
-
import { A as API_PATH, c as configFiles, d as defaultPort, e as extraInlineDeps, a as defaultBrowserPort, E as EXIT_CODE_RESTART, w as workspacesFiles, C as CONFIG_NAMES } from './constants.K-Wf1PUy.js';
|
|
1
|
+
import { dirname, resolve, relative, normalize, join, basename, toNamespacedPath, isAbsolute } from 'pathe';
|
|
2
|
+
import { A as API_PATH, d as defaultPort, e as extraInlineDeps, a as defaultBrowserPort, b as defaultInspectPort, E as EXIT_CODE_RESTART, w as workspacesFiles, C as CONFIG_NAMES, c as configFiles } from './constants.5J7I254_.js';
|
|
7
3
|
import { g as getCoverageProvider, C as CoverageProviderMap } from './coverage.E7sG1b3r.js';
|
|
8
4
|
import { g as getEnvPackageName } from './index.GVFv9dZ0.js';
|
|
9
|
-
import { isFileServingAllowed,
|
|
5
|
+
import { isFileServingAllowed, searchForWorkspaceRoot, version as version$1, createServer, mergeConfig } from 'vite';
|
|
10
6
|
import path$8 from 'node:path';
|
|
11
7
|
import url, { fileURLToPath } from 'node:url';
|
|
12
8
|
import process$1 from 'node:process';
|
|
13
9
|
import fs$8, { promises, existsSync } from 'node:fs';
|
|
10
|
+
import { MessageChannel, isMainThread } from 'node:worker_threads';
|
|
14
11
|
import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers.jjO7Zipk.js';
|
|
15
12
|
import require$$0 from 'os';
|
|
16
13
|
import p from 'path';
|
|
17
14
|
import { a as micromatch_1, m as mm } from './index.xL8XjTLv.js';
|
|
18
15
|
import require$$0$1 from 'stream';
|
|
16
|
+
import require$$0$3 from 'events';
|
|
19
17
|
import require$$0$2 from 'fs';
|
|
18
|
+
import c from 'picocolors';
|
|
20
19
|
import { ViteNodeRunner } from 'vite-node/client';
|
|
21
20
|
import { SnapshotManager } from '@vitest/snapshot/manager';
|
|
22
21
|
import { ViteNodeServer } from 'vite-node/server';
|
|
22
|
+
import { b as removeUndefinedValues, c as isWindows } from './index.ir9i0ywP.js';
|
|
23
23
|
import { rootDir } from '../path.js';
|
|
24
24
|
import { c as createBirpc } from './index.8bPxjt7g.js';
|
|
25
25
|
import require$$0$4 from 'zlib';
|
|
@@ -36,18 +36,20 @@ import { n as noop$2, b as isPrimitive, c as groupBy, A as AggregateErrorPonyfil
|
|
|
36
36
|
import v8 from 'node:v8';
|
|
37
37
|
import * as nodeos from 'node:os';
|
|
38
38
|
import nodeos__default from 'node:os';
|
|
39
|
-
import EventEmitter$
|
|
39
|
+
import EventEmitter$2 from 'node:events';
|
|
40
40
|
import Tinypool$1, { Tinypool } from 'tinypool';
|
|
41
|
-
import {
|
|
41
|
+
import { w as wrapSerializableConfig, f as Typechecker, R as ReportersMap, e as BenchmarkReportsMap, g as RandomSequencer, B as BaseSequencer, h as generateCodeFrame, i as highlightCode, L as Logger } from './index.waF5pgqJ.js';
|
|
42
42
|
import { hasFailed, getTests } from '@vitest/runner/utils';
|
|
43
43
|
import { resolveModule, isPackageExists } from 'local-pkg';
|
|
44
44
|
import { isCI, provider as provider$1 } from 'std-env';
|
|
45
45
|
import crypto, { createHash as createHash$2 } from 'node:crypto';
|
|
46
|
+
import { v as version } from './cac.4YOY8W-L.js';
|
|
46
47
|
import { normalizeRequestId, cleanUrl } from 'vite-node/utils';
|
|
47
48
|
import MagicString from 'magic-string';
|
|
48
49
|
import { findNodeAround } from 'acorn-walk';
|
|
49
50
|
import { esmWalker } from '@vitest/utils/ast';
|
|
50
51
|
import { stripLiteral } from 'strip-literal';
|
|
52
|
+
import { d as divider, s as stripAnsi } from './utils.VYmeMh-u.js';
|
|
51
53
|
import { createRequire } from 'node:module';
|
|
52
54
|
import readline from 'node:readline';
|
|
53
55
|
import require$$0$6 from 'readline';
|
|
@@ -114,622 +116,6 @@ function stringifyReplace(key, value) {
|
|
|
114
116
|
return value;
|
|
115
117
|
}
|
|
116
118
|
|
|
117
|
-
function toArr(any) {
|
|
118
|
-
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function toVal(out, key, val, opts) {
|
|
122
|
-
var x, old=out[key], nxt=(
|
|
123
|
-
!!~opts.string.indexOf(key) ? (val == null || val === true ? '' : String(val))
|
|
124
|
-
: typeof val === 'boolean' ? val
|
|
125
|
-
: !!~opts.boolean.indexOf(key) ? (val === 'false' ? false : val === 'true' || (out._.push((x = +val,x * 0 === 0) ? x : val),!!val))
|
|
126
|
-
: (x = +val,x * 0 === 0) ? x : val
|
|
127
|
-
);
|
|
128
|
-
out[key] = old == null ? nxt : (Array.isArray(old) ? old.concat(nxt) : [old, nxt]);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function mri2 (args, opts) {
|
|
132
|
-
args = args || [];
|
|
133
|
-
opts = opts || {};
|
|
134
|
-
|
|
135
|
-
var k, arr, arg, name, val, out={ _:[] };
|
|
136
|
-
var i=0, j=0, idx=0, len=args.length;
|
|
137
|
-
|
|
138
|
-
const alibi = opts.alias !== void 0;
|
|
139
|
-
const strict = opts.unknown !== void 0;
|
|
140
|
-
const defaults = opts.default !== void 0;
|
|
141
|
-
|
|
142
|
-
opts.alias = opts.alias || {};
|
|
143
|
-
opts.string = toArr(opts.string);
|
|
144
|
-
opts.boolean = toArr(opts.boolean);
|
|
145
|
-
|
|
146
|
-
if (alibi) {
|
|
147
|
-
for (k in opts.alias) {
|
|
148
|
-
arr = opts.alias[k] = toArr(opts.alias[k]);
|
|
149
|
-
for (i=0; i < arr.length; i++) {
|
|
150
|
-
(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
for (i=opts.boolean.length; i-- > 0;) {
|
|
156
|
-
arr = opts.alias[opts.boolean[i]] || [];
|
|
157
|
-
for (j=arr.length; j-- > 0;) opts.boolean.push(arr[j]);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
for (i=opts.string.length; i-- > 0;) {
|
|
161
|
-
arr = opts.alias[opts.string[i]] || [];
|
|
162
|
-
for (j=arr.length; j-- > 0;) opts.string.push(arr[j]);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (defaults) {
|
|
166
|
-
for (k in opts.default) {
|
|
167
|
-
name = typeof opts.default[k];
|
|
168
|
-
arr = opts.alias[k] = opts.alias[k] || [];
|
|
169
|
-
if (opts[name] !== void 0) {
|
|
170
|
-
opts[name].push(k);
|
|
171
|
-
for (i=0; i < arr.length; i++) {
|
|
172
|
-
opts[name].push(arr[i]);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const keys = strict ? Object.keys(opts.alias) : [];
|
|
179
|
-
|
|
180
|
-
for (i=0; i < len; i++) {
|
|
181
|
-
arg = args[i];
|
|
182
|
-
|
|
183
|
-
if (arg === '--') {
|
|
184
|
-
out._ = out._.concat(args.slice(++i));
|
|
185
|
-
break;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
for (j=0; j < arg.length; j++) {
|
|
189
|
-
if (arg.charCodeAt(j) !== 45) break; // "-"
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (j === 0) {
|
|
193
|
-
out._.push(arg);
|
|
194
|
-
} else if (arg.substring(j, j + 3) === 'no-') {
|
|
195
|
-
name = arg.substring(j + 3);
|
|
196
|
-
if (strict && !~keys.indexOf(name)) {
|
|
197
|
-
return opts.unknown(arg);
|
|
198
|
-
}
|
|
199
|
-
out[name] = false;
|
|
200
|
-
} else {
|
|
201
|
-
for (idx=j+1; idx < arg.length; idx++) {
|
|
202
|
-
if (arg.charCodeAt(idx) === 61) break; // "="
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
name = arg.substring(j, idx);
|
|
206
|
-
val = arg.substring(++idx) || (i+1 === len || (''+args[i+1]).charCodeAt(0) === 45 || args[++i]);
|
|
207
|
-
arr = (j === 2 ? [name] : name);
|
|
208
|
-
|
|
209
|
-
for (idx=0; idx < arr.length; idx++) {
|
|
210
|
-
name = arr[idx];
|
|
211
|
-
if (strict && !~keys.indexOf(name)) return opts.unknown('-'.repeat(j) + name);
|
|
212
|
-
toVal(out, name, (idx + 1 < arr.length) || val, opts);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
if (defaults) {
|
|
218
|
-
for (k in opts.default) {
|
|
219
|
-
if (out[k] === void 0) {
|
|
220
|
-
out[k] = opts.default[k];
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if (alibi) {
|
|
226
|
-
for (k in out) {
|
|
227
|
-
arr = opts.alias[k] || [];
|
|
228
|
-
while (arr.length > 0) {
|
|
229
|
-
out[arr.shift()] = out[k];
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
return out;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
const removeBrackets = (v) => v.replace(/[<[].+/, "").trim();
|
|
238
|
-
const findAllBrackets = (v) => {
|
|
239
|
-
const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
|
|
240
|
-
const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
|
|
241
|
-
const res = [];
|
|
242
|
-
const parse = (match) => {
|
|
243
|
-
let variadic = false;
|
|
244
|
-
let value = match[1];
|
|
245
|
-
if (value.startsWith("...")) {
|
|
246
|
-
value = value.slice(3);
|
|
247
|
-
variadic = true;
|
|
248
|
-
}
|
|
249
|
-
return {
|
|
250
|
-
required: match[0].startsWith("<"),
|
|
251
|
-
value,
|
|
252
|
-
variadic
|
|
253
|
-
};
|
|
254
|
-
};
|
|
255
|
-
let angledMatch;
|
|
256
|
-
while (angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v)) {
|
|
257
|
-
res.push(parse(angledMatch));
|
|
258
|
-
}
|
|
259
|
-
let squareMatch;
|
|
260
|
-
while (squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v)) {
|
|
261
|
-
res.push(parse(squareMatch));
|
|
262
|
-
}
|
|
263
|
-
return res;
|
|
264
|
-
};
|
|
265
|
-
const getMriOptions = (options) => {
|
|
266
|
-
const result = {alias: {}, boolean: []};
|
|
267
|
-
for (const [index, option] of options.entries()) {
|
|
268
|
-
if (option.names.length > 1) {
|
|
269
|
-
result.alias[option.names[0]] = option.names.slice(1);
|
|
270
|
-
}
|
|
271
|
-
if (option.isBoolean) {
|
|
272
|
-
if (option.negated) {
|
|
273
|
-
const hasStringTypeOption = options.some((o, i) => {
|
|
274
|
-
return i !== index && o.names.some((name) => option.names.includes(name)) && typeof o.required === "boolean";
|
|
275
|
-
});
|
|
276
|
-
if (!hasStringTypeOption) {
|
|
277
|
-
result.boolean.push(option.names[0]);
|
|
278
|
-
}
|
|
279
|
-
} else {
|
|
280
|
-
result.boolean.push(option.names[0]);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
return result;
|
|
285
|
-
};
|
|
286
|
-
const findLongest = (arr) => {
|
|
287
|
-
return arr.sort((a, b) => {
|
|
288
|
-
return a.length > b.length ? -1 : 1;
|
|
289
|
-
})[0];
|
|
290
|
-
};
|
|
291
|
-
const padRight = (str, length) => {
|
|
292
|
-
return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
|
|
293
|
-
};
|
|
294
|
-
const camelcase = (input) => {
|
|
295
|
-
return input.replace(/([a-z])-([a-z])/g, (_, p1, p2) => {
|
|
296
|
-
return p1 + p2.toUpperCase();
|
|
297
|
-
});
|
|
298
|
-
};
|
|
299
|
-
const setDotProp = (obj, keys, val, transforms) => {
|
|
300
|
-
let i = 0;
|
|
301
|
-
let length = keys.length;
|
|
302
|
-
let t = obj;
|
|
303
|
-
let x;
|
|
304
|
-
let convertKey = (i) => {
|
|
305
|
-
let key = keys[i];
|
|
306
|
-
i--;
|
|
307
|
-
while(i >= 0) {
|
|
308
|
-
key = keys[i] + '.' + key;
|
|
309
|
-
i--;
|
|
310
|
-
}
|
|
311
|
-
return key
|
|
312
|
-
};
|
|
313
|
-
for (; i < length; ++i) {
|
|
314
|
-
x = t[keys[i]];
|
|
315
|
-
const transform = transforms[convertKey(i)] || ((v) => v);
|
|
316
|
-
t = t[keys[i]] = transform(i === length - 1 ? val : x != null ? x : !!~keys[i + 1].indexOf(".") || !(+keys[i + 1] > -1) ? {} : []);
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
const getFileName = (input) => {
|
|
320
|
-
const m = /([^\\\/]+)$/.exec(input);
|
|
321
|
-
return m ? m[1] : "";
|
|
322
|
-
};
|
|
323
|
-
const camelcaseOptionName = (name) => {
|
|
324
|
-
return name.split(".").map((v, i) => {
|
|
325
|
-
return i === 0 ? camelcase(v) : v;
|
|
326
|
-
}).join(".");
|
|
327
|
-
};
|
|
328
|
-
class CACError extends Error {
|
|
329
|
-
constructor(message) {
|
|
330
|
-
super(message);
|
|
331
|
-
this.name = this.constructor.name;
|
|
332
|
-
if (typeof Error.captureStackTrace === "function") {
|
|
333
|
-
Error.captureStackTrace(this, this.constructor);
|
|
334
|
-
} else {
|
|
335
|
-
this.stack = new Error(message).stack;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
class Option {
|
|
341
|
-
constructor(rawName, description, config) {
|
|
342
|
-
this.rawName = rawName;
|
|
343
|
-
this.description = description;
|
|
344
|
-
this.config = Object.assign({}, config);
|
|
345
|
-
rawName = rawName.replace(/\.\*/g, "");
|
|
346
|
-
this.negated = false;
|
|
347
|
-
this.names = removeBrackets(rawName).split(",").map((v) => {
|
|
348
|
-
let name = v.trim().replace(/^-{1,2}/, "");
|
|
349
|
-
if (name.startsWith("no-")) {
|
|
350
|
-
this.negated = true;
|
|
351
|
-
name = name.replace(/^no-/, "");
|
|
352
|
-
}
|
|
353
|
-
return camelcaseOptionName(name);
|
|
354
|
-
}).sort((a, b) => a.length > b.length ? 1 : -1);
|
|
355
|
-
this.name = this.names[this.names.length - 1];
|
|
356
|
-
if (this.negated && this.config.default == null) {
|
|
357
|
-
this.config.default = true;
|
|
358
|
-
}
|
|
359
|
-
if (rawName.includes("<")) {
|
|
360
|
-
this.required = true;
|
|
361
|
-
} else if (rawName.includes("[")) {
|
|
362
|
-
this.required = false;
|
|
363
|
-
} else {
|
|
364
|
-
this.isBoolean = true;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
const processArgs = process.argv;
|
|
370
|
-
const platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
|
|
371
|
-
|
|
372
|
-
class Command {
|
|
373
|
-
constructor(rawName, description, config = {}, cli) {
|
|
374
|
-
this.rawName = rawName;
|
|
375
|
-
this.description = description;
|
|
376
|
-
this.config = config;
|
|
377
|
-
this.cli = cli;
|
|
378
|
-
this.options = [];
|
|
379
|
-
this.aliasNames = [];
|
|
380
|
-
this.name = removeBrackets(rawName);
|
|
381
|
-
this.args = findAllBrackets(rawName);
|
|
382
|
-
this.examples = [];
|
|
383
|
-
}
|
|
384
|
-
usage(text) {
|
|
385
|
-
this.usageText = text;
|
|
386
|
-
return this;
|
|
387
|
-
}
|
|
388
|
-
allowUnknownOptions() {
|
|
389
|
-
this.config.allowUnknownOptions = true;
|
|
390
|
-
return this;
|
|
391
|
-
}
|
|
392
|
-
ignoreOptionDefaultValue() {
|
|
393
|
-
this.config.ignoreOptionDefaultValue = true;
|
|
394
|
-
return this;
|
|
395
|
-
}
|
|
396
|
-
version(version, customFlags = "-v, --version") {
|
|
397
|
-
this.versionNumber = version;
|
|
398
|
-
this.option(customFlags, "Display version number");
|
|
399
|
-
return this;
|
|
400
|
-
}
|
|
401
|
-
example(example) {
|
|
402
|
-
this.examples.push(example);
|
|
403
|
-
return this;
|
|
404
|
-
}
|
|
405
|
-
option(rawName, description, config) {
|
|
406
|
-
const option = new Option(rawName, description, config);
|
|
407
|
-
this.options.push(option);
|
|
408
|
-
return this;
|
|
409
|
-
}
|
|
410
|
-
alias(name) {
|
|
411
|
-
this.aliasNames.push(name);
|
|
412
|
-
return this;
|
|
413
|
-
}
|
|
414
|
-
action(callback) {
|
|
415
|
-
this.commandAction = callback;
|
|
416
|
-
return this;
|
|
417
|
-
}
|
|
418
|
-
isMatched(name) {
|
|
419
|
-
return this.name === name || this.aliasNames.includes(name);
|
|
420
|
-
}
|
|
421
|
-
get isDefaultCommand() {
|
|
422
|
-
return this.name === "" || this.aliasNames.includes("!");
|
|
423
|
-
}
|
|
424
|
-
get isGlobalCommand() {
|
|
425
|
-
return this instanceof GlobalCommand;
|
|
426
|
-
}
|
|
427
|
-
hasOption(name) {
|
|
428
|
-
name = name.split(".")[0];
|
|
429
|
-
return this.options.find((option) => {
|
|
430
|
-
return option.names.includes(name);
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
outputHelp() {
|
|
434
|
-
const {name, commands} = this.cli;
|
|
435
|
-
const {
|
|
436
|
-
versionNumber,
|
|
437
|
-
options: globalOptions,
|
|
438
|
-
helpCallback
|
|
439
|
-
} = this.cli.globalCommand;
|
|
440
|
-
let sections = [
|
|
441
|
-
{
|
|
442
|
-
body: `${name}${versionNumber ? `/${versionNumber}` : ""}`
|
|
443
|
-
}
|
|
444
|
-
];
|
|
445
|
-
sections.push({
|
|
446
|
-
title: "Usage",
|
|
447
|
-
body: ` $ ${name} ${this.usageText || this.rawName}`
|
|
448
|
-
});
|
|
449
|
-
const showCommands = (this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0;
|
|
450
|
-
if (showCommands) {
|
|
451
|
-
const longestCommandName = findLongest(commands.map((command) => command.rawName));
|
|
452
|
-
sections.push({
|
|
453
|
-
title: "Commands",
|
|
454
|
-
body: commands.map((command) => {
|
|
455
|
-
return ` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`;
|
|
456
|
-
}).join("\n")
|
|
457
|
-
});
|
|
458
|
-
sections.push({
|
|
459
|
-
title: `For more info, run any command with the \`--help\` flag`,
|
|
460
|
-
body: commands.map((command) => ` $ ${name}${command.name === "" ? "" : ` ${command.name}`} --help`).join("\n")
|
|
461
|
-
});
|
|
462
|
-
}
|
|
463
|
-
let options = this.isGlobalCommand ? globalOptions : [...this.options, ...globalOptions || []];
|
|
464
|
-
if (!this.isGlobalCommand && !this.isDefaultCommand) {
|
|
465
|
-
options = options.filter((option) => option.name !== "version");
|
|
466
|
-
}
|
|
467
|
-
if (options.length > 0) {
|
|
468
|
-
const longestOptionName = findLongest(options.map((option) => option.rawName));
|
|
469
|
-
sections.push({
|
|
470
|
-
title: "Options",
|
|
471
|
-
body: options.map((option) => {
|
|
472
|
-
return ` ${padRight(option.rawName, longestOptionName.length)} ${option.description} ${option.config.default === void 0 ? "" : `(default: ${option.config.default})`}`;
|
|
473
|
-
}).join("\n")
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
if (this.examples.length > 0) {
|
|
477
|
-
sections.push({
|
|
478
|
-
title: "Examples",
|
|
479
|
-
body: this.examples.map((example) => {
|
|
480
|
-
if (typeof example === "function") {
|
|
481
|
-
return example(name);
|
|
482
|
-
}
|
|
483
|
-
return example;
|
|
484
|
-
}).join("\n")
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
if (helpCallback) {
|
|
488
|
-
sections = helpCallback(sections) || sections;
|
|
489
|
-
}
|
|
490
|
-
console.log(sections.map((section) => {
|
|
491
|
-
return section.title ? `${section.title}:
|
|
492
|
-
${section.body}` : section.body;
|
|
493
|
-
}).join("\n\n"));
|
|
494
|
-
}
|
|
495
|
-
outputVersion() {
|
|
496
|
-
const {name} = this.cli;
|
|
497
|
-
const {versionNumber} = this.cli.globalCommand;
|
|
498
|
-
if (versionNumber) {
|
|
499
|
-
console.log(`${name}/${versionNumber} ${platformInfo}`);
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
checkRequiredArgs() {
|
|
503
|
-
const minimalArgsCount = this.args.filter((arg) => arg.required).length;
|
|
504
|
-
if (this.cli.args.length < minimalArgsCount) {
|
|
505
|
-
throw new CACError(`missing required args for command \`${this.rawName}\``);
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
checkUnknownOptions() {
|
|
509
|
-
const {options, globalCommand} = this.cli;
|
|
510
|
-
if (!this.config.allowUnknownOptions) {
|
|
511
|
-
for (const name of Object.keys(options)) {
|
|
512
|
-
if (name !== "--" && !this.hasOption(name) && !globalCommand.hasOption(name)) {
|
|
513
|
-
throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
checkOptionValue() {
|
|
519
|
-
const {options: parsedOptions, globalCommand} = this.cli;
|
|
520
|
-
const options = [...globalCommand.options, ...this.options];
|
|
521
|
-
for (const option of options) {
|
|
522
|
-
// skip dot names because only top level options are required
|
|
523
|
-
if (option.name.includes('.')) {
|
|
524
|
-
continue;
|
|
525
|
-
}
|
|
526
|
-
const value = parsedOptions[option.name];
|
|
527
|
-
if (option.required) {
|
|
528
|
-
const hasNegated = options.some((o) => o.negated && o.names.includes(option.name));
|
|
529
|
-
if (value === true || value === false && !hasNegated) {
|
|
530
|
-
throw new CACError(`option \`${option.rawName}\` value is missing`);
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
class GlobalCommand extends Command {
|
|
537
|
-
constructor(cli) {
|
|
538
|
-
super("@@global@@", "", {}, cli);
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
var __assign = Object.assign;
|
|
543
|
-
class CAC extends EventEmitter$2 {
|
|
544
|
-
constructor(name = "") {
|
|
545
|
-
super();
|
|
546
|
-
this.name = name;
|
|
547
|
-
this.commands = [];
|
|
548
|
-
this.rawArgs = [];
|
|
549
|
-
this.args = [];
|
|
550
|
-
this.options = {};
|
|
551
|
-
this.globalCommand = new GlobalCommand(this);
|
|
552
|
-
this.globalCommand.usage("<command> [options]");
|
|
553
|
-
}
|
|
554
|
-
usage(text) {
|
|
555
|
-
this.globalCommand.usage(text);
|
|
556
|
-
return this;
|
|
557
|
-
}
|
|
558
|
-
command(rawName, description, config) {
|
|
559
|
-
const command = new Command(rawName, description || "", config, this);
|
|
560
|
-
command.globalCommand = this.globalCommand;
|
|
561
|
-
this.commands.push(command);
|
|
562
|
-
return command;
|
|
563
|
-
}
|
|
564
|
-
option(rawName, description, config) {
|
|
565
|
-
this.globalCommand.option(rawName, description, config);
|
|
566
|
-
return this;
|
|
567
|
-
}
|
|
568
|
-
help(callback) {
|
|
569
|
-
this.globalCommand.option("-h, --help", "Display this message");
|
|
570
|
-
this.globalCommand.helpCallback = callback;
|
|
571
|
-
this.showHelpOnExit = true;
|
|
572
|
-
return this;
|
|
573
|
-
}
|
|
574
|
-
version(version, customFlags = "-v, --version") {
|
|
575
|
-
this.globalCommand.version(version, customFlags);
|
|
576
|
-
this.showVersionOnExit = true;
|
|
577
|
-
return this;
|
|
578
|
-
}
|
|
579
|
-
example(example) {
|
|
580
|
-
this.globalCommand.example(example);
|
|
581
|
-
return this;
|
|
582
|
-
}
|
|
583
|
-
outputHelp() {
|
|
584
|
-
if (this.matchedCommand) {
|
|
585
|
-
this.matchedCommand.outputHelp();
|
|
586
|
-
} else {
|
|
587
|
-
this.globalCommand.outputHelp();
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
outputVersion() {
|
|
591
|
-
this.globalCommand.outputVersion();
|
|
592
|
-
}
|
|
593
|
-
setParsedInfo({args, options}, matchedCommand, matchedCommandName) {
|
|
594
|
-
this.args = args;
|
|
595
|
-
this.options = options;
|
|
596
|
-
if (matchedCommand) {
|
|
597
|
-
this.matchedCommand = matchedCommand;
|
|
598
|
-
}
|
|
599
|
-
if (matchedCommandName) {
|
|
600
|
-
this.matchedCommandName = matchedCommandName;
|
|
601
|
-
}
|
|
602
|
-
return this;
|
|
603
|
-
}
|
|
604
|
-
unsetMatchedCommand() {
|
|
605
|
-
this.matchedCommand = void 0;
|
|
606
|
-
this.matchedCommandName = void 0;
|
|
607
|
-
}
|
|
608
|
-
parse(argv = processArgs, {
|
|
609
|
-
run = true
|
|
610
|
-
} = {}) {
|
|
611
|
-
this.rawArgs = argv;
|
|
612
|
-
if (!this.name) {
|
|
613
|
-
this.name = argv[1] ? getFileName(argv[1]) : "cli";
|
|
614
|
-
}
|
|
615
|
-
let shouldParse = true;
|
|
616
|
-
for (const command of this.commands) {
|
|
617
|
-
const parsed = this.mri(argv.slice(2), command);
|
|
618
|
-
const commandName = parsed.args[0];
|
|
619
|
-
if (command.isMatched(commandName)) {
|
|
620
|
-
shouldParse = false;
|
|
621
|
-
const parsedInfo = __assign(__assign({}, parsed), {
|
|
622
|
-
args: parsed.args.slice(1)
|
|
623
|
-
});
|
|
624
|
-
this.setParsedInfo(parsedInfo, command, commandName);
|
|
625
|
-
this.emit(`command:${commandName}`, command);
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
if (shouldParse) {
|
|
629
|
-
for (const command of this.commands) {
|
|
630
|
-
if (command.name === "") {
|
|
631
|
-
shouldParse = false;
|
|
632
|
-
const parsed = this.mri(argv.slice(2), command);
|
|
633
|
-
this.setParsedInfo(parsed, command);
|
|
634
|
-
this.emit(`command:!`, command);
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
if (shouldParse) {
|
|
639
|
-
const parsed = this.mri(argv.slice(2));
|
|
640
|
-
this.setParsedInfo(parsed);
|
|
641
|
-
}
|
|
642
|
-
if (this.options.help && this.showHelpOnExit) {
|
|
643
|
-
this.outputHelp();
|
|
644
|
-
run = false;
|
|
645
|
-
this.unsetMatchedCommand();
|
|
646
|
-
}
|
|
647
|
-
if (this.options.version && this.showVersionOnExit && this.matchedCommandName == null) {
|
|
648
|
-
this.outputVersion();
|
|
649
|
-
run = false;
|
|
650
|
-
this.unsetMatchedCommand();
|
|
651
|
-
}
|
|
652
|
-
const parsedArgv = {args: this.args, options: this.options};
|
|
653
|
-
if (run) {
|
|
654
|
-
this.runMatchedCommand();
|
|
655
|
-
}
|
|
656
|
-
if (!this.matchedCommand && this.args[0]) {
|
|
657
|
-
this.emit("command:*");
|
|
658
|
-
}
|
|
659
|
-
return parsedArgv;
|
|
660
|
-
}
|
|
661
|
-
mri(argv, command) {
|
|
662
|
-
const cliOptions = [
|
|
663
|
-
...this.globalCommand.options,
|
|
664
|
-
...command ? command.options : []
|
|
665
|
-
];
|
|
666
|
-
const mriOptions = getMriOptions(cliOptions);
|
|
667
|
-
let argsAfterDoubleDashes = [];
|
|
668
|
-
const doubleDashesIndex = argv.indexOf("--");
|
|
669
|
-
if (doubleDashesIndex > -1) {
|
|
670
|
-
argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
|
|
671
|
-
argv = argv.slice(0, doubleDashesIndex);
|
|
672
|
-
}
|
|
673
|
-
let parsed = mri2(argv, mriOptions);
|
|
674
|
-
parsed = Object.keys(parsed).reduce((res, name) => {
|
|
675
|
-
return __assign(__assign({}, res), {
|
|
676
|
-
[camelcaseOptionName(name)]: parsed[name]
|
|
677
|
-
});
|
|
678
|
-
}, {_: []});
|
|
679
|
-
const args = parsed._;
|
|
680
|
-
const options = {
|
|
681
|
-
"--": argsAfterDoubleDashes
|
|
682
|
-
};
|
|
683
|
-
const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
|
|
684
|
-
let transforms = Object.create(null);
|
|
685
|
-
for (const cliOption of cliOptions) {
|
|
686
|
-
if (!ignoreDefault && cliOption.config.default !== void 0) {
|
|
687
|
-
for (const name of cliOption.names) {
|
|
688
|
-
options[name] = cliOption.config.default;
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
if (cliOption.config.type != null) {
|
|
692
|
-
if (transforms[cliOption.name] === void 0) {
|
|
693
|
-
transforms[cliOption.name] = cliOption.config.type;
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
for (const key of Object.keys(parsed)) {
|
|
698
|
-
if (key !== "_") {
|
|
699
|
-
const keys = key.split(".");
|
|
700
|
-
setDotProp(options, keys, parsed[key], transforms);
|
|
701
|
-
// setByType(options, transforms);
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
return {
|
|
705
|
-
args,
|
|
706
|
-
options
|
|
707
|
-
};
|
|
708
|
-
}
|
|
709
|
-
runMatchedCommand() {
|
|
710
|
-
const {args, options, matchedCommand: command} = this;
|
|
711
|
-
if (!command || !command.commandAction)
|
|
712
|
-
return;
|
|
713
|
-
command.checkUnknownOptions();
|
|
714
|
-
command.checkOptionValue();
|
|
715
|
-
command.checkRequiredArgs();
|
|
716
|
-
const actionArgs = [];
|
|
717
|
-
command.args.forEach((arg, index) => {
|
|
718
|
-
if (arg.variadic) {
|
|
719
|
-
actionArgs.push(args.slice(index));
|
|
720
|
-
} else {
|
|
721
|
-
actionArgs.push(args[index]);
|
|
722
|
-
}
|
|
723
|
-
});
|
|
724
|
-
actionArgs.push(options);
|
|
725
|
-
return command.commandAction.apply(this, actionArgs);
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
const cac = (name = "") => new CAC(name);
|
|
730
|
-
|
|
731
|
-
var version = "1.4.0";
|
|
732
|
-
|
|
733
119
|
/*
|
|
734
120
|
How it works:
|
|
735
121
|
`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.
|
|
@@ -8566,7 +7952,7 @@ function createMethodsRPC(project) {
|
|
|
8566
7952
|
}
|
|
8567
7953
|
|
|
8568
7954
|
function createChildProcessChannel$1(project) {
|
|
8569
|
-
const emitter = new EventEmitter$
|
|
7955
|
+
const emitter = new EventEmitter$2();
|
|
8570
7956
|
const cleanup = () => emitter.removeAllListeners();
|
|
8571
7957
|
const events = { message: "message", response: "response" };
|
|
8572
7958
|
const channel = {
|
|
@@ -9213,7 +8599,7 @@ function createTypecheckPool(ctx) {
|
|
|
9213
8599
|
|
|
9214
8600
|
const suppressWarningsPath = resolve(rootDir, "./suppress-warnings.cjs");
|
|
9215
8601
|
function createChildProcessChannel(project) {
|
|
9216
|
-
const emitter = new EventEmitter$
|
|
8602
|
+
const emitter = new EventEmitter$2();
|
|
9217
8603
|
const cleanup = () => emitter.removeAllListeners();
|
|
9218
8604
|
const events = { message: "message", response: "response" };
|
|
9219
8605
|
const channel = {
|
|
@@ -9695,6 +9081,7 @@ const coverageConfigDefaults = {
|
|
|
9695
9081
|
reporter: [["text", {}], ["html", {}], ["clover", {}], ["json", {}]],
|
|
9696
9082
|
extension: [".js", ".cjs", ".mjs", ".ts", ".mts", ".cts", ".tsx", ".jsx", ".vue", ".svelte", ".marko"],
|
|
9697
9083
|
allowExternal: false,
|
|
9084
|
+
ignoreEmptyLines: false,
|
|
9698
9085
|
processingConcurrency: Math.min(20, ((_b = (_a = nodeos__default).availableParallelism) == null ? void 0 : _b.call(_a)) ?? nodeos__default.cpus().length)
|
|
9699
9086
|
};
|
|
9700
9087
|
const fakeTimersDefaults = {
|
|
@@ -9863,23 +9250,6 @@ class VitestCache {
|
|
|
9863
9250
|
const baseDir = slash$1(dir || "node_modules/.vite/vitest");
|
|
9864
9251
|
return projectName ? resolve(root, baseDir, crypto.createHash("md5").update(projectName, "utf-8").digest("hex")) : resolve(root, baseDir);
|
|
9865
9252
|
}
|
|
9866
|
-
static async clearCache(options) {
|
|
9867
|
-
var _a, _b, _c;
|
|
9868
|
-
const root = resolve(options.root || process.cwd());
|
|
9869
|
-
const configPath = options.config === false ? false : options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
|
|
9870
|
-
const config = configPath ? (_a = await loadConfigFromFile({ command: "serve", mode: "test" }, configPath)) == null ? void 0 : _a.config : void 0;
|
|
9871
|
-
const cache = (_b = config == null ? void 0 : config.test) == null ? void 0 : _b.cache;
|
|
9872
|
-
const projectName = (_c = config == null ? void 0 : config.test) == null ? void 0 : _c.name;
|
|
9873
|
-
if (cache === false)
|
|
9874
|
-
throw new Error("Cache is disabled");
|
|
9875
|
-
const cachePath = VitestCache.resolveCacheDir(root, cache == null ? void 0 : cache.dir, projectName);
|
|
9876
|
-
let cleared = false;
|
|
9877
|
-
if (fs$8.existsSync(cachePath)) {
|
|
9878
|
-
fs$8.rmSync(cachePath, { recursive: true, force: true });
|
|
9879
|
-
cleared = true;
|
|
9880
|
-
}
|
|
9881
|
-
return { dir: cachePath, cleared };
|
|
9882
|
-
}
|
|
9883
9253
|
}
|
|
9884
9254
|
|
|
9885
9255
|
function resolvePath(path, root) {
|
|
@@ -9887,6 +9257,18 @@ function resolvePath(path, root) {
|
|
|
9887
9257
|
resolveModule(path, { paths: [root] }) ?? resolve(root, path)
|
|
9888
9258
|
);
|
|
9889
9259
|
}
|
|
9260
|
+
function parseInspector(inspect) {
|
|
9261
|
+
if (typeof inspect === "boolean" || inspect === void 0)
|
|
9262
|
+
return {};
|
|
9263
|
+
if (typeof inspect === "number")
|
|
9264
|
+
return { port: inspect };
|
|
9265
|
+
if (inspect.match(/https?:\//))
|
|
9266
|
+
throw new Error(`Inspector host cannot be a URL. Use "host:port" instead of "${inspect}"`);
|
|
9267
|
+
const [host, port] = inspect.split(":");
|
|
9268
|
+
if (!port)
|
|
9269
|
+
return { host };
|
|
9270
|
+
return { host, port: Number(port) || defaultInspectPort };
|
|
9271
|
+
}
|
|
9890
9272
|
function resolveApiServerConfig(options) {
|
|
9891
9273
|
let api;
|
|
9892
9274
|
if (options.ui && !options.api)
|
|
@@ -9915,11 +9297,11 @@ function resolveApiServerConfig(options) {
|
|
|
9915
9297
|
}
|
|
9916
9298
|
return api;
|
|
9917
9299
|
}
|
|
9918
|
-
function resolveConfig(mode, options, viteConfig) {
|
|
9919
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K;
|
|
9300
|
+
function resolveConfig(mode, options, viteConfig, logger) {
|
|
9301
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M;
|
|
9920
9302
|
if (options.dom) {
|
|
9921
9303
|
if (((_a = viteConfig.test) == null ? void 0 : _a.environment) != null && viteConfig.test.environment !== "happy-dom") {
|
|
9922
|
-
console.warn(
|
|
9304
|
+
logger.console.warn(
|
|
9923
9305
|
c.yellow(
|
|
9924
9306
|
`${c.inverse(c.yellow(" Vitest "))} Your config.test.environment ("${viteConfig.test.environment}") conflicts with --dom flag ("happy-dom"), ignoring "${viteConfig.test.environment}"`
|
|
9925
9307
|
)
|
|
@@ -9933,8 +9315,13 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
9933
9315
|
root: viteConfig.root,
|
|
9934
9316
|
mode
|
|
9935
9317
|
};
|
|
9936
|
-
resolved.inspect
|
|
9937
|
-
resolved.
|
|
9318
|
+
const inspector = resolved.inspect || resolved.inspectBrk;
|
|
9319
|
+
resolved.inspector = {
|
|
9320
|
+
...resolved.inspector,
|
|
9321
|
+
...parseInspector(inspector),
|
|
9322
|
+
enabled: !!inspector,
|
|
9323
|
+
waitForDebugger: ((_b = options.inspector) == null ? void 0 : _b.waitForDebugger) ?? !!resolved.inspectBrk
|
|
9324
|
+
};
|
|
9938
9325
|
if (viteConfig.base !== "/")
|
|
9939
9326
|
resolved.base = viteConfig.base;
|
|
9940
9327
|
resolved.clearScreen = resolved.clearScreen ?? viteConfig.clearScreen ?? true;
|
|
@@ -9954,14 +9341,16 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
9954
9341
|
resolved.maxWorkers = Number(resolved.maxWorkers);
|
|
9955
9342
|
if (resolved.minWorkers)
|
|
9956
9343
|
resolved.minWorkers = Number(resolved.minWorkers);
|
|
9957
|
-
resolved.
|
|
9344
|
+
resolved.browser ?? (resolved.browser = {});
|
|
9345
|
+
(_c = resolved.browser).fileParallelism ?? (_c.fileParallelism = resolved.fileParallelism ?? false);
|
|
9346
|
+
resolved.fileParallelism ?? (resolved.fileParallelism = mode !== "benchmark");
|
|
9958
9347
|
if (!resolved.fileParallelism) {
|
|
9959
9348
|
resolved.maxWorkers = 1;
|
|
9960
9349
|
resolved.minWorkers = 1;
|
|
9961
9350
|
}
|
|
9962
9351
|
if (resolved.inspect || resolved.inspectBrk) {
|
|
9963
|
-
const isSingleThread = resolved.pool === "threads" && ((
|
|
9964
|
-
const isSingleFork = resolved.pool === "forks" && ((
|
|
9352
|
+
const isSingleThread = resolved.pool === "threads" && ((_e = (_d = resolved.poolOptions) == null ? void 0 : _d.threads) == null ? void 0 : _e.singleThread);
|
|
9353
|
+
const isSingleFork = resolved.pool === "forks" && ((_g = (_f = resolved.poolOptions) == null ? void 0 : _f.forks) == null ? void 0 : _g.singleFork);
|
|
9965
9354
|
if (resolved.fileParallelism && !isSingleThread && !isSingleFork) {
|
|
9966
9355
|
const inspectOption = `--inspect${resolved.inspectBrk ? "-brk" : ""}`;
|
|
9967
9356
|
throw new Error(`You cannot use ${inspectOption} without "--no-file-parallelism", "poolOptions.threads.singleThread" or "poolOptions.forks.singleFork"`);
|
|
@@ -9977,7 +9366,7 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
9977
9366
|
throw new Error(`You cannot set "coverage.reportsDirectory" as ${reportsDirectory}. Vitest needs to be able to remove this directory before test run`);
|
|
9978
9367
|
}
|
|
9979
9368
|
resolved.deps ?? (resolved.deps = {});
|
|
9980
|
-
(
|
|
9369
|
+
(_h = resolved.deps).moduleDirectories ?? (_h.moduleDirectories = []);
|
|
9981
9370
|
resolved.deps.moduleDirectories = resolved.deps.moduleDirectories.map((dir) => {
|
|
9982
9371
|
if (!dir.startsWith("/"))
|
|
9983
9372
|
dir = `/${dir}`;
|
|
@@ -9987,26 +9376,26 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
9987
9376
|
});
|
|
9988
9377
|
if (!resolved.deps.moduleDirectories.includes("/node_modules/"))
|
|
9989
9378
|
resolved.deps.moduleDirectories.push("/node_modules/");
|
|
9990
|
-
(
|
|
9991
|
-
(
|
|
9992
|
-
(
|
|
9993
|
-
(
|
|
9994
|
-
(
|
|
9995
|
-
(
|
|
9996
|
-
(
|
|
9997
|
-
(
|
|
9998
|
-
(
|
|
9379
|
+
(_i = resolved.deps).optimizer ?? (_i.optimizer = {});
|
|
9380
|
+
(_j = resolved.deps.optimizer).ssr ?? (_j.ssr = {});
|
|
9381
|
+
(_k = resolved.deps.optimizer.ssr).enabled ?? (_k.enabled = true);
|
|
9382
|
+
(_l = resolved.deps.optimizer).web ?? (_l.web = {});
|
|
9383
|
+
(_m = resolved.deps.optimizer.web).enabled ?? (_m.enabled = true);
|
|
9384
|
+
(_n = resolved.deps).web ?? (_n.web = {});
|
|
9385
|
+
(_o = resolved.deps.web).transformAssets ?? (_o.transformAssets = true);
|
|
9386
|
+
(_p = resolved.deps.web).transformCss ?? (_p.transformCss = true);
|
|
9387
|
+
(_q = resolved.deps.web).transformGlobPattern ?? (_q.transformGlobPattern = []);
|
|
9999
9388
|
resolved.server ?? (resolved.server = {});
|
|
10000
|
-
(
|
|
9389
|
+
(_r = resolved.server).deps ?? (_r.deps = {});
|
|
10001
9390
|
const deprecatedDepsOptions = ["inline", "external", "fallbackCJS"];
|
|
10002
9391
|
deprecatedDepsOptions.forEach((option) => {
|
|
10003
9392
|
if (resolved.deps[option] === void 0)
|
|
10004
9393
|
return;
|
|
10005
9394
|
if (option === "fallbackCJS") {
|
|
10006
|
-
console.warn(c.yellow(`${c.inverse(c.yellow(" Vitest "))} "deps.${option}" is deprecated. Use "server.deps.${option}" instead`));
|
|
9395
|
+
logger.console.warn(c.yellow(`${c.inverse(c.yellow(" Vitest "))} "deps.${option}" is deprecated. Use "server.deps.${option}" instead`));
|
|
10007
9396
|
} else {
|
|
10008
9397
|
const transformMode = resolved.environment === "happy-dom" || resolved.environment === "jsdom" ? "web" : "ssr";
|
|
10009
|
-
console.warn(
|
|
9398
|
+
logger.console.warn(
|
|
10010
9399
|
c.yellow(
|
|
10011
9400
|
`${c.inverse(c.yellow(" Vitest "))} "deps.${option}" is deprecated. If you rely on vite-node directly, use "server.deps.${option}" instead. Otherwise, consider using "deps.optimizer.${transformMode}.${option === "external" ? "exclude" : "include"}"`
|
|
10012
9401
|
)
|
|
@@ -10022,11 +9411,11 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
10022
9411
|
if ((ssrOptions == null ? void 0 : ssrOptions.noExternal) === true && resolved.server.deps.inline == null) {
|
|
10023
9412
|
resolved.server.deps.inline = true;
|
|
10024
9413
|
} else {
|
|
10025
|
-
(
|
|
9414
|
+
(_s = resolved.server.deps).inline ?? (_s.inline = []);
|
|
10026
9415
|
resolved.server.deps.inline.push(...extraInlineDeps);
|
|
10027
9416
|
}
|
|
10028
9417
|
}
|
|
10029
|
-
(
|
|
9418
|
+
(_t = resolved.server.deps).moduleDirectories ?? (_t.moduleDirectories = []);
|
|
10030
9419
|
resolved.server.deps.moduleDirectories.push(...resolved.deps.moduleDirectories);
|
|
10031
9420
|
if (resolved.runner)
|
|
10032
9421
|
resolved.runner = resolvePath(resolved.runner, resolved.root);
|
|
@@ -10054,11 +9443,11 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
10054
9443
|
resolved.poolOptions = {
|
|
10055
9444
|
...resolved.poolOptions,
|
|
10056
9445
|
threads: {
|
|
10057
|
-
...(
|
|
9446
|
+
...(_u = resolved.poolOptions) == null ? void 0 : _u.threads,
|
|
10058
9447
|
maxThreads: Number.parseInt(process.env.VITEST_MAX_THREADS)
|
|
10059
9448
|
},
|
|
10060
9449
|
vmThreads: {
|
|
10061
|
-
...(
|
|
9450
|
+
...(_v = resolved.poolOptions) == null ? void 0 : _v.vmThreads,
|
|
10062
9451
|
maxThreads: Number.parseInt(process.env.VITEST_MAX_THREADS)
|
|
10063
9452
|
}
|
|
10064
9453
|
};
|
|
@@ -10067,11 +9456,11 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
10067
9456
|
resolved.poolOptions = {
|
|
10068
9457
|
...resolved.poolOptions,
|
|
10069
9458
|
threads: {
|
|
10070
|
-
...(
|
|
9459
|
+
...(_w = resolved.poolOptions) == null ? void 0 : _w.threads,
|
|
10071
9460
|
minThreads: Number.parseInt(process.env.VITEST_MIN_THREADS)
|
|
10072
9461
|
},
|
|
10073
9462
|
vmThreads: {
|
|
10074
|
-
...(
|
|
9463
|
+
...(_x = resolved.poolOptions) == null ? void 0 : _x.vmThreads,
|
|
10075
9464
|
minThreads: Number.parseInt(process.env.VITEST_MIN_THREADS)
|
|
10076
9465
|
}
|
|
10077
9466
|
};
|
|
@@ -10080,11 +9469,11 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
10080
9469
|
resolved.poolOptions = {
|
|
10081
9470
|
...resolved.poolOptions,
|
|
10082
9471
|
forks: {
|
|
10083
|
-
...(
|
|
9472
|
+
...(_y = resolved.poolOptions) == null ? void 0 : _y.forks,
|
|
10084
9473
|
maxForks: Number.parseInt(process.env.VITEST_MAX_FORKS)
|
|
10085
9474
|
},
|
|
10086
9475
|
vmForks: {
|
|
10087
|
-
...(
|
|
9476
|
+
...(_z = resolved.poolOptions) == null ? void 0 : _z.vmForks,
|
|
10088
9477
|
maxForks: Number.parseInt(process.env.VITEST_MAX_FORKS)
|
|
10089
9478
|
}
|
|
10090
9479
|
};
|
|
@@ -10093,11 +9482,11 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
10093
9482
|
resolved.poolOptions = {
|
|
10094
9483
|
...resolved.poolOptions,
|
|
10095
9484
|
forks: {
|
|
10096
|
-
...(
|
|
9485
|
+
...(_A = resolved.poolOptions) == null ? void 0 : _A.forks,
|
|
10097
9486
|
minForks: Number.parseInt(process.env.VITEST_MIN_FORKS)
|
|
10098
9487
|
},
|
|
10099
9488
|
vmForks: {
|
|
10100
|
-
...(
|
|
9489
|
+
...(_B = resolved.poolOptions) == null ? void 0 : _B.vmForks,
|
|
10101
9490
|
minForks: Number.parseInt(process.env.VITEST_MIN_FORKS)
|
|
10102
9491
|
}
|
|
10103
9492
|
};
|
|
@@ -10189,13 +9578,13 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
10189
9578
|
resolved.passWithNoTests ?? (resolved.passWithNoTests = true);
|
|
10190
9579
|
resolved.css ?? (resolved.css = {});
|
|
10191
9580
|
if (typeof resolved.css === "object") {
|
|
10192
|
-
(
|
|
10193
|
-
(
|
|
9581
|
+
(_C = resolved.css).modules ?? (_C.modules = {});
|
|
9582
|
+
(_D = resolved.css.modules).classNameStrategy ?? (_D.classNameStrategy = "stable");
|
|
10194
9583
|
}
|
|
10195
9584
|
if (resolved.cache !== false) {
|
|
10196
9585
|
let cacheDir = VitestCache.resolveCacheDir("", resolve(viteConfig.cacheDir, "vitest"), resolved.name);
|
|
10197
9586
|
if (resolved.cache && resolved.cache.dir) {
|
|
10198
|
-
console.warn(
|
|
9587
|
+
logger.console.warn(
|
|
10199
9588
|
c.yellow(
|
|
10200
9589
|
`${c.inverse(c.yellow(" Vitest "))} "cache.dir" is deprecated, use Vite's "cacheDir" instead if you want to change the cache director. Note caches will be written to "cacheDir/vitest"`
|
|
10201
9590
|
)
|
|
@@ -10207,29 +9596,29 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
10207
9596
|
resolved.sequence ?? (resolved.sequence = {});
|
|
10208
9597
|
if (resolved.sequence.shuffle && typeof resolved.sequence.shuffle === "object") {
|
|
10209
9598
|
const { files, tests } = resolved.sequence.shuffle;
|
|
10210
|
-
(
|
|
9599
|
+
(_E = resolved.sequence).sequencer ?? (_E.sequencer = files ? RandomSequencer : BaseSequencer);
|
|
10211
9600
|
resolved.sequence.shuffle = tests;
|
|
10212
9601
|
}
|
|
10213
|
-
if (!((
|
|
9602
|
+
if (!((_F = resolved.sequence) == null ? void 0 : _F.sequencer)) {
|
|
10214
9603
|
resolved.sequence.sequencer = resolved.sequence.shuffle ? RandomSequencer : BaseSequencer;
|
|
10215
9604
|
}
|
|
10216
|
-
(
|
|
9605
|
+
(_G = resolved.sequence).hooks ?? (_G.hooks = "parallel");
|
|
10217
9606
|
if (resolved.sequence.sequencer === RandomSequencer)
|
|
10218
|
-
(
|
|
9607
|
+
(_H = resolved.sequence).seed ?? (_H.seed = Date.now());
|
|
10219
9608
|
resolved.typecheck = {
|
|
10220
9609
|
...configDefaults.typecheck,
|
|
10221
9610
|
...resolved.typecheck
|
|
10222
9611
|
};
|
|
10223
9612
|
resolved.environmentMatchGlobs = (resolved.environmentMatchGlobs || []).map((i) => [resolve(resolved.root, i[0]), i[1]]);
|
|
10224
9613
|
resolved.typecheck ?? (resolved.typecheck = {});
|
|
10225
|
-
(
|
|
9614
|
+
(_I = resolved.typecheck).enabled ?? (_I.enabled = false);
|
|
10226
9615
|
if (resolved.typecheck.enabled)
|
|
10227
|
-
console.warn(c.yellow("Testing types with tsc and vue-tsc is an experimental feature.\nBreaking changes might not follow SemVer, please pin Vitest's version when using it."));
|
|
9616
|
+
logger.console.warn(c.yellow("Testing types with tsc and vue-tsc is an experimental feature.\nBreaking changes might not follow SemVer, please pin Vitest's version when using it."));
|
|
10228
9617
|
resolved.browser ?? (resolved.browser = {});
|
|
10229
|
-
(
|
|
10230
|
-
(
|
|
10231
|
-
(
|
|
10232
|
-
(
|
|
9618
|
+
(_J = resolved.browser).enabled ?? (_J.enabled = false);
|
|
9619
|
+
(_K = resolved.browser).headless ?? (_K.headless = isCI);
|
|
9620
|
+
(_L = resolved.browser).slowHijackESM ?? (_L.slowHijackESM = false);
|
|
9621
|
+
(_M = resolved.browser).isolate ?? (_M.isolate = true);
|
|
10233
9622
|
if (resolved.browser.enabled && provider$1 === "stackblitz")
|
|
10234
9623
|
resolved.browser.provider = "none";
|
|
10235
9624
|
resolved.browser.api = resolveApiServerConfig(resolved.browser) || {
|
|
@@ -11162,13 +10551,15 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
|
|
|
11162
10551
|
isInSourceTestFile(code) {
|
|
11163
10552
|
return code.includes("import.meta.vitest");
|
|
11164
10553
|
}
|
|
11165
|
-
filterFiles(testFiles, filters
|
|
10554
|
+
filterFiles(testFiles, filters, dir) {
|
|
11166
10555
|
if (filters.length && process.platform === "win32")
|
|
11167
10556
|
filters = filters.map((f) => toNamespacedPath(f));
|
|
11168
10557
|
if (filters.length) {
|
|
11169
10558
|
return testFiles.filter((t) => {
|
|
11170
10559
|
const testFile = relative(dir, t).toLocaleLowerCase();
|
|
11171
10560
|
return filters.some((f) => {
|
|
10561
|
+
if (isAbsolute(f) && t.startsWith(f))
|
|
10562
|
+
return true;
|
|
11172
10563
|
const relativePath = f.endsWith("/") ? join(relative(dir, f), "/") : relative(dir, f);
|
|
11173
10564
|
return testFile.includes(f.toLocaleLowerCase()) || testFile.includes(relativePath.toLocaleLowerCase());
|
|
11174
10565
|
});
|
|
@@ -11203,7 +10594,8 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
|
|
|
11203
10594
|
...options,
|
|
11204
10595
|
coverage: this.ctx.config.coverage
|
|
11205
10596
|
},
|
|
11206
|
-
server.config
|
|
10597
|
+
server.config,
|
|
10598
|
+
this.ctx.logger
|
|
11207
10599
|
);
|
|
11208
10600
|
this.server = server;
|
|
11209
10601
|
this.vitenode = new ViteNodeServer(server, this.config.server);
|
|
@@ -11224,7 +10616,7 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
|
|
|
11224
10616
|
return isBrowserEnabled(this.config);
|
|
11225
10617
|
}
|
|
11226
10618
|
getSerializableConfig() {
|
|
11227
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
10619
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
11228
10620
|
const optimizer = (_a = this.config.deps) == null ? void 0 : _a.optimizer;
|
|
11229
10621
|
const poolOptions = this.config.poolOptions;
|
|
11230
10622
|
const isolate = (_d = (_c = (_b = this.server) == null ? void 0 : _b.config) == null ? void 0 : _c.test) == null ? void 0 : _d.isolate;
|
|
@@ -11272,8 +10664,13 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
|
|
|
11272
10664
|
},
|
|
11273
10665
|
inspect: this.ctx.config.inspect,
|
|
11274
10666
|
inspectBrk: this.ctx.config.inspectBrk,
|
|
10667
|
+
inspector: this.ctx.config.inspector,
|
|
11275
10668
|
alias: [],
|
|
11276
|
-
includeTaskLocation: this.config.includeTaskLocation ?? this.ctx.config.includeTaskLocation
|
|
10669
|
+
includeTaskLocation: this.config.includeTaskLocation ?? this.ctx.config.includeTaskLocation,
|
|
10670
|
+
env: {
|
|
10671
|
+
...(_v = this.server) == null ? void 0 : _v.config.env,
|
|
10672
|
+
...this.config.env
|
|
10673
|
+
}
|
|
11277
10674
|
}, this.ctx.configOverride || {});
|
|
11278
10675
|
}
|
|
11279
10676
|
close() {
|
|
@@ -11348,7 +10745,7 @@ const WATCHER_DEBOUNCE = 100;
|
|
|
11348
10745
|
class Vitest {
|
|
11349
10746
|
constructor(mode, options = {}) {
|
|
11350
10747
|
this.mode = mode;
|
|
11351
|
-
this.logger = new Logger(this);
|
|
10748
|
+
this.logger = new Logger(this, options.stdout, options.stderr);
|
|
11352
10749
|
this.packageInstaller = options.packageInstaller || new VitestPackageInstaller();
|
|
11353
10750
|
}
|
|
11354
10751
|
config = void 0;
|
|
@@ -11392,7 +10789,7 @@ class Vitest {
|
|
|
11392
10789
|
this.coverageProvider = void 0;
|
|
11393
10790
|
this.runningPromise = void 0;
|
|
11394
10791
|
this.projectsTestFiles.clear();
|
|
11395
|
-
const resolved = resolveConfig(this.mode, options, server.config);
|
|
10792
|
+
const resolved = resolveConfig(this.mode, options, server.config, this.logger);
|
|
11396
10793
|
this.server = server;
|
|
11397
10794
|
this.config = resolved;
|
|
11398
10795
|
this.state = new StateManager();
|
|
@@ -11562,17 +10959,36 @@ class Vitest {
|
|
|
11562
10959
|
acc[name] = cliOptions[name];
|
|
11563
10960
|
return acc;
|
|
11564
10961
|
}, {});
|
|
11565
|
-
const
|
|
11566
|
-
|
|
11567
|
-
|
|
11568
|
-
|
|
11569
|
-
|
|
10962
|
+
const cwd = process.cwd();
|
|
10963
|
+
const projects = [];
|
|
10964
|
+
try {
|
|
10965
|
+
for (const filepath of filteredWorkspaces) {
|
|
10966
|
+
if (this.server.config.configFile === filepath) {
|
|
10967
|
+
const project = await this.createCoreProject();
|
|
10968
|
+
projects.push(project);
|
|
10969
|
+
continue;
|
|
10970
|
+
}
|
|
10971
|
+
const dir = filepath.endsWith("/") ? filepath.slice(0, -1) : dirname(filepath);
|
|
10972
|
+
if (isMainThread)
|
|
10973
|
+
process.chdir(dir);
|
|
10974
|
+
projects.push(
|
|
10975
|
+
await initializeProject(filepath, this, { workspaceConfigPath, test: cliOverrides })
|
|
10976
|
+
);
|
|
10977
|
+
}
|
|
10978
|
+
} finally {
|
|
10979
|
+
if (isMainThread)
|
|
10980
|
+
process.chdir(cwd);
|
|
10981
|
+
}
|
|
10982
|
+
const projectPromises = [];
|
|
11570
10983
|
projectsOptions.forEach((options, index) => {
|
|
11571
|
-
|
|
10984
|
+
projectPromises.push(initializeProject(index, this, mergeConfig(options, { workspaceConfigPath, test: cliOverrides })));
|
|
11572
10985
|
});
|
|
11573
|
-
if (!projects.length)
|
|
10986
|
+
if (!projects.length && !projectPromises.length)
|
|
11574
10987
|
return [await this.createCoreProject()];
|
|
11575
|
-
const resolvedProjects = await Promise.all(
|
|
10988
|
+
const resolvedProjects = await Promise.all([
|
|
10989
|
+
...projects,
|
|
10990
|
+
...await Promise.all(projectPromises)
|
|
10991
|
+
]);
|
|
11576
10992
|
const names = /* @__PURE__ */ new Set();
|
|
11577
10993
|
for (const project of resolvedProjects) {
|
|
11578
10994
|
const name = project.getName();
|
|
@@ -11935,14 +11351,14 @@ class Vitest {
|
|
|
11935
11351
|
if (!i.file)
|
|
11936
11352
|
return;
|
|
11937
11353
|
const heedsRerun = this.handleFileChanged(i.file);
|
|
11938
|
-
if (heedsRerun)
|
|
11354
|
+
if (heedsRerun.length)
|
|
11939
11355
|
rerun = true;
|
|
11940
11356
|
});
|
|
11941
11357
|
}
|
|
11942
11358
|
if (rerun)
|
|
11943
11359
|
files.push(filepath);
|
|
11944
11360
|
}
|
|
11945
|
-
return files;
|
|
11361
|
+
return Array.from(new Set(files));
|
|
11946
11362
|
}
|
|
11947
11363
|
async reportCoverage(allTestsRun) {
|
|
11948
11364
|
if (!this.config.coverage.reportOnFailure && this.state.getCountOfFailedTests() > 0)
|
|
@@ -11963,8 +11379,8 @@ class Vitest {
|
|
|
11963
11379
|
teardownProjects.push(this.coreWorkspaceProject);
|
|
11964
11380
|
for await (const project of teardownProjects.reverse())
|
|
11965
11381
|
await project.teardownGlobalSetup();
|
|
11966
|
-
const closePromises = this.
|
|
11967
|
-
if (!this.
|
|
11382
|
+
const closePromises = this.resolvedProjects.map((w) => w.close().then(() => w.server = void 0));
|
|
11383
|
+
if (!this.resolvedProjects.includes(this.coreWorkspaceProject))
|
|
11968
11384
|
closePromises.push(this.coreWorkspaceProject.close().then(() => this.server = void 0));
|
|
11969
11385
|
if (this.pool) {
|
|
11970
11386
|
closePromises.push((async () => {
|
|
@@ -11993,7 +11409,7 @@ class Vitest {
|
|
|
11993
11409
|
console.warn(`close timed out after ${this.config.teardownTimeout}ms`);
|
|
11994
11410
|
this.state.getProcessTimeoutCauses().forEach((cause) => console.warn(cause));
|
|
11995
11411
|
if (!this.pool) {
|
|
11996
|
-
const runningServers = [this.server, ...this.
|
|
11412
|
+
const runningServers = [this.server, ...this.resolvedProjects.map((p) => p.server)].filter(Boolean).length;
|
|
11997
11413
|
if (runningServers === 1)
|
|
11998
11414
|
console.warn("Tests closed successfully but something prevents Vite server from exiting");
|
|
11999
11415
|
else if (runningServers > 1)
|
|
@@ -12110,6 +11526,15 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
12110
11526
|
allow: resolveFsAllow(getRoot(), testConfig.config)
|
|
12111
11527
|
}
|
|
12112
11528
|
},
|
|
11529
|
+
build: {
|
|
11530
|
+
// Vitest doesn't use outputDir, but this value affects what folders are watched
|
|
11531
|
+
// https://github.com/vitest-dev/vitest/issues/5429
|
|
11532
|
+
// This works for Vite <5.2.10
|
|
11533
|
+
outDir: "dummy-non-existing-folder",
|
|
11534
|
+
// This works for Vite >=5.2.10
|
|
11535
|
+
// https://github.com/vitejs/vite/pull/16453
|
|
11536
|
+
emptyOutDir: false
|
|
11537
|
+
},
|
|
12113
11538
|
test: {
|
|
12114
11539
|
poolOptions: {
|
|
12115
11540
|
threads: {
|
|
@@ -18506,20 +17931,24 @@ class WatchFilter {
|
|
|
18506
17931
|
results = [];
|
|
18507
17932
|
selectionIndex = -1;
|
|
18508
17933
|
onKeyPress;
|
|
18509
|
-
|
|
17934
|
+
stdin;
|
|
17935
|
+
stdout;
|
|
17936
|
+
constructor(message, stdin = process.stdin, stdout$1 = stdout()) {
|
|
18510
17937
|
this.message = message;
|
|
18511
|
-
this.
|
|
18512
|
-
|
|
18513
|
-
|
|
18514
|
-
|
|
17938
|
+
this.stdin = stdin;
|
|
17939
|
+
this.stdout = stdout$1;
|
|
17940
|
+
this.filterRL = readline.createInterface({ input: this.stdin, escapeCodeTimeout: 50 });
|
|
17941
|
+
readline.emitKeypressEvents(this.stdin, this.filterRL);
|
|
17942
|
+
if (this.stdin.isTTY)
|
|
17943
|
+
this.stdin.setRawMode(true);
|
|
18515
17944
|
}
|
|
18516
17945
|
async filter(filterFunc) {
|
|
18517
|
-
|
|
17946
|
+
this.write(this.promptLine());
|
|
18518
17947
|
const resultPromise = createDefer();
|
|
18519
17948
|
this.onKeyPress = this.filterHandler(filterFunc, (result) => {
|
|
18520
17949
|
resultPromise.resolve(result);
|
|
18521
17950
|
});
|
|
18522
|
-
|
|
17951
|
+
this.stdin.on("keypress", this.onKeyPress);
|
|
18523
17952
|
try {
|
|
18524
17953
|
return await resultPromise;
|
|
18525
17954
|
} finally {
|
|
@@ -18606,27 +18035,32 @@ ${resultBody}`;
|
|
|
18606
18035
|
eraseAndPrint(str) {
|
|
18607
18036
|
let rows = 0;
|
|
18608
18037
|
const lines = str.split(/\r?\n/);
|
|
18609
|
-
for (const line of lines)
|
|
18610
|
-
|
|
18611
|
-
|
|
18612
|
-
|
|
18613
|
-
|
|
18614
|
-
|
|
18038
|
+
for (const line of lines) {
|
|
18039
|
+
const columns = "columns" in this.stdout ? this.stdout.columns : 80;
|
|
18040
|
+
rows += 1 + Math.floor(Math.max(stripAnsi(line).length - 1, 0) / columns);
|
|
18041
|
+
}
|
|
18042
|
+
this.write(`${ESC}1G`);
|
|
18043
|
+
this.write(`${ESC}J`);
|
|
18044
|
+
this.write(str);
|
|
18045
|
+
this.write(`${ESC}${rows - 1}A`);
|
|
18615
18046
|
}
|
|
18616
18047
|
close() {
|
|
18617
18048
|
this.filterRL.close();
|
|
18618
18049
|
if (this.onKeyPress)
|
|
18619
|
-
|
|
18620
|
-
if (
|
|
18621
|
-
|
|
18050
|
+
this.stdin.removeListener("keypress", this.onKeyPress);
|
|
18051
|
+
if (this.stdin.isTTY)
|
|
18052
|
+
this.stdin.setRawMode(false);
|
|
18622
18053
|
}
|
|
18623
18054
|
restoreCursor() {
|
|
18624
18055
|
var _a;
|
|
18625
18056
|
const cursortPos = this.keywordOffset() + (((_a = this.currentKeyword) == null ? void 0 : _a.length) || 0);
|
|
18626
|
-
|
|
18057
|
+
this.write(`${ESC}${cursortPos}G`);
|
|
18627
18058
|
}
|
|
18628
18059
|
cancel() {
|
|
18629
|
-
|
|
18060
|
+
this.write(`${ESC}J`);
|
|
18061
|
+
}
|
|
18062
|
+
write(data) {
|
|
18063
|
+
this.stdout.write(data);
|
|
18630
18064
|
}
|
|
18631
18065
|
}
|
|
18632
18066
|
|
|
@@ -18649,7 +18083,7 @@ ${keys.map((i) => c.dim(" press ") + c.reset([i[0]].flat().map(c.bold).join(",
|
|
|
18649
18083
|
`
|
|
18650
18084
|
);
|
|
18651
18085
|
}
|
|
18652
|
-
function registerConsoleShortcuts(ctx) {
|
|
18086
|
+
function registerConsoleShortcuts(ctx, stdin = process.stdin, stdout2) {
|
|
18653
18087
|
let latestFilename = "";
|
|
18654
18088
|
async function _keypressHandler(str, key) {
|
|
18655
18089
|
if (str === "" || str === "\x1B" || key && key.ctrl && key.name === "c") {
|
|
@@ -18697,7 +18131,7 @@ function registerConsoleShortcuts(ctx) {
|
|
|
18697
18131
|
}
|
|
18698
18132
|
async function inputNamePattern() {
|
|
18699
18133
|
off();
|
|
18700
|
-
const watchFilter = new WatchFilter("Input test name pattern (RegExp)");
|
|
18134
|
+
const watchFilter = new WatchFilter("Input test name pattern (RegExp)", stdin, stdout2);
|
|
18701
18135
|
const filter = await watchFilter.filter((str) => {
|
|
18702
18136
|
const files = ctx.state.getFiles();
|
|
18703
18137
|
const tests = getTests(files);
|
|
@@ -18724,7 +18158,7 @@ function registerConsoleShortcuts(ctx) {
|
|
|
18724
18158
|
}
|
|
18725
18159
|
async function inputFilePattern() {
|
|
18726
18160
|
off();
|
|
18727
|
-
const watchFilter = new WatchFilter("Input filename pattern");
|
|
18161
|
+
const watchFilter = new WatchFilter("Input filename pattern", stdin, stdout2);
|
|
18728
18162
|
const filter = await watchFilter.filter(async (str) => {
|
|
18729
18163
|
const files = await ctx.globTestFiles([str]);
|
|
18730
18164
|
return files.map(
|
|
@@ -18738,18 +18172,18 @@ function registerConsoleShortcuts(ctx) {
|
|
|
18738
18172
|
let rl;
|
|
18739
18173
|
function on() {
|
|
18740
18174
|
off();
|
|
18741
|
-
rl = readline.createInterface({ input:
|
|
18742
|
-
readline.emitKeypressEvents(
|
|
18743
|
-
if (
|
|
18744
|
-
|
|
18745
|
-
|
|
18175
|
+
rl = readline.createInterface({ input: stdin, escapeCodeTimeout: 50 });
|
|
18176
|
+
readline.emitKeypressEvents(stdin, rl);
|
|
18177
|
+
if (stdin.isTTY)
|
|
18178
|
+
stdin.setRawMode(true);
|
|
18179
|
+
stdin.on("keypress", keypressHandler);
|
|
18746
18180
|
}
|
|
18747
18181
|
function off() {
|
|
18748
18182
|
rl == null ? void 0 : rl.close();
|
|
18749
18183
|
rl = void 0;
|
|
18750
|
-
|
|
18751
|
-
if (
|
|
18752
|
-
|
|
18184
|
+
stdin.removeListener("keypress", keypressHandler);
|
|
18185
|
+
if (stdin.isTTY)
|
|
18186
|
+
stdin.setRawMode(false);
|
|
18753
18187
|
}
|
|
18754
18188
|
on();
|
|
18755
18189
|
return function cleanup() {
|
|
@@ -18785,9 +18219,11 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides, v
|
|
|
18785
18219
|
process.exitCode = 1;
|
|
18786
18220
|
return ctx;
|
|
18787
18221
|
}
|
|
18222
|
+
const stdin = (vitestOptions == null ? void 0 : vitestOptions.stdin) || process.stdin;
|
|
18223
|
+
const stdout = (vitestOptions == null ? void 0 : vitestOptions.stdout) || process.stdout;
|
|
18788
18224
|
let stdinCleanup;
|
|
18789
|
-
if (
|
|
18790
|
-
stdinCleanup = registerConsoleShortcuts(ctx);
|
|
18225
|
+
if (stdin.isTTY && ctx.config.watch)
|
|
18226
|
+
stdinCleanup = registerConsoleShortcuts(ctx, stdin, stdout);
|
|
18791
18227
|
ctx.onServerRestart((reason) => {
|
|
18792
18228
|
ctx.report("onServerRestart", reason);
|
|
18793
18229
|
if (process.env.VITEST_CLI_WRAPPER)
|
|
@@ -18811,766 +18247,9 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides, v
|
|
|
18811
18247
|
return ctx;
|
|
18812
18248
|
}
|
|
18813
18249
|
|
|
18814
|
-
|
|
18815
|
-
|
|
18816
|
-
|
|
18817
|
-
argument: "[port]"
|
|
18818
|
-
},
|
|
18819
|
-
host: {
|
|
18820
|
-
description: "Specify which IP addresses the server should listen on. Set this to 0.0.0.0 or true to listen on all addresses, including LAN and public addresses",
|
|
18821
|
-
argument: "[host]"
|
|
18822
|
-
},
|
|
18823
|
-
strictPort: {
|
|
18824
|
-
description: "Set to true to exit if port is already in use, instead of automatically trying the next available port"
|
|
18825
|
-
},
|
|
18826
|
-
middlewareMode: null
|
|
18250
|
+
var cliApi = /*#__PURE__*/Object.freeze({
|
|
18251
|
+
__proto__: null,
|
|
18252
|
+
startVitest: startVitest
|
|
18827
18253
|
});
|
|
18828
|
-
const poolThreadsCommands = {
|
|
18829
|
-
isolate: {
|
|
18830
|
-
description: "Isolate tests in threads pool (default: true)"
|
|
18831
|
-
},
|
|
18832
|
-
singleThread: {
|
|
18833
|
-
description: "Run tests inside a single thread (default: false)"
|
|
18834
|
-
},
|
|
18835
|
-
maxThreads: {
|
|
18836
|
-
description: "Maximum number of threads to run tests in",
|
|
18837
|
-
argument: "<workers>"
|
|
18838
|
-
},
|
|
18839
|
-
minThreads: {
|
|
18840
|
-
description: "Minimum number of threads to run tests in",
|
|
18841
|
-
argument: "<workers>"
|
|
18842
|
-
},
|
|
18843
|
-
useAtomics: {
|
|
18844
|
-
description: "Use Atomics to synchronize threads. This can improve performance in some cases, but might cause segfault in older Node versions (default: false)"
|
|
18845
|
-
},
|
|
18846
|
-
execArgv: null
|
|
18847
|
-
};
|
|
18848
|
-
const poolForksCommands = {
|
|
18849
|
-
isolate: {
|
|
18850
|
-
description: "Isolate tests in threads pool (default: true)"
|
|
18851
|
-
},
|
|
18852
|
-
singleFork: {
|
|
18853
|
-
description: "Run tests inside a single child_process (default: false)"
|
|
18854
|
-
},
|
|
18855
|
-
maxForks: {
|
|
18856
|
-
description: "Maximum number of processes to run tests in",
|
|
18857
|
-
argument: "<workers>"
|
|
18858
|
-
},
|
|
18859
|
-
minForks: {
|
|
18860
|
-
description: "Minimum number of processes to run tests in",
|
|
18861
|
-
argument: "<workers>"
|
|
18862
|
-
},
|
|
18863
|
-
execArgv: null
|
|
18864
|
-
};
|
|
18865
|
-
function watermarkTransform(value) {
|
|
18866
|
-
if (typeof value === "string")
|
|
18867
|
-
return value.split(",").map(Number);
|
|
18868
|
-
return value;
|
|
18869
|
-
}
|
|
18870
|
-
function transformNestedBoolean(value) {
|
|
18871
|
-
if (typeof value === "boolean")
|
|
18872
|
-
return { enabled: value };
|
|
18873
|
-
return value;
|
|
18874
|
-
}
|
|
18875
|
-
const cliOptionsConfig = {
|
|
18876
|
-
root: {
|
|
18877
|
-
description: "Root path",
|
|
18878
|
-
shorthand: "r",
|
|
18879
|
-
argument: "<path>",
|
|
18880
|
-
normalize: true
|
|
18881
|
-
},
|
|
18882
|
-
config: {
|
|
18883
|
-
shorthand: "c",
|
|
18884
|
-
description: "Path to config file",
|
|
18885
|
-
argument: "<path>",
|
|
18886
|
-
normalize: true
|
|
18887
|
-
},
|
|
18888
|
-
update: {
|
|
18889
|
-
shorthand: "u",
|
|
18890
|
-
description: "Update snapshot"
|
|
18891
|
-
},
|
|
18892
|
-
watch: {
|
|
18893
|
-
shorthand: "w",
|
|
18894
|
-
description: "Enable watch mode"
|
|
18895
|
-
},
|
|
18896
|
-
testNamePattern: {
|
|
18897
|
-
description: "Run tests with full names matching the specified regexp pattern",
|
|
18898
|
-
argument: "<pattern>",
|
|
18899
|
-
shorthand: "t"
|
|
18900
|
-
},
|
|
18901
|
-
dir: {
|
|
18902
|
-
description: "Base directory to scan for the test files",
|
|
18903
|
-
argument: "<path>",
|
|
18904
|
-
normalize: true
|
|
18905
|
-
},
|
|
18906
|
-
ui: {
|
|
18907
|
-
description: "Enable UI"
|
|
18908
|
-
},
|
|
18909
|
-
open: {
|
|
18910
|
-
description: "Open UI automatically (default: !process.env.CI)"
|
|
18911
|
-
},
|
|
18912
|
-
api: {
|
|
18913
|
-
argument: "[port]",
|
|
18914
|
-
description: `Specify server port. Note if the port is already being used, Vite will automatically try the next available port so this may not be the actual port the server ends up listening on. If true will be set to ${defaultPort}`,
|
|
18915
|
-
subcommands: apiConfig(defaultPort)
|
|
18916
|
-
},
|
|
18917
|
-
silent: {
|
|
18918
|
-
description: "Silent console output from tests"
|
|
18919
|
-
},
|
|
18920
|
-
hideSkippedTests: {
|
|
18921
|
-
description: "Hide logs for skipped tests"
|
|
18922
|
-
},
|
|
18923
|
-
reporters: {
|
|
18924
|
-
alias: "reporter",
|
|
18925
|
-
description: "Specify reporters",
|
|
18926
|
-
argument: "<name>",
|
|
18927
|
-
subcommands: null,
|
|
18928
|
-
// don't support custom objects
|
|
18929
|
-
array: true
|
|
18930
|
-
},
|
|
18931
|
-
outputFile: {
|
|
18932
|
-
argument: "<filename/-s>",
|
|
18933
|
-
description: "Write test results to a file when supporter reporter is also specified, use cac's dot notation for individual outputs of multiple reporters (example: --outputFile.tap=./tap.txt)",
|
|
18934
|
-
subcommands: null
|
|
18935
|
-
},
|
|
18936
|
-
coverage: {
|
|
18937
|
-
description: "Enable coverage report",
|
|
18938
|
-
argument: "",
|
|
18939
|
-
// empty string means boolean
|
|
18940
|
-
transform: transformNestedBoolean,
|
|
18941
|
-
subcommands: {
|
|
18942
|
-
all: {
|
|
18943
|
-
description: "Whether to include all files, including the untested ones into report",
|
|
18944
|
-
default: true
|
|
18945
|
-
},
|
|
18946
|
-
provider: {
|
|
18947
|
-
description: 'Select the tool for coverage collection, available values are: "v8", "istanbul" and "custom"',
|
|
18948
|
-
argument: "<name>"
|
|
18949
|
-
},
|
|
18950
|
-
enabled: {
|
|
18951
|
-
description: "Enables coverage collection. Can be overridden using the --coverage CLI option (default: false)"
|
|
18952
|
-
},
|
|
18953
|
-
include: {
|
|
18954
|
-
description: "Files included in coverage as glob patterns. May be specified more than once when using multiple patterns (default: **)",
|
|
18955
|
-
argument: "<pattern>",
|
|
18956
|
-
array: true
|
|
18957
|
-
},
|
|
18958
|
-
exclude: {
|
|
18959
|
-
description: "Files to be excluded in coverage. May be specified more than once when using multiple extensions (default: Visit https://vitest.dev/config/#coverage-exclude)",
|
|
18960
|
-
argument: "<pattern>",
|
|
18961
|
-
array: true
|
|
18962
|
-
},
|
|
18963
|
-
extension: {
|
|
18964
|
-
description: 'Extension to be included in coverage. May be specified more than once when using multiple extensions (default: [".js", ".cjs", ".mjs", ".ts", ".mts", ".cts", ".tsx", ".jsx", ".vue", ".svelte"])',
|
|
18965
|
-
argument: "<extension>",
|
|
18966
|
-
array: true
|
|
18967
|
-
},
|
|
18968
|
-
clean: {
|
|
18969
|
-
description: "Clean coverage results before running tests (default: true)"
|
|
18970
|
-
},
|
|
18971
|
-
cleanOnRerun: {
|
|
18972
|
-
description: "Clean coverage report on watch rerun (default: true)"
|
|
18973
|
-
},
|
|
18974
|
-
reportsDirectory: {
|
|
18975
|
-
description: "Directory to write coverage report to (default: ./coverage)",
|
|
18976
|
-
argument: "<path>",
|
|
18977
|
-
normalize: true
|
|
18978
|
-
},
|
|
18979
|
-
reporter: {
|
|
18980
|
-
description: 'Coverage reporters to use. Visit https://vitest.dev/config/#coverage-reporter for more information (default: ["text", "html", "clover", "json"])',
|
|
18981
|
-
argument: "<name>",
|
|
18982
|
-
subcommands: null,
|
|
18983
|
-
// don't support custom objects
|
|
18984
|
-
array: true
|
|
18985
|
-
},
|
|
18986
|
-
reportOnFailure: {
|
|
18987
|
-
description: "Generate coverage report even when tests fail (default: false)"
|
|
18988
|
-
},
|
|
18989
|
-
allowExternal: {
|
|
18990
|
-
description: "Collect coverage of files outside the project root (default: false)"
|
|
18991
|
-
},
|
|
18992
|
-
skipFull: {
|
|
18993
|
-
description: "Do not show files with 100% statement, branch, and function coverage (default: false)"
|
|
18994
|
-
},
|
|
18995
|
-
thresholds: {
|
|
18996
|
-
description: null,
|
|
18997
|
-
argument: "",
|
|
18998
|
-
// no displayed
|
|
18999
|
-
subcommands: {
|
|
19000
|
-
perFile: {
|
|
19001
|
-
description: "Check thresholds per file. See --coverage.thresholds.lines, --coverage.thresholds.functions, --coverage.thresholds.branches and --coverage.thresholds.statements for the actual thresholds (default: false)"
|
|
19002
|
-
},
|
|
19003
|
-
autoUpdate: {
|
|
19004
|
-
description: 'Update threshold values: "lines", "functions", "branches" and "statements" to configuration file when current coverage is above the configured thresholds (default: false)'
|
|
19005
|
-
},
|
|
19006
|
-
lines: {
|
|
19007
|
-
description: "Threshold for lines. Visit https://github.com/istanbuljs/nyc#coverage-thresholds for more information. This option is not available for custom providers",
|
|
19008
|
-
argument: "<number>"
|
|
19009
|
-
},
|
|
19010
|
-
functions: {
|
|
19011
|
-
description: "Threshold for functions. Visit https://github.com/istanbuljs/nyc#coverage-thresholds for more information. This option is not available for custom providers",
|
|
19012
|
-
argument: "<number>"
|
|
19013
|
-
},
|
|
19014
|
-
branches: {
|
|
19015
|
-
description: "Threshold for branches. Visit https://github.com/istanbuljs/nyc#coverage-thresholds for more information. This option is not available for custom providers",
|
|
19016
|
-
argument: "<number>"
|
|
19017
|
-
},
|
|
19018
|
-
statements: {
|
|
19019
|
-
description: "Threshold for statements. Visit https://github.com/istanbuljs/nyc#coverage-thresholds for more information. This option is not available for custom providers",
|
|
19020
|
-
argument: "<number>"
|
|
19021
|
-
},
|
|
19022
|
-
100: {
|
|
19023
|
-
description: "Shortcut to set all coverage thresholds to 100 (default: false)"
|
|
19024
|
-
}
|
|
19025
|
-
}
|
|
19026
|
-
},
|
|
19027
|
-
ignoreClassMethods: {
|
|
19028
|
-
description: "Array of class method names to ignore for coverage. Visit https://github.com/istanbuljs/nyc#ignoring-methods for more information. This option is only available for the istanbul providers (default: [])",
|
|
19029
|
-
argument: "<name>",
|
|
19030
|
-
array: true
|
|
19031
|
-
},
|
|
19032
|
-
processingConcurrency: {
|
|
19033
|
-
description: "Concurrency limit used when processing the coverage results. (default min between 20 and the number of CPUs)",
|
|
19034
|
-
argument: "<number>"
|
|
19035
|
-
},
|
|
19036
|
-
customProviderModule: {
|
|
19037
|
-
description: "Specifies the module name or path for the custom coverage provider module. Visit https://vitest.dev/guide/coverage.html#custom-coverage-provider for more information. This option is only available for custom providers",
|
|
19038
|
-
argument: "<path>",
|
|
19039
|
-
normalize: true
|
|
19040
|
-
},
|
|
19041
|
-
watermarks: {
|
|
19042
|
-
description: null,
|
|
19043
|
-
argument: "",
|
|
19044
|
-
// no displayed
|
|
19045
|
-
subcommands: {
|
|
19046
|
-
statements: {
|
|
19047
|
-
description: "High and low watermarks for statements in the format of <high>,<low>",
|
|
19048
|
-
argument: "<watermarks>",
|
|
19049
|
-
transform: watermarkTransform
|
|
19050
|
-
},
|
|
19051
|
-
lines: {
|
|
19052
|
-
description: "High and low watermarks for lines in the format of <high>,<low>",
|
|
19053
|
-
argument: "<watermarks>",
|
|
19054
|
-
transform: watermarkTransform
|
|
19055
|
-
},
|
|
19056
|
-
branches: {
|
|
19057
|
-
description: "High and low watermarks for branches in the format of <high>,<low>",
|
|
19058
|
-
argument: "<watermarks>",
|
|
19059
|
-
transform: watermarkTransform
|
|
19060
|
-
},
|
|
19061
|
-
functions: {
|
|
19062
|
-
description: "High and low watermarks for functions in the format of <high>,<low>",
|
|
19063
|
-
argument: "<watermarks>",
|
|
19064
|
-
transform: watermarkTransform
|
|
19065
|
-
}
|
|
19066
|
-
}
|
|
19067
|
-
}
|
|
19068
|
-
}
|
|
19069
|
-
},
|
|
19070
|
-
mode: {
|
|
19071
|
-
description: "Override Vite mode (default: test or benchmark)",
|
|
19072
|
-
argument: "<name>"
|
|
19073
|
-
},
|
|
19074
|
-
workspace: {
|
|
19075
|
-
description: "Path to a workspace configuration file",
|
|
19076
|
-
argument: "<path>",
|
|
19077
|
-
normalize: true
|
|
19078
|
-
},
|
|
19079
|
-
isolate: {
|
|
19080
|
-
description: "Run every test file in isolation. To disable isolation, use --no-isolate (default: true)"
|
|
19081
|
-
},
|
|
19082
|
-
globals: {
|
|
19083
|
-
description: "Inject apis globally"
|
|
19084
|
-
},
|
|
19085
|
-
dom: {
|
|
19086
|
-
description: "Mock browser API with happy-dom"
|
|
19087
|
-
},
|
|
19088
|
-
browser: {
|
|
19089
|
-
description: "Run tests in the browser. Equivalent to --browser.enabled (default: false)",
|
|
19090
|
-
argument: "<name>",
|
|
19091
|
-
transform(browser) {
|
|
19092
|
-
if (typeof browser === "boolean")
|
|
19093
|
-
return { enabled: browser };
|
|
19094
|
-
if (browser === "true" || browser === "false")
|
|
19095
|
-
return { enabled: browser !== "false" };
|
|
19096
|
-
if (typeof browser === "string")
|
|
19097
|
-
return { enabled: true, name: browser };
|
|
19098
|
-
return browser;
|
|
19099
|
-
},
|
|
19100
|
-
subcommands: {
|
|
19101
|
-
enabled: {
|
|
19102
|
-
description: "Run tests in the browser. Equivalent to --browser.enabled (default: false)"
|
|
19103
|
-
},
|
|
19104
|
-
name: {
|
|
19105
|
-
description: "Run all tests in a specific browser. Some browsers are only available for specific providers (see --browser.provider). Visit https://vitest.dev/config/#browser-name for more information",
|
|
19106
|
-
argument: "<name>"
|
|
19107
|
-
},
|
|
19108
|
-
headless: {
|
|
19109
|
-
description: "Run the browser in headless mode (i.e. without opening the GUI (Graphical User Interface)). If you are running Vitest in CI, it will be enabled by default (default: process.env.CI)"
|
|
19110
|
-
},
|
|
19111
|
-
api: {
|
|
19112
|
-
description: "Specify options for the browser API server. Does not affect the --api option",
|
|
19113
|
-
argument: "[port]",
|
|
19114
|
-
subcommands: apiConfig(defaultBrowserPort)
|
|
19115
|
-
},
|
|
19116
|
-
provider: {
|
|
19117
|
-
description: 'Provider used to run browser tests. Some browsers are only available for specific providers. Can be "webdriverio", "playwright", or the path to a custom provider. Visit https://vitest.dev/config/#browser-provider for more information (default: "webdriverio")',
|
|
19118
|
-
argument: "<name>",
|
|
19119
|
-
subcommands: null
|
|
19120
|
-
// don't support custom objects
|
|
19121
|
-
},
|
|
19122
|
-
providerOptions: {
|
|
19123
|
-
description: "Options that are passed down to a browser provider. Visit https://vitest.dev/config/#browser-provideroptions-1-0-0 for more information",
|
|
19124
|
-
argument: "<options>",
|
|
19125
|
-
subcommands: null
|
|
19126
|
-
// don't support custom objects
|
|
19127
|
-
},
|
|
19128
|
-
slowHijackESM: {
|
|
19129
|
-
description: "Let Vitest use its own module resolution on the browser to enable APIs such as vi.mock and vi.spyOn. Visit https://vitest.dev/config/#browser-slowhijackesm for more information (default: false)"
|
|
19130
|
-
},
|
|
19131
|
-
isolate: {
|
|
19132
|
-
description: "Run every browser test file in isolation. To disable isolation, use --browser.isolate=false (default: true)"
|
|
19133
|
-
},
|
|
19134
|
-
fileParallelism: {
|
|
19135
|
-
description: "Should all test files run in parallel. Use --browser.file-parallelism=false to disable (default: same as --file-parallelism)"
|
|
19136
|
-
}
|
|
19137
|
-
}
|
|
19138
|
-
},
|
|
19139
|
-
pool: {
|
|
19140
|
-
description: "Specify pool, if not running in the browser (default: threads)",
|
|
19141
|
-
argument: "<pool>",
|
|
19142
|
-
subcommands: null
|
|
19143
|
-
// don't support custom objects
|
|
19144
|
-
},
|
|
19145
|
-
poolOptions: {
|
|
19146
|
-
description: "Specify pool options",
|
|
19147
|
-
argument: "<options>",
|
|
19148
|
-
// we use casting here because TypeScript (for some reason) makes this into CLIOption<unknown>
|
|
19149
|
-
// even when using casting, these types fail if the new option is added which is good
|
|
19150
|
-
subcommands: {
|
|
19151
|
-
threads: {
|
|
19152
|
-
description: "Specify threads pool options",
|
|
19153
|
-
argument: "<options>",
|
|
19154
|
-
subcommands: poolThreadsCommands
|
|
19155
|
-
},
|
|
19156
|
-
vmThreads: {
|
|
19157
|
-
description: "Specify VM threads pool options",
|
|
19158
|
-
argument: "<options>",
|
|
19159
|
-
subcommands: {
|
|
19160
|
-
...poolThreadsCommands,
|
|
19161
|
-
memoryLimit: {
|
|
19162
|
-
description: "Memory limit for VM threads pool. If you see memory leaks, try to tinker this value.",
|
|
19163
|
-
argument: "<limit>"
|
|
19164
|
-
}
|
|
19165
|
-
}
|
|
19166
|
-
},
|
|
19167
|
-
forks: {
|
|
19168
|
-
description: "Specify forks pool options",
|
|
19169
|
-
argument: "<options>",
|
|
19170
|
-
subcommands: poolForksCommands
|
|
19171
|
-
},
|
|
19172
|
-
vmForks: {
|
|
19173
|
-
description: "Specify VM forks pool options",
|
|
19174
|
-
argument: "<options>",
|
|
19175
|
-
subcommands: {
|
|
19176
|
-
...poolForksCommands,
|
|
19177
|
-
memoryLimit: {
|
|
19178
|
-
description: "Memory limit for VM forks pool. If you see memory leaks, try to tinker this value.",
|
|
19179
|
-
argument: "<limit>"
|
|
19180
|
-
}
|
|
19181
|
-
}
|
|
19182
|
-
}
|
|
19183
|
-
}
|
|
19184
|
-
},
|
|
19185
|
-
fileParallelism: {
|
|
19186
|
-
description: "Should all test files run in parallel. Use --no-file-parallelism to disable (default: true)"
|
|
19187
|
-
},
|
|
19188
|
-
maxWorkers: {
|
|
19189
|
-
description: "Maximum number of workers to run tests in",
|
|
19190
|
-
argument: "<workers>"
|
|
19191
|
-
},
|
|
19192
|
-
minWorkers: {
|
|
19193
|
-
description: "Minimum number of workers to run tests in",
|
|
19194
|
-
argument: "<workers>"
|
|
19195
|
-
},
|
|
19196
|
-
environment: {
|
|
19197
|
-
description: "Specify runner environment, if not running in the browser (default: node)",
|
|
19198
|
-
argument: "<name>",
|
|
19199
|
-
subcommands: null
|
|
19200
|
-
// don't support custom objects
|
|
19201
|
-
},
|
|
19202
|
-
passWithNoTests: {
|
|
19203
|
-
description: "Pass when no tests are found"
|
|
19204
|
-
},
|
|
19205
|
-
logHeapUsage: {
|
|
19206
|
-
description: "Show the size of heap for each test when running in node"
|
|
19207
|
-
},
|
|
19208
|
-
allowOnly: {
|
|
19209
|
-
description: "Allow tests and suites that are marked as only (default: !process.env.CI)"
|
|
19210
|
-
},
|
|
19211
|
-
dangerouslyIgnoreUnhandledErrors: {
|
|
19212
|
-
description: "Ignore any unhandled errors that occur"
|
|
19213
|
-
},
|
|
19214
|
-
shard: {
|
|
19215
|
-
description: "Test suite shard to execute in a format of <index>/<count>",
|
|
19216
|
-
argument: "<shards>"
|
|
19217
|
-
},
|
|
19218
|
-
changed: {
|
|
19219
|
-
description: "Run tests that are affected by the changed files (default: false)",
|
|
19220
|
-
argument: "[since]"
|
|
19221
|
-
},
|
|
19222
|
-
sequence: {
|
|
19223
|
-
description: "Options for how tests should be sorted",
|
|
19224
|
-
argument: "<options>",
|
|
19225
|
-
subcommands: {
|
|
19226
|
-
shuffle: {
|
|
19227
|
-
description: "Run files and tests in a random order. Enabling this option will impact Vitest's cache and have a performance impact. May be useful to find tests that accidentally depend on another run previously (default: false)",
|
|
19228
|
-
argument: "",
|
|
19229
|
-
subcommands: {
|
|
19230
|
-
files: {
|
|
19231
|
-
description: "Run files in a random order. Long running tests will not start earlier if you enable this option. (default: false)"
|
|
19232
|
-
},
|
|
19233
|
-
tests: {
|
|
19234
|
-
description: "Run tests in a random oder (default: false)"
|
|
19235
|
-
}
|
|
19236
|
-
}
|
|
19237
|
-
},
|
|
19238
|
-
concurrent: {
|
|
19239
|
-
description: "Make tests run in parallel (default: false)"
|
|
19240
|
-
},
|
|
19241
|
-
seed: {
|
|
19242
|
-
description: "Set the randomization seed. This option will have no effect if --sequence.shuffle is falsy. Visit https://en.wikipedia.org/wiki/Random_seed for more information",
|
|
19243
|
-
argument: "<seed>"
|
|
19244
|
-
},
|
|
19245
|
-
hooks: {
|
|
19246
|
-
description: 'Changes the order in which hooks are executed. Accepted values are: "stack", "list" and "parallel". Visit https://vitest.dev/config/#sequence-hooks for more information (default: "parallel")',
|
|
19247
|
-
argument: "<order>"
|
|
19248
|
-
},
|
|
19249
|
-
setupFiles: {
|
|
19250
|
-
description: 'Changes the order in which setup files are executed. Accepted values are: "list" and "parallel". If set to "list", will run setup files in the order they are defined. If set to "parallel", will run setup files in parallel (default: "parallel")',
|
|
19251
|
-
argument: "<order>"
|
|
19252
|
-
}
|
|
19253
|
-
}
|
|
19254
|
-
},
|
|
19255
|
-
inspect: {
|
|
19256
|
-
description: "Enable Node.js inspector"
|
|
19257
|
-
},
|
|
19258
|
-
inspectBrk: {
|
|
19259
|
-
description: "Enable Node.js inspector with break"
|
|
19260
|
-
},
|
|
19261
|
-
testTimeout: {
|
|
19262
|
-
description: "Default timeout of a test in milliseconds (default: 5000)",
|
|
19263
|
-
argument: "<timeout>"
|
|
19264
|
-
},
|
|
19265
|
-
hookTimeout: {
|
|
19266
|
-
description: "Default hook timeout in milliseconds (default: 10000)",
|
|
19267
|
-
argument: "<timeout>"
|
|
19268
|
-
},
|
|
19269
|
-
bail: {
|
|
19270
|
-
description: "Stop test execution when given number of tests have failed (default: 0)",
|
|
19271
|
-
argument: "<number>"
|
|
19272
|
-
},
|
|
19273
|
-
retry: {
|
|
19274
|
-
description: "Retry the test specific number of times if it fails (default: 0)",
|
|
19275
|
-
argument: "<times>"
|
|
19276
|
-
},
|
|
19277
|
-
diff: {
|
|
19278
|
-
description: "Path to a diff config that will be used to generate diff interface",
|
|
19279
|
-
argument: "<path>",
|
|
19280
|
-
normalize: true
|
|
19281
|
-
},
|
|
19282
|
-
exclude: {
|
|
19283
|
-
description: "Additional file globs to be excluded from test",
|
|
19284
|
-
argument: "<glob>"
|
|
19285
|
-
},
|
|
19286
|
-
expandSnapshotDiff: {
|
|
19287
|
-
description: "Show full diff when snapshot fails"
|
|
19288
|
-
},
|
|
19289
|
-
disableConsoleIntercept: {
|
|
19290
|
-
description: "Disable automatic interception of console logging (default: false)"
|
|
19291
|
-
},
|
|
19292
|
-
typecheck: {
|
|
19293
|
-
description: "Enable typechecking alongside tests (default: false)",
|
|
19294
|
-
argument: "",
|
|
19295
|
-
// allow boolean
|
|
19296
|
-
transform: transformNestedBoolean,
|
|
19297
|
-
subcommands: {
|
|
19298
|
-
enabled: {
|
|
19299
|
-
description: "Enable typechecking alongside tests (default: false)"
|
|
19300
|
-
},
|
|
19301
|
-
only: {
|
|
19302
|
-
description: "Run only typecheck tests. This automatically enables typecheck (default: false)"
|
|
19303
|
-
},
|
|
19304
|
-
checker: {
|
|
19305
|
-
description: 'Specify the typechecker to use. Available values are: "tcs" and "vue-tsc" and a path to an executable (default: "tsc")',
|
|
19306
|
-
argument: "<name>",
|
|
19307
|
-
subcommands: null
|
|
19308
|
-
},
|
|
19309
|
-
allowJs: {
|
|
19310
|
-
description: "Allow JavaScript files to be typechecked. By default takes the value from tsconfig.json"
|
|
19311
|
-
},
|
|
19312
|
-
ignoreSourceErrors: {
|
|
19313
|
-
description: "Ignore type errors from source files"
|
|
19314
|
-
},
|
|
19315
|
-
tsconfig: {
|
|
19316
|
-
description: "Path to a custom tsconfig file",
|
|
19317
|
-
argument: "<path>",
|
|
19318
|
-
normalize: true
|
|
19319
|
-
},
|
|
19320
|
-
include: null,
|
|
19321
|
-
exclude: null
|
|
19322
|
-
}
|
|
19323
|
-
},
|
|
19324
|
-
project: {
|
|
19325
|
-
description: "The name of the project to run if you are using Vitest workspace feature. This can be repeated for multiple projects: --project=1 --project=2. You can also filter projects using wildcards like --project=packages*",
|
|
19326
|
-
argument: "<name>",
|
|
19327
|
-
array: true
|
|
19328
|
-
},
|
|
19329
|
-
slowTestThreshold: {
|
|
19330
|
-
description: "Threshold in milliseconds for a test to be considered slow (default: 300)",
|
|
19331
|
-
argument: "<threshold>"
|
|
19332
|
-
},
|
|
19333
|
-
teardownTimeout: {
|
|
19334
|
-
description: "Default timeout of a teardown function in milliseconds (default: 10000)",
|
|
19335
|
-
argument: "<timeout>"
|
|
19336
|
-
},
|
|
19337
|
-
cache: {
|
|
19338
|
-
description: "Enable cache",
|
|
19339
|
-
argument: "",
|
|
19340
|
-
// allow only boolean
|
|
19341
|
-
subcommands: {
|
|
19342
|
-
dir: null
|
|
19343
|
-
},
|
|
19344
|
-
default: true,
|
|
19345
|
-
// cache can only be "false" or an object
|
|
19346
|
-
transform(cache) {
|
|
19347
|
-
if (typeof cache !== "boolean" && cache)
|
|
19348
|
-
throw new Error("--cache.dir is deprecated");
|
|
19349
|
-
if (cache)
|
|
19350
|
-
return {};
|
|
19351
|
-
return cache;
|
|
19352
|
-
}
|
|
19353
|
-
},
|
|
19354
|
-
maxConcurrency: {
|
|
19355
|
-
description: "Maximum number of concurrent tests in a suite (default: 5)",
|
|
19356
|
-
argument: "<number>"
|
|
19357
|
-
},
|
|
19358
|
-
// CLI only options
|
|
19359
|
-
run: {
|
|
19360
|
-
description: "Disable watch mode"
|
|
19361
|
-
},
|
|
19362
|
-
segfaultRetry: {
|
|
19363
|
-
description: "Retry the test suite if it crashes due to a segfault (default: true)",
|
|
19364
|
-
argument: "<times>",
|
|
19365
|
-
default: 0
|
|
19366
|
-
},
|
|
19367
|
-
color: {
|
|
19368
|
-
description: "Removes colors from the console output",
|
|
19369
|
-
alias: "no-color"
|
|
19370
|
-
},
|
|
19371
|
-
clearScreen: {
|
|
19372
|
-
description: "Clear terminal screen when re-running tests during watch mode (default: true)"
|
|
19373
|
-
},
|
|
19374
|
-
// disable CLI options
|
|
19375
|
-
cliExclude: null,
|
|
19376
|
-
server: null,
|
|
19377
|
-
setupFiles: null,
|
|
19378
|
-
globalSetup: null,
|
|
19379
|
-
snapshotFormat: null,
|
|
19380
|
-
snapshotSerializers: null,
|
|
19381
|
-
includeSource: null,
|
|
19382
|
-
watchExclude: null,
|
|
19383
|
-
alias: null,
|
|
19384
|
-
env: null,
|
|
19385
|
-
environmentMatchGlobs: null,
|
|
19386
|
-
environmentOptions: null,
|
|
19387
|
-
unstubEnvs: null,
|
|
19388
|
-
related: null,
|
|
19389
|
-
restoreMocks: null,
|
|
19390
|
-
runner: null,
|
|
19391
|
-
mockReset: null,
|
|
19392
|
-
forceRerunTriggers: null,
|
|
19393
|
-
unstubGlobals: null,
|
|
19394
|
-
uiBase: null,
|
|
19395
|
-
benchmark: null,
|
|
19396
|
-
include: null,
|
|
19397
|
-
testTransformMode: null,
|
|
19398
|
-
fakeTimers: null,
|
|
19399
|
-
chaiConfig: null,
|
|
19400
|
-
clearMocks: null,
|
|
19401
|
-
css: null,
|
|
19402
|
-
poolMatchGlobs: null,
|
|
19403
|
-
deps: null,
|
|
19404
|
-
name: null,
|
|
19405
|
-
includeTaskLocation: null
|
|
19406
|
-
};
|
|
19407
|
-
|
|
19408
|
-
function addCommand(cli, name, option) {
|
|
19409
|
-
const commandName = option.alias || name;
|
|
19410
|
-
let command = option.shorthand ? `-${option.shorthand}, --${commandName}` : `--${commandName}`;
|
|
19411
|
-
if ("argument" in option)
|
|
19412
|
-
command += ` ${option.argument}`;
|
|
19413
|
-
function transform(value) {
|
|
19414
|
-
if (!option.array && Array.isArray(value)) {
|
|
19415
|
-
const received = value.map((s) => typeof s === "string" ? `"${s}"` : s).join(", ");
|
|
19416
|
-
throw new Error(
|
|
19417
|
-
`Expected a single value for option "${command}", received [${received}]`
|
|
19418
|
-
);
|
|
19419
|
-
}
|
|
19420
|
-
if (option.transform)
|
|
19421
|
-
return option.transform(value);
|
|
19422
|
-
if (option.array)
|
|
19423
|
-
return toArray(value);
|
|
19424
|
-
if (option.normalize)
|
|
19425
|
-
return normalize(String(value));
|
|
19426
|
-
return value;
|
|
19427
|
-
}
|
|
19428
|
-
const hasSubcommands = "subcommands" in option && option.subcommands;
|
|
19429
|
-
if (option.description) {
|
|
19430
|
-
let description = option.description;
|
|
19431
|
-
if (hasSubcommands)
|
|
19432
|
-
description += `. Use '--help --${commandName}' for more info.`;
|
|
19433
|
-
cli.option(command, description, {
|
|
19434
|
-
type: transform
|
|
19435
|
-
});
|
|
19436
|
-
}
|
|
19437
|
-
if (hasSubcommands) {
|
|
19438
|
-
for (const commandName2 in option.subcommands) {
|
|
19439
|
-
const subcommand = option.subcommands[commandName2];
|
|
19440
|
-
if (subcommand)
|
|
19441
|
-
addCommand(cli, `${name}.${commandName2}`, subcommand);
|
|
19442
|
-
}
|
|
19443
|
-
}
|
|
19444
|
-
}
|
|
19445
|
-
function createCLI(options = {}) {
|
|
19446
|
-
const cli = cac("vitest");
|
|
19447
|
-
cli.version(version);
|
|
19448
|
-
for (const optionName in cliOptionsConfig) {
|
|
19449
|
-
const option = cliOptionsConfig[optionName];
|
|
19450
|
-
if (option)
|
|
19451
|
-
addCommand(cli, optionName, option);
|
|
19452
|
-
}
|
|
19453
|
-
cli.help((info) => {
|
|
19454
|
-
const helpSection = info.find((current) => {
|
|
19455
|
-
var _a;
|
|
19456
|
-
return (_a = current.title) == null ? void 0 : _a.startsWith("For more info, run any command");
|
|
19457
|
-
});
|
|
19458
|
-
if (helpSection)
|
|
19459
|
-
helpSection.body += "\n $ vitest --help --expand-help";
|
|
19460
|
-
const options2 = info.find((current) => current.title === "Options");
|
|
19461
|
-
if (typeof options2 !== "object")
|
|
19462
|
-
return info;
|
|
19463
|
-
const helpIndex = process.argv.findIndex((arg) => arg === "--help");
|
|
19464
|
-
const subcommands = process.argv.slice(helpIndex + 1);
|
|
19465
|
-
const defaultOutput = options2.body.split("\n").filter((line) => /^\s+--\S+\./.test(line) === false).join("\n");
|
|
19466
|
-
if (subcommands.length === 0) {
|
|
19467
|
-
options2.body = defaultOutput;
|
|
19468
|
-
return info;
|
|
19469
|
-
}
|
|
19470
|
-
if (subcommands.length === 1 && (subcommands[0] === "--expand-help" || subcommands[0] === "--expandHelp"))
|
|
19471
|
-
return info;
|
|
19472
|
-
const subcommandMarker = "$SUB_COMMAND_MARKER$";
|
|
19473
|
-
const banner = info.find((current) => /^vitest\/[0-9]+\.[0-9]+\.[0-9]+$/.test(current.body));
|
|
19474
|
-
function addBannerWarning(warning) {
|
|
19475
|
-
if (typeof (banner == null ? void 0 : banner.body) === "string") {
|
|
19476
|
-
if (banner == null ? void 0 : banner.body.includes(warning))
|
|
19477
|
-
return;
|
|
19478
|
-
banner.body = `${banner.body}
|
|
19479
|
-
WARN: ${warning}`;
|
|
19480
|
-
}
|
|
19481
|
-
}
|
|
19482
|
-
for (let i = 0; i < subcommands.length; i++) {
|
|
19483
|
-
const subcommand = subcommands[i];
|
|
19484
|
-
if (subcommand === "--expand-help" || subcommand === "--expandHelp") {
|
|
19485
|
-
addBannerWarning("--expand-help subcommand ignored because, when used with --help, it must be the only subcommand");
|
|
19486
|
-
continue;
|
|
19487
|
-
}
|
|
19488
|
-
if (subcommand.startsWith("--")) {
|
|
19489
|
-
options2.body = options2.body.split("\n").map((line) => line.trim().startsWith(subcommand) ? `${subcommandMarker}${line}` : line).join("\n");
|
|
19490
|
-
}
|
|
19491
|
-
}
|
|
19492
|
-
options2.body = options2.body.split("\n").map((line) => line.startsWith(subcommandMarker) ? line.split(subcommandMarker)[1] : "").filter((line) => line.length !== 0).join("\n");
|
|
19493
|
-
if (!options2.body) {
|
|
19494
|
-
addBannerWarning("no options were found for your subcommands so we printed the whole output");
|
|
19495
|
-
options2.body = defaultOutput;
|
|
19496
|
-
}
|
|
19497
|
-
return info;
|
|
19498
|
-
});
|
|
19499
|
-
cli.command("run [...filters]", void 0, options).action(run);
|
|
19500
|
-
cli.command("related [...filters]", void 0, options).action(runRelated);
|
|
19501
|
-
cli.command("watch [...filters]", void 0, options).action(watch);
|
|
19502
|
-
cli.command("dev [...filters]", void 0, options).action(watch);
|
|
19503
|
-
cli.command("bench [...filters]", void 0, options).action(benchmark);
|
|
19504
|
-
cli.command("typecheck [...filters]").action(() => {
|
|
19505
|
-
throw new Error(`Running typecheck via "typecheck" command is removed. Please use "--typecheck" to run your regular tests alongside typechecking, or "--typecheck.only" to run only typecheck tests.`);
|
|
19506
|
-
});
|
|
19507
|
-
cli.command("[...filters]", void 0, options).action((filters, options2) => start("test", filters, options2));
|
|
19508
|
-
return cli;
|
|
19509
|
-
}
|
|
19510
|
-
function parseCLI(argv, config = {}) {
|
|
19511
|
-
const arrayArgs = typeof argv === "string" ? argv.split(" ") : argv;
|
|
19512
|
-
if (arrayArgs[0] !== "vitest")
|
|
19513
|
-
throw new Error(`Expected "vitest" as the first argument, received "${arrayArgs[0]}"`);
|
|
19514
|
-
arrayArgs[0] = "/index.js";
|
|
19515
|
-
arrayArgs.unshift("node");
|
|
19516
|
-
let { args, options } = createCLI(config).parse(arrayArgs, {
|
|
19517
|
-
run: false
|
|
19518
|
-
});
|
|
19519
|
-
if (arrayArgs[2] === "watch" || arrayArgs[2] === "dev")
|
|
19520
|
-
options.watch = true;
|
|
19521
|
-
if (arrayArgs[2] === "run")
|
|
19522
|
-
options.run = true;
|
|
19523
|
-
if (arrayArgs[2] === "related") {
|
|
19524
|
-
options.related = args;
|
|
19525
|
-
options.passWithNoTests ?? (options.passWithNoTests = true);
|
|
19526
|
-
args = [];
|
|
19527
|
-
}
|
|
19528
|
-
return {
|
|
19529
|
-
filter: args,
|
|
19530
|
-
options
|
|
19531
|
-
};
|
|
19532
|
-
}
|
|
19533
|
-
async function runRelated(relatedFiles, argv) {
|
|
19534
|
-
argv.related = relatedFiles;
|
|
19535
|
-
argv.passWithNoTests ?? (argv.passWithNoTests = true);
|
|
19536
|
-
await start("test", [], argv);
|
|
19537
|
-
}
|
|
19538
|
-
async function watch(cliFilters, options) {
|
|
19539
|
-
options.watch = true;
|
|
19540
|
-
await start("test", cliFilters, options);
|
|
19541
|
-
}
|
|
19542
|
-
async function run(cliFilters, options) {
|
|
19543
|
-
options.run = true;
|
|
19544
|
-
await start("test", cliFilters, options);
|
|
19545
|
-
}
|
|
19546
|
-
async function benchmark(cliFilters, options) {
|
|
19547
|
-
console.warn(c.yellow("Benchmarking is an experimental feature.\nBreaking changes might not follow SemVer, please pin Vitest's version when using it."));
|
|
19548
|
-
await start("benchmark", cliFilters, options);
|
|
19549
|
-
}
|
|
19550
|
-
function normalizeCliOptions(argv) {
|
|
19551
|
-
if (argv.exclude) {
|
|
19552
|
-
argv.cliExclude = toArray(argv.exclude);
|
|
19553
|
-
delete argv.exclude;
|
|
19554
|
-
}
|
|
19555
|
-
return argv;
|
|
19556
|
-
}
|
|
19557
|
-
async function start(mode, cliFilters, options) {
|
|
19558
|
-
try {
|
|
19559
|
-
process.title = "node (vitest)";
|
|
19560
|
-
} catch {
|
|
19561
|
-
}
|
|
19562
|
-
try {
|
|
19563
|
-
const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(options));
|
|
19564
|
-
if (!(ctx == null ? void 0 : ctx.shouldKeepServer()))
|
|
19565
|
-
await (ctx == null ? void 0 : ctx.exit());
|
|
19566
|
-
return ctx;
|
|
19567
|
-
} catch (e) {
|
|
19568
|
-
console.error(`
|
|
19569
|
-
${c.red(divider(c.bold(c.inverse(" Unhandled Error "))))}`);
|
|
19570
|
-
console.error(e);
|
|
19571
|
-
console.error("\n\n");
|
|
19572
|
-
process.exit(1);
|
|
19573
|
-
}
|
|
19574
|
-
}
|
|
19575
18254
|
|
|
19576
|
-
export { VitestPlugin as V, createMethodsRPC as a, VitestPackageInstaller as b, createVitest as c,
|
|
18255
|
+
export { VitestPlugin as V, createMethodsRPC as a, VitestPackageInstaller as b, createVitest as c, cliApi as d, registerConsoleShortcuts as r, startVitest as s };
|