vitest 3.1.3 → 3.2.0-beta.2

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.
Files changed (57) hide show
  1. package/LICENSE.md +0 -232
  2. package/dist/browser.d.ts +4 -2
  3. package/dist/browser.js +3 -4
  4. package/dist/chunks/{base.DslwPSCy.js → base.DwtwORaC.js} +2 -2
  5. package/dist/chunks/{cac.BN2e7cE1.js → cac.I9MLYfT-.js} +14 -10
  6. package/dist/chunks/{cli-api.Bti1vevt.js → cli-api.d6IK1pnk.js} +945 -852
  7. package/dist/chunks/{coverage.87S59-Sl.js → coverage.OGU09Jbh.js} +129 -4216
  8. package/dist/chunks/{creator.CuL7xDWI.js → creator.DGAdZ4Hj.js} +18 -39
  9. package/dist/chunks/{environment.d.Dmw5ulng.d.ts → environment.d.D8YDy2v5.d.ts} +2 -1
  10. package/dist/chunks/{execute.BpmIjFTD.js → execute.JlGHLJZT.js} +3 -5
  11. package/dist/chunks/{global.d.CXRAxnWc.d.ts → global.d.BPa1eL3O.d.ts} +17 -12
  12. package/dist/chunks/{globals.CZAEe_Gf.js → globals.CpxW8ccg.js} +2 -3
  13. package/dist/chunks/{index.Bw6JxgX8.js → index.CK1YOQaa.js} +7 -7
  14. package/dist/chunks/{index.De2FqGmR.js → index.CV36oG_L.js} +896 -957
  15. package/dist/chunks/{index.B0uVAVvx.js → index.CfXMNXHg.js} +2 -14
  16. package/dist/chunks/index.CmC5OK9L.js +275 -0
  17. package/dist/chunks/{index.Cu2UlluP.js → index.DswW_LEs.js} +2 -2
  18. package/dist/chunks/{index.DBIGubLC.js → index.X0nbfr6-.js} +7 -7
  19. package/dist/chunks/{reporters.d.DG9VKi4m.d.ts → reporters.d.CLC9rhKy.d.ts} +68 -11
  20. package/dist/chunks/{runBaseTests.BV8m0B-u.js → runBaseTests.Dn2vyej_.js} +5 -6
  21. package/dist/chunks/{setup-common.AQcDs321.js → setup-common.CYo3Y0dD.js} +1 -3
  22. package/dist/chunks/typechecker.DnTrplSJ.js +897 -0
  23. package/dist/chunks/{vi.ClIskdbk.js → vi.BFR5YIgu.js} +3 -0
  24. package/dist/chunks/{vite.d.D3ndlJcw.d.ts → vite.d.CBZ3M_ru.d.ts} +1 -1
  25. package/dist/chunks/{vm.CuLHT1BG.js → vm.C1HHjtNS.js} +1 -1
  26. package/dist/chunks/{worker.d.CHGSOG0s.d.ts → worker.d.CoCI7hzP.d.ts} +1 -1
  27. package/dist/chunks/{worker.d.C-KN07Ls.d.ts → worker.d.D5Xdi-Zr.d.ts} +1 -1
  28. package/dist/cli.js +20 -1
  29. package/dist/config.cjs +3 -0
  30. package/dist/config.d.ts +8 -5
  31. package/dist/config.js +3 -0
  32. package/dist/coverage.d.ts +3 -3
  33. package/dist/coverage.js +4 -7
  34. package/dist/environments.d.ts +2 -2
  35. package/dist/execute.d.ts +2 -2
  36. package/dist/execute.js +1 -1
  37. package/dist/index.d.ts +45 -32
  38. package/dist/index.js +2 -3
  39. package/dist/node.d.ts +8 -8
  40. package/dist/node.js +16 -18
  41. package/dist/reporters.d.ts +3 -3
  42. package/dist/reporters.js +14 -14
  43. package/dist/runners.d.ts +1 -1
  44. package/dist/runners.js +2 -2
  45. package/dist/workers/forks.js +2 -2
  46. package/dist/workers/runVmTests.js +5 -6
  47. package/dist/workers/threads.js +2 -2
  48. package/dist/workers/vmForks.js +2 -2
  49. package/dist/workers/vmThreads.js +2 -2
  50. package/dist/workers.d.ts +3 -3
  51. package/dist/workers.js +3 -3
  52. package/package.json +15 -19
  53. package/dist/chunks/run-once.Dimr7O9f.js +0 -47
  54. package/dist/chunks/typechecker.DYQbn8uK.js +0 -956
  55. package/dist/chunks/utils.Cc45eY3L.js +0 -200
  56. package/dist/utils.d.ts +0 -3
  57. package/dist/utils.js +0 -2
@@ -1,18 +1,10 @@
1
- import { c as createExpect, a as globalExpect, i as inject, v as vi, b as vitest } from './vi.ClIskdbk.js';
2
- import { i as isFirstRun, a as runOnce } from './run-once.Dimr7O9f.js';
1
+ import { c as createExpect, a as globalExpect, i as inject, v as vi, b as vitest } from './vi.BFR5YIgu.js';
3
2
  import { b as bench } from './benchmark.BoF7jW0Q.js';
4
3
  import { expectTypeOf } from 'expect-type';
5
4
  import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
6
5
  import * as chai from 'chai';
7
6
  import { assert, should } from 'chai';
8
7
 
9
- function getRunningMode() {
10
- return process.env.VITEST_MODE === "WATCH" ? "watch" : "run";
11
- }
12
- function isWatchMode() {
13
- return getRunningMode() === "watch";
14
- }
15
-
16
8
  const assertType = function assertType() {};
17
9
 
