vitest 4.0.0-beta.11 → 4.0.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +4 -101
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +2 -2
- package/dist/chunks/{benchmark.LXhJ0F0X.js → benchmark.DHKMYAts.js} +1 -1
- package/dist/chunks/{browser.d.Dx7DO_Ce.d.ts → browser.d.D9YV3JvA.d.ts} +1 -1
- package/dist/chunks/{cac.elvK37c9.js → cac.BBtYKH7y.js} +16 -9
- package/dist/chunks/{cli-api.C7plPyhs.js → cli-api.CeakdBUN.js} +95 -148
- package/dist/chunks/{config.d.B_LthbQq.d.ts → config.d.DGazh2r6.d.ts} +3 -1
- package/dist/chunks/{console.CiTi59Jy.js → console.CTJL2nuH.js} +3 -5
- package/dist/chunks/{coverage.CG6Uhorw.js → coverage.DabP7UTQ.js} +69 -80
- package/dist/chunks/{creator.08Gi-vCA.js → creator.DfXDsUyL.js} +6 -8
- package/dist/chunks/{global.d.BK3X7FW1.d.ts → global.d.BcFPD2LN.d.ts} +0 -13
- package/dist/chunks/{globals.BjvYA-AD.js → globals.DC4ntO86.js} +5 -5
- package/dist/chunks/{index.DIWhzsUh.js → index.Bt-upxGS.js} +6 -12
- package/dist/chunks/{index.BwBttQPf.js → index.CHrBLuEH.js} +33 -38
- package/dist/chunks/{index.X0nbfr6-.js → index.Dc3xnDvT.js} +48 -289
- package/dist/chunks/{index.AZOjjqWP.js → index.Dnl38iQ_.js} +2 -2
- package/dist/chunks/{index.BhY64fF0.js → index.uLUz1RDt.js} +1 -1
- package/dist/chunks/{inspector.CvQD-Nie.js → inspector.Br76Q2Mb.js} +1 -4
- package/dist/chunks/{moduleRunner.d.BNa-CL9e.d.ts → moduleRunner.d.CeYc7nZ0.d.ts} +1 -1
- package/dist/chunks/{node.BsdMi6DV.js → node.BwAWWjHZ.js} +2 -3
- package/dist/chunks/{plugin.d.C5phQR6o.d.ts → plugin.d.COyglhiI.d.ts} +1 -1
- package/dist/chunks/{reporters.d.CVzhsTvK.d.ts → reporters.d.xGvTJYG3.d.ts} +41 -4
- package/dist/chunks/{resolveSnapshotEnvironment.DQVamkje.js → resolveSnapshotEnvironment.BsJpmVZR.js} +7 -8
- package/dist/chunks/{rpc.jKGRSXIH.js → rpc.cD77ENhU.js} +12 -13
- package/dist/chunks/{setup-common.NAWRuMRP.js → setup-common.BewgbkTd.js} +5 -5
- package/dist/chunks/{startModuleRunner.oAuCu1yL.js → startModuleRunner.DPBo3mme.js} +40 -48
- package/dist/chunks/{test.KC5tH8hC.js → test.CTuWuHYH.js} +5 -5
- package/dist/chunks/{typechecker.gXq-5P3n.js → typechecker.BfOQ86_a.js} +54 -77
- package/dist/chunks/{utils.DGKhod2J.js → utils.CG9h5ccR.js} +1 -4
- package/dist/chunks/{vi.CiJ0Laa6.js → vi.B2--mG9U.js} +35 -144
- package/dist/chunks/{worker.rPGLlbkW.js → worker.DVTUM2IW.js} +11 -15
- package/dist/chunks/{worker.d.B_Fd9M_w.d.ts → worker.d.buwuBpBt.d.ts} +1 -1
- package/dist/cli.js +3 -3
- package/dist/config.d.ts +6 -6
- package/dist/coverage.d.ts +5 -5
- package/dist/coverage.js +3 -3
- package/dist/environments.js +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +5 -5
- package/dist/module-evaluator.d.ts +3 -3
- package/dist/module-evaluator.js +10 -12
- package/dist/module-runner.js +2 -2
- package/dist/node.d.ts +8 -8
- package/dist/node.js +10 -10
- package/dist/reporters.d.ts +5 -5
- package/dist/reporters.js +3 -3
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +6 -6
- package/dist/snapshot.js +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker-base.js +30 -32
- package/dist/worker-vm.js +19 -30
- package/dist/workers/runVmTests.js +10 -10
- package/package.json +18 -19
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync, promises } from 'node:fs';
|
|
2
2
|
import { mkdir, writeFile, readdir, stat, readFile } from 'node:fs/promises';
|
|
3
3
|
import { resolve, dirname, isAbsolute, relative, basename, normalize } from 'pathe';
|
|
4
|
-
import { g as getOutputFile, h as hasFailedSnapshot, T as TypeCheckError } from './typechecker.
|
|
4
|
+
import { g as getOutputFile, h as hasFailedSnapshot, T as TypeCheckError } from './typechecker.BfOQ86_a.js';
|
|
5
5
|
import { performance as performance$1 } from 'node:perf_hooks';
|
|
6
6
|
import { getTestName, hasFailed, getTests, getSuites, getTasks, getFullName } from '@vitest/runner/utils';
|
|
7
7
|
import { slash, toArray, isPrimitive } from '@vitest/utils/helpers';
|
|
@@ -171,9 +171,9 @@ async function writeBlob(content, filename) {
|
|
|
171
171
|
}
|
|
172
172
|
async function readBlobs(currentVersion, blobsDirectory, projectsArray) {
|
|
173
173
|
// using process.cwd() because --merge-reports can only be used in CLI
|
|
174
|
-
const resolvedDir = resolve(process.cwd(), blobsDirectory),
|
|
175
|
-
const fullPath = resolve(resolvedDir, filename)
|
|
176
|
-
if (!
|
|
174
|
+
const resolvedDir = resolve(process.cwd(), blobsDirectory), promises = (await readdir(resolvedDir)).map(async (filename) => {
|
|
175
|
+
const fullPath = resolve(resolvedDir, filename);
|
|
176
|
+
if (!(await stat(fullPath)).isFile()) throw new TypeError(`vitest.mergeReports() expects all paths in "${blobsDirectory}" to be files generated by the blob reporter, but "${filename}" is not a file`);
|
|
177
177
|
const content = await readFile(fullPath, "utf-8"), [version, files, errors, moduleKeys, coverage, executionTime] = parse(content);
|
|
178
178
|
if (!version) throw new TypeError(`vitest.mergeReports() expects all paths in "${blobsDirectory}" to be files generated by the blob reporter, but "${filename}" is not a valid blob file`);
|
|
179
179
|
return {
|
|
@@ -456,8 +456,7 @@ class BaseReporter {
|
|
|
456
456
|
let suffix = c.dim("(") + state + c.dim(")") + this.getDurationPrefix(testModule.task);
|
|
457
457
|
const diagnostic = testModule.diagnostic();
|
|
458
458
|
if (diagnostic.heap != null) suffix += c.magenta(` ${Math.floor(diagnostic.heap / 1024 / 1024)} MB heap used`);
|
|
459
|
-
|
|
460
|
-
return ` ${title} ${testModule.task.name} ${suffix}`;
|
|
459
|
+
return ` ${this.getEntityPrefix(testModule)} ${testModule.task.name} ${suffix}`;
|
|
461
460
|
}
|
|
462
461
|
printTestSuite(testSuite) {
|
|
463
462
|
if (!this.renderSucceed) return;
|
|
@@ -479,12 +478,16 @@ class BaseReporter {
|
|
|
479
478
|
printAnnotations(test, console, padding = 0) {
|
|
480
479
|
const annotations = test.annotations();
|
|
481
480
|
if (!annotations.length) return;
|
|
482
|
-
const PADDING = " ".repeat(padding);
|
|
483
|
-
annotations.forEach((
|
|
481
|
+
const PADDING = " ".repeat(padding), groupedAnnotations = {};
|
|
482
|
+
for (const group in annotations.forEach((annotation) => {
|
|
483
|
+
const { location, type } = annotation;
|
|
484
|
+
let group;
|
|
484
485
|
if (location) {
|
|
485
486
|
const file = relative(test.project.config.root, location.file);
|
|
486
|
-
|
|
487
|
-
} else
|
|
487
|
+
group = `${c.gray(`${file}:${location.line}:${location.column}`)} ${c.bold(type)}`;
|
|
488
|
+
} else group = c.bold(type);
|
|
489
|
+
groupedAnnotations[group] ??= [], groupedAnnotations[group].push(annotation);
|
|
490
|
+
}), groupedAnnotations) this[console](`${PADDING}${c.blue(F_POINTER)} ${group}`), groupedAnnotations[group].forEach(({ message }) => {
|
|
488
491
|
this[console](`${PADDING} ${c.blue(F_DOWN_RIGHT)} ${message}`);
|
|
489
492
|
});
|
|
490
493
|
}
|
|
@@ -508,13 +511,10 @@ class BaseReporter {
|
|
|
508
511
|
}
|
|
509
512
|
getDurationPrefix(task) {
|
|
510
513
|
const duration = task.result?.duration && Math.round(task.result?.duration);
|
|
511
|
-
|
|
512
|
-
const color = duration > this.ctx.config.slowTestThreshold ? c.yellow : c.green;
|
|
513
|
-
return color(` ${duration}${c.dim("ms")}`);
|
|
514
|
+
return duration == null ? "" : (duration > this.ctx.config.slowTestThreshold ? c.yellow : c.green)(` ${duration}${c.dim("ms")}`);
|
|
514
515
|
}
|
|
515
516
|
onWatcherStart(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
516
|
-
|
|
517
|
-
if (failed) this.log(withLabel("red", "FAIL", "Tests failed. Watching for file changes..."));
|
|
517
|
+
if (errors.length > 0 || hasFailed(files)) this.log(withLabel("red", "FAIL", "Tests failed. Watching for file changes..."));
|
|
518
518
|
else if (this.ctx.isCancelling) this.log(withLabel("red", "CANCELLED", "Test run cancelled. Watching for file changes..."));
|
|
519
519
|
else this.log(withLabel("green", "PASS", "Waiting for file changes..."));
|
|
520
520
|
const hints = [c.dim("press ") + c.bold("h") + c.dim(" to show help")];
|
|
@@ -564,8 +564,8 @@ class BaseReporter {
|
|
|
564
564
|
shouldLog(log, taskState) {
|
|
565
565
|
if (this.ctx.config.silent === true || this.ctx.config.silent === "passed-only" && taskState !== "failed") return false;
|
|
566
566
|
if (this.ctx.config.onConsoleLog) {
|
|
567
|
-
const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : void 0, entity = task && this.ctx.state.getReportedEntity(task)
|
|
568
|
-
if (
|
|
567
|
+
const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : void 0, entity = task && this.ctx.state.getReportedEntity(task);
|
|
568
|
+
if (this.ctx.config.onConsoleLog(log.content, log.type, entity) === false) return false;
|
|
569
569
|
}
|
|
570
570
|
return true;
|
|
571
571
|
}
|
|
@@ -615,7 +615,7 @@ class BaseReporter {
|
|
|
615
615
|
if (errors.length) this.ctx.logger.printUnhandledErrors(errors), this.error();
|
|
616
616
|
}
|
|
617
617
|
reportBenchmarkSummary(files) {
|
|
618
|
-
const
|
|
618
|
+
const topBenches = getTests(files).filter((i) => i.result?.benchmark?.rank === 1);
|
|
619
619
|
this.log(`\n${withLabel("cyan", "BENCH", "Summary\n")}`);
|
|
620
620
|
for (const bench of topBenches) {
|
|
621
621
|
const group = bench.suite || bench.file;
|
|
@@ -893,11 +893,10 @@ class SummaryReporter {
|
|
|
893
893
|
else if (state === "failed") this.modules.failed++;
|
|
894
894
|
else if (module.task.mode === "todo" && state === "skipped") this.modules.todo++;
|
|
895
895
|
else if (state === "skipped") this.modules.skipped++;
|
|
896
|
-
const left = this.modules.total - this.modules.completed;
|
|
897
896
|
// Keep finished tests visible in summary for a while if there are more tests left.
|
|
898
897
|
// When a new test starts in onTestModuleQueued it will take this ones place.
|
|
899
898
|
// This reduces flickering by making summary more stable.
|
|
900
|
-
if (
|
|
899
|
+
if (this.modules.total - this.modules.completed > this.maxParallelTests) this.finishedModules.set(module.id, setTimeout(() => {
|
|
901
900
|
this.removeTestModule(module.id);
|
|
902
901
|
}, FINISHED_TEST_CLEANUP_TIME_MS).unref());
|
|
903
902
|
else
|
|
@@ -1122,12 +1121,12 @@ function capturePrintError(error, ctx, options) {
|
|
|
1122
1121
|
} }), console = new Console(writable), logger = {
|
|
1123
1122
|
error: console.error.bind(console),
|
|
1124
1123
|
highlight: ctx.logger.highlight.bind(ctx.logger)
|
|
1125
|
-
}
|
|
1126
|
-
showCodeFrame: false,
|
|
1127
|
-
...options
|
|
1128
|
-
});
|
|
1124
|
+
};
|
|
1129
1125
|
return {
|
|
1130
|
-
nearest:
|
|
1126
|
+
nearest: printError(error, ctx, logger, {
|
|
1127
|
+
showCodeFrame: false,
|
|
1128
|
+
...options
|
|
1129
|
+
})?.nearest,
|
|
1131
1130
|
output
|
|
1132
1131
|
};
|
|
1133
1132
|
}
|
|
@@ -1175,19 +1174,17 @@ function printErrorInner(error, project, options) {
|
|
|
1175
1174
|
const stacks = options.parseErrorStacktrace(e), nearest = error instanceof TypeCheckError ? error.stacks[0] : stacks.find((stack) => {
|
|
1176
1175
|
// we are checking that this module was processed by us at one point
|
|
1177
1176
|
try {
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
});
|
|
1182
|
-
return hasResult && existsSync(stack.file);
|
|
1177
|
+
return [...Object.values(project._vite?.environments || {}), ...Object.values(project.browser?.vite.environments || {})].some((environment) => {
|
|
1178
|
+
return [...environment.moduleGraph.getModulesByFile(stack.file)?.values() || []].some((module) => !!module.transformResult);
|
|
1179
|
+
}) && existsSync(stack.file);
|
|
1183
1180
|
} catch {
|
|
1184
1181
|
return false;
|
|
1185
1182
|
}
|
|
1186
1183
|
});
|
|
1187
1184
|
if (type) printErrorType(type, project.vitest);
|
|
1188
1185
|
if (printErrorMessage(e, logger), options.screenshotPaths?.length) {
|
|
1189
|
-
const
|
|
1190
|
-
if (logger.error(`\nFailure screenshot${length > 1 ? "s" : ""}:`), logger.error(
|
|
1186
|
+
const uniqueScreenshots = Array.from(new Set(options.screenshotPaths)), length = uniqueScreenshots.length;
|
|
1187
|
+
if (logger.error(`\nFailure screenshot${length > 1 ? "s" : ""}:`), logger.error(uniqueScreenshots.map((p) => ` - ${c.dim(relative(process.cwd(), p))}`).join("\n")), !e.diff) logger.error();
|
|
1191
1188
|
}
|
|
1192
1189
|
if (e.codeFrame) logger.error(`${e.codeFrame}\n`);
|
|
1193
1190
|
if ("__vitest_rollup_error__" in e) {
|
|
@@ -1426,7 +1423,7 @@ const BUILT_IN_TYPES = [
|
|
|
1426
1423
|
"warning"
|
|
1427
1424
|
];
|
|
1428
1425
|
function getTitle(type) {
|
|
1429
|
-
|
|
1426
|
+
if (!BUILT_IN_TYPES.includes(type)) return type;
|
|
1430
1427
|
}
|
|
1431
1428
|
function getType(type) {
|
|
1432
1429
|
return BUILT_IN_TYPES.includes(type) ? type : "notice";
|
|
@@ -1453,8 +1450,7 @@ function escapeProperty(s) {
|
|
|
1453
1450
|
class HangingProcessReporter {
|
|
1454
1451
|
whyRunning;
|
|
1455
1452
|
onInit() {
|
|
1456
|
-
|
|
1457
|
-
this.whyRunning = _require("why-is-node-running");
|
|
1453
|
+
this.whyRunning = createRequire(import.meta.url)("why-is-node-running");
|
|
1458
1454
|
}
|
|
1459
1455
|
onProcessTimeout() {
|
|
1460
1456
|
this.whyRunning?.();
|
|
@@ -1614,8 +1610,7 @@ class JUnitReporter {
|
|
|
1614
1610
|
this.reportFile = resolve(this.ctx.config.root, outputFile);
|
|
1615
1611
|
const outputDirectory = dirname(this.reportFile);
|
|
1616
1612
|
if (!existsSync(outputDirectory)) await promises.mkdir(outputDirectory, { recursive: true });
|
|
1617
|
-
|
|
1618
|
-
this.fileFd = fileFd, this.baseLog = async (text) => {
|
|
1613
|
+
this.fileFd = await promises.open(this.reportFile, "w+"), this.baseLog = async (text) => {
|
|
1619
1614
|
if (!this.fileFd) this.fileFd = await promises.open(this.reportFile, "w+");
|
|
1620
1615
|
await promises.writeFile(this.fileFd, `${text}\n`);
|
|
1621
1616
|
};
|
|
@@ -1778,7 +1773,7 @@ class TapReporter {
|
|
|
1778
1773
|
this.logger.log(`# ${type}: ${message}`);
|
|
1779
1774
|
}), this.logger.unindent();
|
|
1780
1775
|
if (task.result?.state === "fail" && task.result.errors) this.logger.indent(), task.result.errors.forEach((error) => {
|
|
1781
|
-
const
|
|
1776
|
+
const stack = (task.file.pool === "browser" ? project.browser?.parseErrorStacktrace(error) || [] : parseErrorStacktrace(error, { frameFilter: this.ctx.config.onStackTrace }))[0];
|
|
1782
1777
|
if (this.logger.log("---"), this.logger.log("error:"), this.logger.indent(), this.logErrorDetails(error), this.logger.unindent(), stack) this.logger.log(`at: ${yamlString(`${stack.file}:${stack.line}:${stack.column}`)}`);
|
|
1783
1778
|
if (error.showDiff) this.logger.log(`actual: ${yamlString(error.actual)}`), this.logger.log(`expected: ${yamlString(error.expected)}`);
|
|
1784
1779
|
}), this.logger.log("..."), this.logger.unindent();
|
|
@@ -1,301 +1,60 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { resolve, isAbsolute, dirname, join } from 'node:path';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import 'node:module';
|
|
4
|
+
import 'node:url';
|
|
5
5
|
import { g as getDefaultExportFromCjs } from './_commonjsHelpers.BFTU3MAI.js';
|
|
6
6
|
import require$$0 from 'readline';
|
|
7
7
|
import require$$0$1 from 'events';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
get: function () { return e[k]; }
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
return Object.freeze(n);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/*
|
|
25
|
-
How it works:
|
|
26
|
-
`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.
|
|
9
|
+
/**
|
|
10
|
+
* Resolve an absolute path from {@link root}, but only
|
|
11
|
+
* if {@link input} isn't already absolute.
|
|
12
|
+
*
|
|
13
|
+
* @param input The path to resolve.
|
|
14
|
+
* @param root The base path; default = process.cwd()
|
|
15
|
+
* @returns The resolved absolute path.
|
|
27
16
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
value;
|
|
31
|
-
next;
|
|
32
|
-
|
|
33
|
-
constructor(value) {
|
|
34
|
-
this.value = value;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
class Queue {
|
|
39
|
-
#head;
|
|
40
|
-
#tail;
|
|
41
|
-
#size;
|
|
42
|
-
|
|
43
|
-
constructor() {
|
|
44
|
-
this.clear();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
enqueue(value) {
|
|
48
|
-
const node = new Node(value);
|
|
49
|
-
|
|
50
|
-
if (this.#head) {
|
|
51
|
-
this.#tail.next = node;
|
|
52
|
-
this.#tail = node;
|
|
53
|
-
} else {
|
|
54
|
-
this.#head = node;
|
|
55
|
-
this.#tail = node;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
this.#size++;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
dequeue() {
|
|
62
|
-
const current = this.#head;
|
|
63
|
-
if (!current) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
this.#head = this.#head.next;
|
|
68
|
-
this.#size--;
|
|
69
|
-
return current.value;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
clear() {
|
|
73
|
-
this.#head = undefined;
|
|
74
|
-
this.#tail = undefined;
|
|
75
|
-
this.#size = 0;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
get size() {
|
|
79
|
-
return this.#size;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
* [Symbol.iterator]() {
|
|
83
|
-
let current = this.#head;
|
|
84
|
-
|
|
85
|
-
while (current) {
|
|
86
|
-
yield current.value;
|
|
87
|
-
current = current.next;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function pLimit(concurrency) {
|
|
93
|
-
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
|
94
|
-
throw new TypeError('Expected `concurrency` to be a number from 1 and up');
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const queue = new Queue();
|
|
98
|
-
let activeCount = 0;
|
|
99
|
-
|
|
100
|
-
const next = () => {
|
|
101
|
-
activeCount--;
|
|
102
|
-
|
|
103
|
-
if (queue.size > 0) {
|
|
104
|
-
queue.dequeue()();
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const run = async (fn, resolve, args) => {
|
|
109
|
-
activeCount++;
|
|
110
|
-
|
|
111
|
-
const result = (async () => fn(...args))();
|
|
112
|
-
|
|
113
|
-
resolve(result);
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
await result;
|
|
117
|
-
} catch {}
|
|
118
|
-
|
|
119
|
-
next();
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
const enqueue = (fn, resolve, args) => {
|
|
123
|
-
queue.enqueue(run.bind(undefined, fn, resolve, args));
|
|
124
|
-
|
|
125
|
-
(async () => {
|
|
126
|
-
// This function needs to wait until the next microtask before comparing
|
|
127
|
-
// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
|
|
128
|
-
// when the run function is dequeued and called. The comparison in the if-statement
|
|
129
|
-
// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
|
|
130
|
-
await Promise.resolve();
|
|
131
|
-
|
|
132
|
-
if (activeCount < concurrency && queue.size > 0) {
|
|
133
|
-
queue.dequeue()();
|
|
134
|
-
}
|
|
135
|
-
})();
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
const generator = (fn, ...args) => new Promise(resolve => {
|
|
139
|
-
enqueue(fn, resolve, args);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
Object.defineProperties(generator, {
|
|
143
|
-
activeCount: {
|
|
144
|
-
get: () => activeCount,
|
|
145
|
-
},
|
|
146
|
-
pendingCount: {
|
|
147
|
-
get: () => queue.size,
|
|
148
|
-
},
|
|
149
|
-
clearQueue: {
|
|
150
|
-
value: () => {
|
|
151
|
-
queue.clear();
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
return generator;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
class EndError extends Error {
|
|
160
|
-
constructor(value) {
|
|
161
|
-
super();
|
|
162
|
-
this.value = value;
|
|
163
|
-
}
|
|
17
|
+
function absolute(input, root) {
|
|
18
|
+
return isAbsolute(input) ? input : resolve(root || ".", input);
|
|
164
19
|
}
|
|
165
20
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
tester,
|
|
182
|
-
{
|
|
183
|
-
concurrency = Number.POSITIVE_INFINITY,
|
|
184
|
-
preserveOrder = true,
|
|
185
|
-
} = {},
|
|
186
|
-
) {
|
|
187
|
-
const limit = pLimit(concurrency);
|
|
188
|
-
|
|
189
|
-
// Start all the promises concurrently with optional limit.
|
|
190
|
-
const items = [...iterable].map(element => [element, limit(testElement, element, tester)]);
|
|
191
|
-
|
|
192
|
-
// Check the promises either serially or concurrently.
|
|
193
|
-
const checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);
|
|
194
|
-
|
|
195
|
-
try {
|
|
196
|
-
await Promise.all(items.map(element => checkLimit(finder, element)));
|
|
197
|
-
} catch (error) {
|
|
198
|
-
if (error instanceof EndError) {
|
|
199
|
-
return error.value;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
throw error;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const typeMappings = {
|
|
207
|
-
directory: 'isDirectory',
|
|
208
|
-
file: 'isFile',
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
function checkType(type) {
|
|
212
|
-
if (Object.hasOwnProperty.call(typeMappings, type)) {
|
|
213
|
-
return;
|
|
21
|
+
/**
|
|
22
|
+
* Get all parent directories of {@link base}.
|
|
23
|
+
* Stops after {@link Options['last']} is processed.
|
|
24
|
+
*
|
|
25
|
+
* @returns An array of absolute paths of all parent directories.
|
|
26
|
+
*/
|
|
27
|
+
function up(base, options) {
|
|
28
|
+
let { last, cwd } = options || {};
|
|
29
|
+
let tmp = absolute(base, cwd);
|
|
30
|
+
let root = absolute(last || "/", cwd);
|
|
31
|
+
let prev, arr = [];
|
|
32
|
+
while (prev !== root) {
|
|
33
|
+
arr.push(tmp);
|
|
34
|
+
tmp = dirname(prev = tmp);
|
|
35
|
+
if (tmp === prev) break;
|
|
214
36
|
}
|
|
215
|
-
|
|
216
|
-
throw new Error(`Invalid type specified: ${type}`);
|
|
37
|
+
return arr;
|
|
217
38
|
}
|
|
218
39
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
const statFunction = allowSymlinks ? promises.stat : promises.lstat;
|
|
237
|
-
|
|
238
|
-
return pLocate(paths, async path_ => {
|
|
239
|
-
try {
|
|
240
|
-
const stat = await statFunction(path.resolve(cwd, path_));
|
|
241
|
-
return matchType(type, stat);
|
|
242
|
-
} catch {
|
|
243
|
-
return false;
|
|
244
|
-
}
|
|
245
|
-
}, {concurrency, preserveOrder});
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
const toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
|
|
249
|
-
|
|
250
|
-
const findUpStop = Symbol('findUpStop');
|
|
251
|
-
|
|
252
|
-
async function findUpMultiple(name, options = {}) {
|
|
253
|
-
let directory = path.resolve(toPath(options.cwd) || '');
|
|
254
|
-
const {root} = path.parse(directory);
|
|
255
|
-
const stopAt = path.resolve(directory, options.stopAt || root);
|
|
256
|
-
const limit = options.limit || Number.POSITIVE_INFINITY;
|
|
257
|
-
const paths = [name].flat();
|
|
258
|
-
|
|
259
|
-
const runMatcher = async locateOptions => {
|
|
260
|
-
if (typeof name !== 'function') {
|
|
261
|
-
return locatePath(paths, locateOptions);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
const foundPath = await name(locateOptions.cwd);
|
|
265
|
-
if (typeof foundPath === 'string') {
|
|
266
|
-
return locatePath([foundPath], locateOptions);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
return foundPath;
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
const matches = [];
|
|
273
|
-
// eslint-disable-next-line no-constant-condition
|
|
274
|
-
while (true) {
|
|
275
|
-
// eslint-disable-next-line no-await-in-loop
|
|
276
|
-
const foundPath = await runMatcher({...options, cwd: directory});
|
|
277
|
-
|
|
278
|
-
if (foundPath === findUpStop) {
|
|
279
|
-
break;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
if (foundPath) {
|
|
283
|
-
matches.push(path.resolve(directory, foundPath));
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (directory === stopAt || matches.length >= limit) {
|
|
287
|
-
break;
|
|
40
|
+
/**
|
|
41
|
+
* Get the first path that matches any of the names provided.
|
|
42
|
+
*
|
|
43
|
+
* > [NOTE]
|
|
44
|
+
* > The order of {@link names} is respected.
|
|
45
|
+
*
|
|
46
|
+
* @param names The item names to find.
|
|
47
|
+
* @returns The absolute path of the first item found, if any.
|
|
48
|
+
*/
|
|
49
|
+
function any(names, options) {
|
|
50
|
+
let dir, start = options && options.cwd || "";
|
|
51
|
+
let j = 0, len = names.length, tmp;
|
|
52
|
+
for (dir of up(start, options)) {
|
|
53
|
+
for (j = 0; j < len; j++) {
|
|
54
|
+
tmp = join(dir, names[j]);
|
|
55
|
+
if (existsSync(tmp)) return tmp;
|
|
288
56
|
}
|
|
289
|
-
|
|
290
|
-
directory = path.dirname(directory);
|
|
291
57
|
}
|
|
292
|
-
|
|
293
|
-
return matches;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
async function findUp(name, options = {}) {
|
|
297
|
-
const matches = await findUpMultiple(name, {...options, limit: 1});
|
|
298
|
-
return matches[0];
|
|
299
58
|
}
|
|
300
59
|
|
|
301
60
|
var prompts$2 = {};
|
|
@@ -6576,9 +6335,9 @@ function requirePrompts () {
|
|
|
6576
6335
|
var promptsExports = requirePrompts();
|
|
6577
6336
|
var prompt = /*@__PURE__*/getDefaultExportFromCjs(promptsExports);
|
|
6578
6337
|
|
|
6579
|
-
var index = /*#__PURE__*/
|
|
6338
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
6580
6339
|
__proto__: null,
|
|
6581
6340
|
default: prompt
|
|
6582
|
-
}
|
|
6341
|
+
});
|
|
6583
6342
|
|
|
6584
|
-
export {
|
|
6343
|
+
export { any as a, index as i, prompt as p };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as assert, c as createExpect, g as globalExpect, i as inject, s as should, v as vi, d as vitest } from './vi.
|
|
2
|
-
import { b as bench } from './benchmark.
|
|
1
|
+
import { b as assert, c as createExpect, g as globalExpect, i as inject, s as should, v as vi, d as vitest } from './vi.B2--mG9U.js';
|
|
2
|
+
import { b as bench } from './benchmark.DHKMYAts.js';
|
|
3
3
|
import { expectTypeOf } from 'expect-type';
|
|
4
4
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
|
5
5
|
import { EvaluatedModules } from 'vite/module-runner';
|
|
@@ -2,7 +2,7 @@ import fs from 'node:fs';
|
|
|
2
2
|
import { getTasks, getFullName, getTests } from '@vitest/runner/utils';
|
|
3
3
|
import * as pathe from 'pathe';
|
|
4
4
|
import c from 'tinyrainbow';
|
|
5
|
-
import { g as getStateSymbol, t as truncateString, F as F_RIGHT, D as DefaultReporter, f as formatProjectName, s as separator } from './index.
|
|
5
|
+
import { g as getStateSymbol, t as truncateString, F as F_RIGHT, D as DefaultReporter, f as formatProjectName, s as separator } from './index.CHrBLuEH.js';
|
|
6
6
|
import { stripVTControlCharacters } from 'node:util';
|
|
7
7
|
import { notNullish } from '@vitest/utils/helpers';
|
|
8
8
|
|
|
@@ -10,10 +10,7 @@ let inspector, session;
|
|
|
10
10
|
function setupInspect(ctx) {
|
|
11
11
|
const config = ctx.config, isEnabled = config.inspector.enabled;
|
|
12
12
|
if (isEnabled) {
|
|
13
|
-
inspector = __require("node:inspector")
|
|
14
|
-
// Inspector may be open already if "isolate: false" is used
|
|
15
|
-
const isOpen = inspector.url() !== void 0;
|
|
16
|
-
if (!isOpen) {
|
|
13
|
+
if (inspector = __require("node:inspector"), !(inspector.url() !== void 0)) {
|
|
17
14
|
if (inspector.open(config.inspector.port, config.inspector.host, config.inspector.waitForDebugger), config.inspectBrk) {
|
|
18
15
|
const firstTestFile = typeof ctx.files[0] === "string" ? ctx.files[0] : ctx.files[0].filepath;
|
|
19
16
|
// Stop at first test file
|
|
@@ -2,7 +2,7 @@ import * as _vitest_spy from '@vitest/spy';
|
|
|
2
2
|
import vm from 'node:vm';
|
|
3
3
|
import * as viteModuleRunner from 'vite/module-runner';
|
|
4
4
|
import { ModuleEvaluator, ModuleRunnerImportMeta, ModuleRunnerContext, EvaluatedModuleNode, FetchFunction, EvaluatedModules } from 'vite/module-runner';
|
|
5
|
-
import { a as RuntimeRPC, W as WorkerGlobalState } from './worker.d.
|
|
5
|
+
import { a as RuntimeRPC, W as WorkerGlobalState } from './worker.d.buwuBpBt.js';
|
|
6
6
|
import { R as ResolveFunctionResult } from './environment.d.BsToaxti.js';
|
|
7
7
|
import { MockedModule, MockedModuleType } from '@vitest/mocker';
|
|
8
8
|
import { P as PendingSuiteMock, b as MockFactory, a as MockOptions } from './mocker.d.BE_2ls6u.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NodeSnapshotEnvironment } from '@vitest/snapshot/environment';
|
|
2
|
-
import { g as getWorkerState } from './utils.
|
|
2
|
+
import { g as getWorkerState } from './utils.CG9h5ccR.js';
|
|
3
3
|
import '@vitest/utils/timers';
|
|
4
4
|
|
|
5
5
|
class VitestNodeSnapshotEnvironment extends NodeSnapshotEnvironment {
|
|
@@ -7,8 +7,7 @@ class VitestNodeSnapshotEnvironment extends NodeSnapshotEnvironment {
|
|
|
7
7
|
return `// Vitest Snapshot v${this.getVersion()}, https://vitest.dev/guide/snapshot.html`;
|
|
8
8
|
}
|
|
9
9
|
resolvePath(filepath) {
|
|
10
|
-
|
|
11
|
-
return rpc.resolveSnapshotPath(filepath);
|
|
10
|
+
return getWorkerState().rpc.resolveSnapshotPath(filepath);
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
13
|
|