18
10
  var VitestIndex = /*#__PURE__*/Object.freeze({
@@ -29,14 +21,10 @@ var VitestIndex = /*#__PURE__*/Object.freeze({
29
21
  describe: describe,
30
22
  expect: globalExpect,
31
23
  expectTypeOf: expectTypeOf,
32
- getRunningMode: getRunningMode,
33
24
  inject: inject,
34
- isFirstRun: isFirstRun,
35
- isWatchMode: isWatchMode,
36
25
  it: it,
37
26
  onTestFailed: onTestFailed,
38
27
  onTestFinished: onTestFinished,
39
- runOnce: runOnce,
40
28
  should: should,
41
29
  suite: suite,
42
30
  test: test,
@@ -44,4 +32,4 @@ var VitestIndex = /*#__PURE__*/Object.freeze({
44
32
  vitest: vitest
45
33
  });
46
34
 
47
- export { VitestIndex as V, assertType as a, getRunningMode as g, isWatchMode as i };
35
+ export { VitestIndex as V, assertType as a };
@@ -0,0 +1,275 @@
1
+ import fs from 'node:fs';
2
+ import { getTasks, getFullName, getTests } from '@vitest/runner/utils';
3
+ import * as pathe from 'pathe';
4
+ import c from 'tinyrainbow';
5
+ import { g as getStateSymbol, t as truncateString, F as F_RIGHT, D as DefaultReporter, f as formatProjectName } from './index.CV36oG_L.js';
6
+ import { stripVTControlCharacters } from 'node:util';
7
+ import { notNullish } from '@vitest/utils';
8
+
9
+ function createBenchmarkJsonReport(files) {
10
+ const report = { files: [] };
11
+ for (const file of files) {
12
+ const groups = [];
13
+ for (const task of getTasks(file)) {
14
+ if (task?.type === "suite") {
15
+ const benchmarks = [];
16
+ for (const t of task.tasks) {
17
+ const benchmark = t.meta.benchmark && t.result?.benchmark;
18
+ if (benchmark) {
19
+ benchmarks.push({
20
+ id: t.id,
21
+ ...benchmark,
22
+ samples: []
23
+ });
24
+ }
25
+ }
26
+ if (benchmarks.length) {
27
+ groups.push({
28
+ fullName: getFullName(task, " > "),
29
+ benchmarks
30
+ });
31
+ }
32
+ }
33
+ }
34
+ report.files.push({
35
+ filepath: file.filepath,
36
+ groups
37
+ });
38
+ }
39
+ return report;
40
+ }
41
+ function flattenFormattedBenchmarkReport(report) {
42
+ const flat = {};
43
+ for (const file of report.files) {
44
+ for (const group of file.groups) {
45
+ for (const t of group.benchmarks) {
46
+ flat[t.id] = t;
47
+ }
48
+ }
49
+ }
50
+ return flat;
51
+ }
52
+
53
+ const outputMap = new WeakMap();
54
+ function formatNumber(number) {
55
+ const res = String(number.toFixed(number < 100 ? 4 : 2)).split(".");
56
+ return res[0].replace(/(?=(?:\d{3})+$)\B/g, ",") + (res[1] ? `.${res[1]}` : "");
57
+ }
58
+ const tableHead = [
59
+ "name",
60
+ "hz",
61
+ "min",
62
+ "max",
63
+ "mean",
64
+ "p75",
65
+ "p99",
66
+ "p995",
67
+ "p999",
68
+ "rme",
69
+ "samples"
70
+ ];
71
+ function renderBenchmarkItems(result) {
72
+ return [
73
+ result.name,
74
+ formatNumber(result.hz || 0),
75
+ formatNumber(result.min || 0),
76
+ formatNumber(result.max || 0),
77
+ formatNumber(result.mean || 0),
78
+ formatNumber(result.p75 || 0),
79
+ formatNumber(result.p99 || 0),
80
+ formatNumber(result.p995 || 0),
81
+ formatNumber(result.p999 || 0),
82
+ `±${(result.rme || 0).toFixed(2)}%`,
83
+ (result.sampleCount || 0).toString()
84
+ ];
85
+ }
86
+ function computeColumnWidths(results) {
87
+ const rows = [tableHead, ...results.map((v) => renderBenchmarkItems(v))];
88
+ return Array.from(tableHead, (_, i) => Math.max(...rows.map((row) => stripVTControlCharacters(row[i]).length)));
89
+ }
90
+ function padRow(row, widths) {
91
+ return row.map((v, i) => i ? v.padStart(widths[i], " ") : v.padEnd(widths[i], " "));
92
+ }
93
+ function renderTableHead(widths) {
94
+ return " ".repeat(3) + padRow(tableHead, widths).map(c.bold).join(" ");
95
+ }
96
+ function renderBenchmark(result, widths) {
97
+ const padded = padRow(renderBenchmarkItems(result), widths);
98
+ return [
99
+ padded[0],
100
+ c.blue(padded[1]),
101
+ c.cyan(padded[2]),
102
+ c.cyan(padded[3]),
103
+ c.cyan(padded[4]),
104
+ c.cyan(padded[5]),
105
+ c.cyan(padded[6]),
106
+ c.cyan(padded[7]),
107
+ c.cyan(padded[8]),
108
+ c.dim(padded[9]),
109
+ c.dim(padded[10])
110
+ ].join(" ");
111
+ }
112
+ function renderTable(options) {
113
+ const output = [];
114
+ const benchMap = {};
115
+ for (const task of options.tasks) {
116
+ if (task.meta.benchmark && task.result?.benchmark) {
117
+ benchMap[task.id] = {
118
+ current: task.result.benchmark,
119
+ baseline: options.compare?.[task.id]
120
+ };
121
+ }
122
+ }
123
+ const benchCount = Object.entries(benchMap).length;
124
+ const columnWidths = computeColumnWidths(Object.values(benchMap).flatMap((v) => [v.current, v.baseline]).filter(notNullish));
125
+ let idx = 0;
126
+ const padding = " ".repeat(1 );
127
+ for (const task of options.tasks) {
128
+ const duration = task.result?.duration;
129
+ const bench = benchMap[task.id];
130
+ let prefix = "";
131
+ if (idx === 0 && task.meta?.benchmark) {
132
+ prefix += `${renderTableHead(columnWidths)}\n${padding}`;
133
+ }
134
+ prefix += ` ${getStateSymbol(task)} `;
135
+ let suffix = "";
136
+ if (task.type === "suite") {
137
+ suffix += c.dim(` (${getTests(task).length})`);
138
+ }
139
+ if (task.mode === "skip" || task.mode === "todo") {
140
+ suffix += c.dim(c.gray(" [skipped]"));
141
+ }
142
+ if (duration != null) {
143
+ const color = duration > options.slowTestThreshold ? c.yellow : c.green;
144
+ suffix += color(` ${Math.round(duration)}${c.dim("ms")}`);
145
+ }
146
+ if (options.showHeap && task.result?.heap != null) {
147
+ suffix += c.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
148
+ }
149
+ if (bench) {
150
+ let body = renderBenchmark(bench.current, columnWidths);
151
+ if (options.compare && bench.baseline) {
152
+ if (bench.current.hz) {
153
+ const diff = bench.current.hz / bench.baseline.hz;
154
+ const diffFixed = diff.toFixed(2);
155
+ if (diffFixed === "1.0.0") {
156
+ body += c.gray(` [${diffFixed}x]`);
157
+ }
158
+ if (diff > 1) {
159
+ body += c.blue(` [${diffFixed}x] ⇑`);
160
+ } else {
161
+ body += c.red(` [${diffFixed}x] ⇓`);
162
+ }
163
+ }
164
+ output.push(padding + prefix + body + suffix);
165
+ const bodyBaseline = renderBenchmark(bench.baseline, columnWidths);
166
+ output.push(`${padding} ${bodyBaseline} ${c.dim("(baseline)")}`);
167
+ } else {
168
+ if (bench.current.rank === 1 && benchCount > 1) {
169
+ body += c.bold(c.green(" fastest"));
170
+ }
171
+ if (bench.current.rank === benchCount && benchCount > 2) {
172
+ body += c.bold(c.gray(" slowest"));
173
+ }
174
+ output.push(padding + prefix + body + suffix);
175
+ }
176
+ } else {
177
+ output.push(padding + prefix + task.name + suffix);
178
+ }
179
+ if (task.result?.state !== "pass" && outputMap.get(task) != null) {
180
+ let data = outputMap.get(task);
181
+ if (typeof data === "string") {
182
+ data = stripVTControlCharacters(data.trim().split("\n").filter(Boolean).pop());
183
+ if (data === "") {
184
+ data = undefined;
185
+ }
186
+ }
187
+ if (data != null) {
188
+ const out = ` ${" ".repeat(options.level)}${F_RIGHT} ${data}`;
189
+ output.push(c.gray(truncateString(out, options.columns)));
190
+ }
191
+ }
192
+ idx++;
193
+ }
194
+ return output.filter(Boolean).join("\n");
195
+ }
196
+
197
+ class BenchmarkReporter extends DefaultReporter {
198
+ compare;
199
+ async onInit(ctx) {
200
+ super.onInit(ctx);
201
+ if (this.ctx.config.benchmark?.compare) {
202
+ const compareFile = pathe.resolve(this.ctx.config.root, this.ctx.config.benchmark?.compare);
203
+ try {
204
+ this.compare = flattenFormattedBenchmarkReport(JSON.parse(await fs.promises.readFile(compareFile, "utf-8")));
205
+ } catch (e) {
206
+ this.error(`Failed to read '${compareFile}'`, e);
207
+ }
208
+ }
209
+ }
210
+ onTaskUpdate(packs) {
211
+ for (const pack of packs) {
212
+ const task = this.ctx.state.idMap.get(pack[0]);
213
+ if (task?.type === "suite" && task.result?.state !== "run") {
214
+ task.tasks.filter((task) => task.result?.benchmark).sort((benchA, benchB) => benchA.result.benchmark.mean - benchB.result.benchmark.mean).forEach((bench, idx) => {
215
+ bench.result.benchmark.rank = Number(idx) + 1;
216
+ });
217
+ }
218
+ }
219
+ }
220
+ onTestSuiteResult(testSuite) {
221
+ super.onTestSuiteResult(testSuite);
222
+ this.printSuiteTable(testSuite);
223
+ }
224
+ printTestModule(testModule) {
225
+ this.printSuiteTable(testModule);
226
+ }
227
+ printSuiteTable(testTask) {
228
+ const state = testTask.state();
229
+ if (state === "pending" || state === "queued") {
230
+ return;
231
+ }
232
+ const benches = testTask.task.tasks.filter((t) => t.meta.benchmark);
233
+ const duration = testTask.task.result?.duration || 0;
234
+ if (benches.length > 0 && benches.every((t) => t.result?.state !== "run" && t.result?.state !== "queued")) {
235
+ let title = `\n ${getStateSymbol(testTask.task)} ${formatProjectName(testTask.project)}${getFullName(testTask.task, c.dim(" > "))}`;
236
+ if (duration != null && duration > this.ctx.config.slowTestThreshold) {
237
+ title += c.yellow(` ${Math.round(duration)}${c.dim("ms")}`);
238
+ }
239
+ this.log(title);
240
+ this.log(renderTable({
241
+ tasks: benches,
242
+ level: 1,
243
+ columns: this.ctx.logger.getColumns(),
244
+ compare: this.compare,
245
+ showHeap: this.ctx.config.logHeapUsage,
246
+ slowTestThreshold: this.ctx.config.slowTestThreshold
247
+ }));
248
+ }
249
+ }
250
+ async onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
251
+ super.onFinished(files, errors);
252
+ let outputFile = this.ctx.config.benchmark?.outputJson;
253
+ if (outputFile) {
254
+ outputFile = pathe.resolve(this.ctx.config.root, outputFile);
255
+ const outputDirectory = pathe.dirname(outputFile);
256
+ if (!fs.existsSync(outputDirectory)) {
257
+ await fs.promises.mkdir(outputDirectory, { recursive: true });
258
+ }
259
+ const output = createBenchmarkJsonReport(files);
260
+ await fs.promises.writeFile(outputFile, JSON.stringify(output, null, 2));
261
+ this.log(`Benchmark report written to ${outputFile}`);
262
+ }
263
+ }
264
+ }
265
+
266
+ class VerboseBenchmarkReporter extends BenchmarkReporter {
267
+ verbose = true;
268
+ }
269
+
270
+ const BenchmarkReportsMap = {
271
+ default: BenchmarkReporter,
272
+ verbose: VerboseBenchmarkReporter
273
+ };
274
+
275
+ export { BenchmarkReporter as B, VerboseBenchmarkReporter as V, BenchmarkReportsMap as a };
@@ -1,6 +1,6 @@
1
1
  import * as chai from 'chai';
2
2
  import { resolve } from 'node:path';
3
- import { l as loadDiffConfig, b as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.AQcDs321.js';
3
+ import { l as loadDiffConfig, b as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.CYo3Y0dD.js';
4
4
  import { distDir } from '../path.js';
5
5
  import { r as rpc } from './rpc.D9_013TY.js';
6
6
  import { g as getWorkerState } from './utils.CgTj3MsC.js';
@@ -93,7 +93,7 @@ async function resolveTestRunner(config, executor) {
93
93
  const currentFailures = 1 + previousFailures;
94
94
  if (currentFailures >= config.bail) {
95
95
  rpc().onCancel("test-failure");
96
- testRunner.onCancel?.("test-failure");
96
+ testRunner.cancel?.("test-failure");
97
97
  }
98
98
  }
99
99
  await originalOnAfterRunTask?.call(testRunner, test);
@@ -1,4 +1,4 @@
1
- import p from 'node:path';
1
+ import path from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
3
  import process$1 from 'node:process';
4
4
  import { promises } from 'node:fs';
@@ -237,7 +237,7 @@ async function locatePath(
237
237
 
238
238
  return pLocate(paths, async path_ => {
239
239
  try {
240
- const stat = await statFunction(p.resolve(cwd, path_));
240
+ const stat = await statFunction(path.resolve(cwd, path_));
241
241
  return matchType(type, stat);
242
242
  } catch {
243
243
  return false;
@@ -250,9 +250,9 @@ const toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath)
250
250
  const findUpStop = Symbol('findUpStop');
251
251
 
252
252
  async function findUpMultiple(name, options = {}) {
253
- let directory = p.resolve(toPath(options.cwd) || '');
254
- const {root} = p.parse(directory);
255
- const stopAt = p.resolve(directory, options.stopAt || root);
253
+ let directory = path.resolve(toPath(options.cwd) || '');
254
+ const {root} = path.parse(directory);
255
+ const stopAt = path.resolve(directory, options.stopAt || root);
256
256
  const limit = options.limit || Number.POSITIVE_INFINITY;
257
257
  const paths = [name].flat();
258
258
 
@@ -280,14 +280,14 @@ async function findUpMultiple(name, options = {}) {
280
280
  }
281
281
 
282
282
  if (foundPath) {
283
- matches.push(p.resolve(directory, foundPath));
283
+ matches.push(path.resolve(directory, foundPath));
284
284
  }
285
285
 
286
286
  if (directory === stopAt || matches.length >= limit) {
287
287
  break;
288
288
  }
289
289
 
290
- directory = p.dirname(directory);
290
+ directory = path.dirname(directory);
291
291
  }
292
292
 
293
293
  return matches;
@@ -1,12 +1,12 @@
1
1
  import { Task, TaskMeta, Suite, File, TaskResultPack, SequenceSetupFiles, SequenceHooks, CancelReason } from '@vitest/runner';
2
- import { b as Awaitable, U as UserConsoleLog, c as Arrayable$1, A as AfterSuiteRunMeta, f as EnvironmentOptions, P as ProvidedContext } from './environment.d.Dmw5ulng.js';
2
+ import { b as Awaitable, U as UserConsoleLog, c as Arrayable$1, A as AfterSuiteRunMeta, L as LabelColor, f as EnvironmentOptions, P as ProvidedContext } from './environment.d.D8YDy2v5.js';
3
3
  import { ParsedStack, TestError, SerializedError, ErrorWithDiff, Arrayable, Awaitable as Awaitable$1 } from '@vitest/utils';
4
4
  import { Writable } from 'node:stream';
5
5
  import { TransformResult as TransformResult$1, UserConfig as UserConfig$1, DepOptimizationConfig, ServerOptions, ConfigEnv, AliasOptions, ViteDevServer, ModuleNode } from 'vite';
6
6
  import { Console } from 'node:console';
7
7
  import { MockedModule } from '@vitest/mocker';
8
8
  import { StackTraceParserOptions } from '@vitest/utils/source-map';
9
- import { T as TestExecutionMethod } from './worker.d.CHGSOG0s.js';
9
+ import { T as TestExecutionMethod } from './worker.d.CoCI7hzP.js';
10
10
  import { a as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.UqE-KR0o.js';
11
11
  import { PrettyFormatOptions } from '@vitest/pretty-format';
12
12
  import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
@@ -51,6 +51,7 @@ declare class Logger {
51
51
  clearScreen(message: string, force?: boolean): void;
52
52
  private _clearScreen;
53
53
  printError(err: unknown, options?: ErrorOptions): void;
54
+ deprecate(message: string): void;
54
55
  clearHighlightCache(filename?: string): void;
55
56
  highlight(filename: string, source: string): string;
56
57
  printNoTestFound(filters?: string[]): void;
@@ -1065,6 +1066,11 @@ interface TestSequencerConstructor {
1065
1066
  new (ctx: Vitest): TestSequencer;
1066
1067
  }
1067
1068
 
1069
+ interface WatcherTriggerPattern {
1070
+ pattern: RegExp;
1071
+ testsToRun: (file: string, match: RegExpMatchArray) => string[] | string | null | undefined | void;
1072
+ }
1073
+
1068
1074
  interface BenchmarkUserOptions {
1069
1075
  /**
1070
1076
  * Include globs for benchmark test files
@@ -1377,8 +1383,21 @@ interface CoverageIstanbulOptions extends BaseCoverageOptions {
1377
1383
  interface CoverageV8Options extends BaseCoverageOptions {
1378
1384
  /**
1379
1385
  * Ignore empty lines, comments and other non-runtime code, e.g. Typescript types
1386
+ * - Requires `experimentalAstAwareRemapping: false`
1380
1387
  */
1381
1388
  ignoreEmptyLines?: boolean;
1389
+ /**
1390
+ * Remap coverage with experimental AST based analysis
1391
+ * - Provides more accurate results compared to default mode
1392
+ */
1393
+ experimentalAstAwareRemapping?: boolean;
1394
+ /**
1395
+ * Set to array of class method names to ignore for coverage.
1396
+ * - Requires `experimentalAstAwareRemapping: true`
1397
+ *
1398
+ * @default []
1399
+ */
1400
+ ignoreClassMethods?: string[];
1382
1401
  }
1383
1402
  interface CustomProviderOptions extends Pick<BaseCoverageOptions, FieldsWithDefaultValues> {
1384
1403
  /** Name of the module or path to a file to load the custom provider from */
@@ -1412,6 +1431,10 @@ type CSSModuleScopeStrategy = "stable" | "scoped" | "non-scoped";
1412
1431
  type ApiConfig = Pick<ServerOptions, "port" | "strictPort" | "host" | "middlewareMode">;
1413
1432
 
1414
1433
  type VitestRunMode = "test" | "benchmark";
1434
+ interface ProjectName {
1435
+ label: string;
1436
+ color?: LabelColor;
1437
+ }
1415
1438
  interface SequenceOptions {
1416
1439
  /**
1417
1440
  * Class that handles sorting and sharding algorithm.
@@ -1421,6 +1444,15 @@ interface SequenceOptions {
1421
1444
  */
1422
1445
  sequencer?: TestSequencerConstructor;
1423
1446
  /**
1447
+ * Controls the order in which this project runs its tests when using multiple [projects](/guide/projects).
1448
+ *
1449
+ * - Projects with the same group order number will run together, and groups are run from lowest to highest.
1450
+ * - If you don’t set this option, all projects run in parallel.
1451
+ * - If several projects use the same group order, they will run at the same time.
1452
+ * @default 0
1453
+ */
1454
+ groupOrder?: number;
1455
+ /**
1424
1456
  * Should files and tests run in random order.
1425
1457
  * @default false
1426
1458
  */
@@ -1578,7 +1610,7 @@ interface InlineConfig {
1578
1610
  /**
1579
1611
  * Name of the project. Will be used to display in the reporter.
1580
1612
  */
1581
- name?: string;
1613
+ name?: string | ProjectName;
1582
1614
  /**
1583
1615
  * Benchmark options.
1584
1616
  *
@@ -1643,7 +1675,7 @@ interface InlineConfig {
1643
1675
  *
1644
1676
  * Format: [glob, environment-name]
1645
1677
  *
1646
- * @deprecated use [`workspace`](https://vitest.dev/config/#environmentmatchglobs) instead
1678
+ * @deprecated use [`projects`](https://vitest.dev/config/#projects) instead
1647
1679
  * @default []
1648
1680
  * @example [
1649
1681
  * // all tests in tests/dom will run in jsdom
@@ -1694,7 +1726,7 @@ interface InlineConfig {
1694
1726
  *
1695
1727
  * Format: [glob, pool-name]
1696
1728
  *
1697
- * @deprecated use [`workspace`](https://vitest.dev/config/#poolmatchglobs) instead
1729
+ * @deprecated use [`projects`](https://vitest.dev/config/#projects) instead
1698
1730
  * @default []
1699
1731
  * @example [
1700
1732
  * // all tests in "forks" directory will run using "poolOptions.forks" API
@@ -1705,7 +1737,12 @@ interface InlineConfig {
1705
1737
  */
1706
1738
  poolMatchGlobs?: [string, Exclude<Pool, "browser">][];
1707
1739
  /**
1740
+ * Options for projects
1741
+ */
1742
+ projects?: TestProjectConfiguration[];
1743
+ /**
1708
1744
  * Path to a workspace configuration file
1745
+ * @deprecated use `projects` instead
1709
1746
  */
1710
1747
  workspace?: string | TestProjectConfiguration[];
1711
1748
  /**
@@ -1787,6 +1824,11 @@ interface InlineConfig {
1787
1824
  */
1788
1825
  forceRerunTriggers?: string[];
1789
1826
  /**
1827
+ * Pattern configuration to rerun only the tests that are affected
1828
+ * by the changes of specific files in the repository.
1829
+ */
1830
+ watchTriggerPatterns?: WatcherTriggerPattern[];
1831
+ /**
1790
1832
  * Coverage options
1791
1833
  */
1792
1834
  coverage?: CoverageOptions;
@@ -2201,8 +2243,10 @@ interface UserConfig extends InlineConfig {
2201
2243
  */
2202
2244
  mergeReports?: string;
2203
2245
  }
2204
- interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config" | "filters" | "browser" | "coverage" | "testNamePattern" | "related" | "api" | "reporters" | "resolveSnapshotPath" | "benchmark" | "shard" | "cache" | "sequence" | "typecheck" | "runner" | "poolOptions" | "pool" | "cliExclude" | "diff" | "setupFiles" | "snapshotEnvironment" | "bail"> {
2246
+ interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config" | "filters" | "browser" | "coverage" | "testNamePattern" | "related" | "api" | "reporters" | "resolveSnapshotPath" | "benchmark" | "shard" | "cache" | "sequence" | "typecheck" | "runner" | "poolOptions" | "pool" | "cliExclude" | "diff" | "setupFiles" | "snapshotEnvironment" | "bail" | "name"> {
2205
2247
  mode: VitestRunMode;
2248
+ name: ProjectName["label"];
2249
+ color?: ProjectName["color"];
2206
2250
  base?: string;
2207
2251
  diff?: string | SerializedDiffOptions;
2208
2252
  bail?: number;
@@ -2242,6 +2286,7 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config"
2242
2286
  shuffle?: boolean
2243
2287
  concurrent?: boolean
2244
2288
  seed: number
2289
+ groupOrder: number
2245
2290
  };
2246
2291
  typecheck: Omit<TypecheckConfig, "enabled"> & {
2247
2292
  enabled: boolean
@@ -2250,7 +2295,7 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config"
2250
2295
  maxWorkers: number;
2251
2296
  minWorkers: number;
2252
2297
  }
2253
- type NonProjectOptions = "shard" | "watch" | "run" | "cache" | "update" | "reporters" | "outputFile" | "teardownTimeout" | "silent" | "forceRerunTriggers" | "testNamePattern" | "ui" | "open" | "uiBase" | "snapshotFormat" | "resolveSnapshotPath" | "passWithNoTests" | "onConsoleLog" | "onStackTrace" | "dangerouslyIgnoreUnhandledErrors" | "slowTestThreshold" | "inspect" | "inspectBrk" | "coverage" | "maxWorkers" | "minWorkers" | "fileParallelism" | "workspace";
2298
+ type NonProjectOptions = "shard" | "watch" | "run" | "cache" | "update" | "reporters" | "outputFile" | "teardownTimeout" | "silent" | "forceRerunTriggers" | "testNamePattern" | "ui" | "open" | "uiBase" | "snapshotFormat" | "resolveSnapshotPath" | "passWithNoTests" | "onConsoleLog" | "onStackTrace" | "dangerouslyIgnoreUnhandledErrors" | "slowTestThreshold" | "inspect" | "inspectBrk" | "coverage" | "maxWorkers" | "minWorkers" | "fileParallelism" | "workspace" | "watchTriggerPatterns";
2254
2299
  type ProjectConfig = Omit<InlineConfig, NonProjectOptions | "sequencer" | "deps" | "poolOptions"> & {
2255
2300
  mode?: string
2256
2301
  sequencer?: Omit<SequenceOptions, "sequencer" | "seed">
@@ -2313,12 +2358,13 @@ interface BrowserProviderModule {
2313
2358
  }
2314
2359
  interface BrowserProviderOptions {}
2315
2360
  type BrowserBuiltinProvider = "webdriverio" | "playwright" | "preview";
2316
- type UnsupportedProperties = "browser" | "typecheck" | "alias" | "sequence" | "root" | "pool" | "poolOptions" | "runner" | "api" | "deps" | "testTransformMode" | "poolMatchGlobs" | "environmentMatchGlobs" | "environment" | "environmentOptions" | "server" | "benchmark";
2361
+ type UnsupportedProperties = "browser" | "typecheck" | "alias" | "sequence" | "root" | "pool" | "poolOptions" | "runner" | "api" | "deps" | "testTransformMode" | "poolMatchGlobs" | "environmentMatchGlobs" | "environment" | "environmentOptions" | "server" | "benchmark" | "name";
2317
2362
  interface BrowserInstanceOption extends BrowserProviderOptions, Omit<ProjectConfig, UnsupportedProperties>, Pick<BrowserConfigOptions, "headless" | "locators" | "viewport" | "testerHtmlPath" | "screenshotDirectory" | "screenshotFailures"> {
2318
2363
  /**
2319
2364
  * Name of the browser
2320
2365
  */
2321
2366
  browser: string;
2367
+ name?: string;
2322
2368
  }
2323
2369
  interface BrowserConfigOptions {
2324
2370
  /**
@@ -2562,6 +2608,12 @@ declare class TestProject {
2562
2608
  private _provided;
2563
2609
  constructor(path: string | number, vitest: Vitest, options?: InitializeProjectOptions | undefined);
2564
2610
  /**
2611
+ * The unique hash of this project. This value is consistent between the reruns.
2612
+ *
2613
+ * It is based on the root of the project (not consistent between OS) and its name.
2614
+ */
2615
+ get hash(): string;
2616
+ /**
2565
2617
  * Provide a value to the test context. This value will be available to all tests with `inject`.
2566
2618
  */
2567
2619
  provide: <T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]) => void;
@@ -2588,6 +2640,10 @@ declare class TestProject {
2588
2640
  */
2589
2641
  get name(): string;
2590
2642
  /**
2643
+ * The color used when reporting tasks of this project.
2644
+ */
2645
+ get color(): ProjectName["color"];
2646
+ /**
2591
2647
  * Serialized project configuration. This is the config that tests receive.
2592
2648
  */
2593
2649
  get serializedConfig(): SerializedConfig;
@@ -2658,6 +2714,7 @@ declare class TestProject {
2658
2714
  getName(): string;
2659
2715
  /** @deprecated internal */
2660
2716
  setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
2717
+ private _setHash;
2661
2718
  private _serializeOverriddenConfig;
2662
2719
  private clearTmpDir;
2663
2720
  /** @deprecated */
@@ -2889,7 +2946,7 @@ declare class Vitest {
2889
2946
  */
2890
2947
  import<T>(moduleId: string): Promise<T>;
2891
2948
  private resolveWorkspaceConfigPath;
2892
- private resolveWorkspace;
2949
+ private resolveProjects;
2893
2950
  /**
2894
2951
  * Glob test files in every project and create a TestSpecification for each file and pool.
2895
2952
  * @param filters String filters to match the test files.
@@ -3053,5 +3110,5 @@ declare class Vitest {
3053
3110
  type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
3054
3111
  type OnTestsRerunHandler = (testFiles: TestSpecification[]) => Promise<void> | void;
3055
3112
 
3056
- export { CoverageMap as C, TestSpecification as J, TestModule as K, Logger as L, VitestPackageInstaller as Q, TestProject as T, Vitest as V, getFilePoolName as Z, TestCase as a3, TestCollection as a4, BasicReporter as aB, BenchmarkReporter as aC, BenchmarkReportsMap as aD, DefaultReporter as aE, DotReporter as aF, GithubActionsReporter as aG, HangingProcessReporter as aH, JsonReporter as aI, JUnitReporter as aJ, ReportersMap as aK, TapFlatReporter as aL, TapReporter as aM, VerboseBenchmarkReporter as aN, VerboseReporter as aO, BaseReporter as aP, TestSuite as ac };
3057
- export type { HTMLOptions as $, ApiConfig as A, BaseCoverageOptions as B, DepsOptimizationOptions as D, BenchmarkUserOptions as E, BrowserTesterOptions as F, VitestOptions as G, TestSequencer as H, InlineConfig as I, ModuleDiagnostic as M, OnTestsRerunHandler as N, OnServerRestartHandler as O, Pool as P, ResolvedCoverageOptions as R, SerializedTestSpecification as S, UserWorkspaceConfig as U, WorkspaceProjectConfiguration as W, ProcessPool as X, WorkspaceSpec as Y, SerializedTestProject as _, ReportContext as a, JsonOptions$1 as a0, JUnitOptions as a1, TaskOptions as a2, TestDiagnostic as a5, TestModuleState as a6, TestResult as a7, TestResultFailed as a8, TestResultPassed as a9, TestRunEndReason as aA, BenchmarkBuiltinReporters as aQ, BuiltinReporterOptions as aR, BuiltinReporters as aS, JsonAssertionResult as aT, JsonTestResult as aU, JsonTestResults as aV, TestResultSkipped as aa, TestState as ab, TestSuiteState as ad, TestSequencerConstructor as ae, BrowserBuiltinProvider as af, BrowserCommand as ag, BrowserCommandContext as ah, BrowserInstanceOption as ai, BrowserModuleMocker as aj, BrowserOrchestrator as ak, BrowserProvider as al, BrowserProviderInitializationOptions as am, BrowserProviderModule as an, BrowserProviderOptions as ao, BrowserServerState as ap, BrowserServerStateSession as aq, CDPSession as ar, ParentProjectBrowser as as, ProjectBrowser as at, ResolvedBrowserOptions as au, ResolvedProjectConfig as av, ResolveSnapshotPathHandler as aw, ResolveSnapshotPathHandlerContext as ax, TestRunResult as ay, ReportedHookContext as az, TestProjectConfiguration as b, CoverageV8Options as c, UserProjectConfigFn as d, UserProjectConfigExport as e, TestProjectInlineConfiguration as f, CoverageProvider as g, CoverageProviderModule as h, CoverageReporter as i, CoverageProviderName as j, CoverageOptions as k, CoverageIstanbulOptions as l, CustomProviderOptions as m, Reporter as n, BrowserScript as o, BrowserConfigOptions as p, BuiltinEnvironment as q, VitestEnvironment as r, PoolOptions as s, CSSModuleScopeStrategy as t, VitestRunMode as u, TransformModePatterns as v, TypecheckConfig as w, UserConfig as x, ResolvedConfig as y, ProjectConfig as z };
3113
+ export { CoverageMap as C, TestSpecification as K, Logger as L, TestModule as M, TestProject as T, Vitest as V, VitestPackageInstaller as X, getFilePoolName as _, TestCase as a4, TestCollection as a5, BasicReporter as aC, BenchmarkReporter as aD, BenchmarkReportsMap as aE, DefaultReporter as aF, DotReporter as aG, GithubActionsReporter as aH, HangingProcessReporter as aI, JsonReporter as aJ, JUnitReporter as aK, ReportersMap as aL, TapFlatReporter as aM, TapReporter as aN, VerboseBenchmarkReporter as aO, VerboseReporter as aP, BaseReporter as aQ, TestSuite as ad };
3114
+ export type { SerializedTestProject as $, ApiConfig as A, BaseCoverageOptions as B, DepsOptimizationOptions as D, ProjectConfig as E, BenchmarkUserOptions as F, BrowserTesterOptions as G, VitestOptions as H, InlineConfig as I, TestSequencer as J, ModuleDiagnostic as N, OnServerRestartHandler as O, Pool as P, OnTestsRerunHandler as Q, ResolvedCoverageOptions as R, SerializedTestSpecification as S, UserWorkspaceConfig as U, WorkspaceProjectConfiguration as W, ProcessPool as Y, WorkspaceSpec as Z, ReportContext as a, HTMLOptions as a0, JsonOptions$1 as a1, JUnitOptions as a2, TaskOptions as a3, TestDiagnostic as a6, TestModuleState as a7, TestResult as a8, TestResultFailed as a9, ReportedHookContext as aA, TestRunEndReason as aB, BenchmarkBuiltinReporters as aR, BuiltinReporterOptions as aS, BuiltinReporters as aT, JsonAssertionResult as aU, JsonTestResult as aV, JsonTestResults as aW, TestResultPassed as aa, TestResultSkipped as ab, TestState as ac, TestSuiteState as ae, TestSequencerConstructor as af, BrowserBuiltinProvider as ag, BrowserCommand as ah, BrowserCommandContext as ai, BrowserInstanceOption as aj, BrowserModuleMocker as ak, BrowserOrchestrator as al, BrowserProvider as am, BrowserProviderInitializationOptions as an, BrowserProviderModule as ao, BrowserProviderOptions as ap, BrowserServerState as aq, BrowserServerStateSession as ar, CDPSession as as, ParentProjectBrowser as at, ProjectBrowser as au, ResolvedBrowserOptions as av, ResolvedProjectConfig as aw, ResolveSnapshotPathHandler as ax, ResolveSnapshotPathHandlerContext as ay, TestRunResult as az, TestProjectConfiguration as b, CoverageV8Options as c, UserProjectConfigFn as d, UserProjectConfigExport as e, TestProjectInlineConfiguration as f, WatcherTriggerPattern as g, CoverageProvider as h, CoverageProviderModule as i, CoverageReporter as j, CoverageProviderName as k, CoverageOptions as l, CoverageIstanbulOptions as m, CustomProviderOptions as n, Reporter as o, BrowserScript as p, BrowserConfigOptions as q, BuiltinEnvironment as r, VitestEnvironment as s, PoolOptions as t, CSSModuleScopeStrategy as u, VitestRunMode as v, TransformModePatterns as w, TypecheckConfig as x, UserConfig as y, ResolvedConfig as z };
@@ -1,8 +1,8 @@
1
1
  import { performance } from 'node:perf_hooks';
2
2
  import { startTests, collectTests } from '@vitest/runner';
3
- import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.Cu2UlluP.js';
4
- import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './setup-common.AQcDs321.js';
5
- import { a as globalExpect, v as vi } from './vi.ClIskdbk.js';
3
+ import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.DswW_LEs.js';
4
+ import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './setup-common.CYo3Y0dD.js';
5
+ import { a as globalExpect, v as vi } from './vi.BFR5YIgu.js';
6
6
  import { c as closeInspector } from './inspector.DbDkSkFn.js';
7
7
  import { createRequire } from 'node:module';
8
8
  import timers from 'node:timers';
@@ -11,7 +11,7 @@ import util from 'node:util';
11
11
  import { getSafeTimers } from '@vitest/utils';
12
12
  import { KNOWN_ASSET_TYPES } from 'vite-node/constants';
13
13
  import { installSourcemapsSupport } from 'vite-node/source-map';
14
- import { V as VitestIndex } from './index.B0uVAVvx.js';
14
+ import { V as VitestIndex } from './index.CfXMNXHg.js';
15
15
  import { g as getWorkerState, r as resetModules } from './utils.CgTj3MsC.js';
16
16
  import 'chai';
17
17
  import 'node:path';
@@ -21,7 +21,6 @@ import './rpc.D9_013TY.js';
21
21
  import './index.CJ0plNrh.js';
22
22
  import './coverage.0iPg4Wrz.js';
23
23
  import '@vitest/snapshot';
24
- import './run-once.Dimr7O9f.js';
25
24
  import '@vitest/expect';
26
25
  import '@vitest/runner/utils';
27
26
  import './_commonjsHelpers.BFTU3MAI.js';
@@ -106,7 +105,7 @@ async function run(method, files, config, environment, executor) {
106
105
  const runner = await resolveTestRunner(config, executor);
107
106
  workerState.onCancel.then((reason) => {
108
107
  closeInspector(config);
109
- runner.onCancel?.(reason);
108
+ runner.cancel?.(reason);
110
109
  });
111
110
  workerState.durations.prepare = performance.now() - workerState.durations.prepare;
112
111
  workerState.durations.environment = performance.now();
@@ -1,7 +1,6 @@
1
1
  import { r as resolveCoverageProviderModule } from './coverage.0iPg4Wrz.js';
2
2
  import { addSerializer } from '@vitest/snapshot';
3
3
  import { setSafeTimers } from '@vitest/utils';
4
- import { r as resetRunOnceCounter } from './run-once.Dimr7O9f.js';
5
4
 
6
5
  async function startCoverageInsideWorker(options, loader, runtimeOptions) {
7
6
  const coverageModule = await resolveCoverageProviderModule(options, loader);
@@ -27,7 +26,6 @@ async function stopCoverageInsideWorker(options, loader, runtimeOptions) {
27
26
 
28
27
  let globalSetup = false;
29
28
  async function setupCommonEnv(config) {
30
- resetRunOnceCounter();
31
29
  setupDefines(config.defines);
32
30
  setupEnv(config.env);
33
31
  if (globalSetup) {
@@ -36,7 +34,7 @@ async function setupCommonEnv(config) {
36
34
  globalSetup = true;
37
35
  setSafeTimers();
38
36
  if (config.globals) {
39
- (await import('./globals.CZAEe_Gf.js')).registerApiGlobally();
37
+ (await import('./globals.CpxW8ccg.js')).registerApiGlobally();
40
38
  }
41
39
  }
42
40
  function setupDefines(defines) {