vitest 3.1.0-beta.2 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/LICENSE.md +29 -0
  2. package/dist/chunks/{base.CylSMlTD.js → base.bV8rwssx.js} +1 -1
  3. package/dist/chunks/{cac.JtTXbKz0.js → cac.1WcTh-zl.js} +10 -6
  4. package/dist/chunks/{cli-api.BTtPTYMs.js → cli-api.2yb7XCwB.js} +39 -37
  5. package/dist/chunks/{coverage.C2ohxaN0.js → coverage.SfnlalVs.js} +213 -8
  6. package/dist/chunks/{creator.BEXek7yQ.js → creator.CuL7xDWI.js} +65 -0
  7. package/dist/chunks/{execute.DZKwfrTs.js → execute.CwmnH2oH.js} +6 -6
  8. package/dist/chunks/{index.ZIOEXBQB.js → index.CwHmn5H5.js} +140 -100
  9. package/dist/chunks/{reporters.d.5g6jXhoW.d.ts → reporters.d.CfRkRKN2.d.ts} +39 -18
  10. package/dist/chunks/{typechecker.C2IpOhid.js → typechecker.CG0zmr19.js} +6 -6
  11. package/dist/chunks/{utils.OLmtDstN.js → utils.Lot3J_8U.js} +1 -1
  12. package/dist/chunks/{vite.d.Dh1jE-_V.d.ts → vite.d.4pkSbgmp.d.ts} +1 -1
  13. package/dist/chunks/{vm.BW5voG-u.js → vm.Lp7mPCVW.js} +91 -84
  14. package/dist/cli.js +1 -1
  15. package/dist/config.d.ts +6 -4
  16. package/dist/coverage.d.ts +2 -1
  17. package/dist/coverage.js +3 -3
  18. package/dist/execute.d.ts +0 -2
  19. package/dist/execute.js +1 -1
  20. package/dist/index.d.ts +6 -5
  21. package/dist/node.d.ts +17 -6
  22. package/dist/node.js +8 -8
  23. package/dist/reporters.d.ts +2 -1
  24. package/dist/reporters.js +3 -3
  25. package/dist/workers/forks.js +2 -2
  26. package/dist/workers/threads.js +2 -2
  27. package/dist/workers/vmForks.js +2 -2
  28. package/dist/workers/vmThreads.js +2 -2
  29. package/dist/workers.d.ts +2 -1
  30. package/dist/workers.js +3 -3
  31. package/package.json +17 -17
@@ -433,15 +433,15 @@ class VitestMocker {
433
433
  const registry = this.getMockerRegistry();
434
434
  const id = this.normalizePath(path);
435
435
  if (mockType === "manual") {
436
- registry.register("manual", originalId, id, factory);
436
+ registry.register("manual", originalId, id, id, factory);
437
437
  } else if (mockType === "autospy") {
438
- registry.register("autospy", originalId, id);
438
+ registry.register("autospy", originalId, id, id);
439
439
  } else {
440
440
  const redirect = this.resolveMockPath(id, external);
441
441
  if (redirect) {
442
- registry.register("redirect", originalId, id, redirect);
442
+ registry.register("redirect", originalId, id, id, redirect);
443
443
  } else {
444
- registry.register("automock", originalId, id);
444
+ registry.register("automock", originalId, id, id);
445
445
  }
446
446
  }
447
447
  this.deleteCachedItem(id);
@@ -458,9 +458,9 @@ class VitestMocker {
458
458
  if (!mock) {
459
459
  const redirect = this.resolveMockPath(normalizedId, external);
460
460
  if (redirect) {
461
- mock = new RedirectedModule(rawId, normalizedId, redirect);
461
+ mock = new RedirectedModule(rawId, normalizedId, normalizedId, redirect);
462
462
  } else {
463
- mock = new AutomockedModule(rawId, normalizedId);
463
+ mock = new AutomockedModule(rawId, normalizedId, normalizedId);
464
464
  }
465
465
  }
466
466
  if (mock.type === "automock" || mock.type === "autospy") {
@@ -1,15 +1,15 @@
1
1
  import fs, { existsSync, readFileSync, promises } from 'node:fs';
2
- import { getSuites, getTests, getTestName, hasFailed, getFullName, getTasks } from '@vitest/runner/utils';
2
+ import { getTestName, hasFailed, getFullName, getTests, getSuites, getTasks } from '@vitest/runner/utils';
3
3
  import * as pathe from 'pathe';
4
4
  import { relative, normalize, resolve, dirname } from 'pathe';
5
5
  import c from 'tinyrainbow';
6
- import { t as truncateString, d as divider, F as F_POINTER, f as formatTimeString, g as getStateSymbol, a as formatProjectName, b as taskFail, c as F_CHECK, e as F_RIGHT, w as withLabel, r as renderSnapshotSummary, p as padSummaryTitle, h as getStateString$1, i as formatTime, j as countTestErrors, k as F_TREE_NODE_END, l as F_TREE_NODE_MIDDLE } from './utils.OLmtDstN.js';
6
+ import { t as truncateString, d as divider, F as F_POINTER, f as formatTimeString, a as taskFail, b as F_CHECK, g as getStateSymbol, c as formatProjectName, e as F_RIGHT, w as withLabel, r as renderSnapshotSummary, p as padSummaryTitle, h as getStateString$1, i as formatTime, j as countTestErrors, k as F_TREE_NODE_END, l as F_TREE_NODE_MIDDLE } from './utils.Lot3J_8U.js';
7
7
  import { stripVTControlCharacters } from 'node:util';
8
8
  import { positionToOffset, lineSplitRE, isPrimitive, inspect, toArray, notNullish } from '@vitest/utils';
9
9
  import { performance as performance$1 } from 'node:perf_hooks';
10
10
  import { parseErrorStacktrace, parseStacktrace } from '@vitest/utils/source-map';
11
11
  import { i as isTTY } from './env.Dq0hM4Xv.js';
12
- import { T as TypeCheckError, g as getOutputFile, h as hasFailedSnapshot } from './typechecker.C2IpOhid.js';
12
+ import { T as TypeCheckError, g as getOutputFile, h as hasFailedSnapshot } from './typechecker.CG0zmr19.js';
13
13
  import { mkdir, writeFile, readdir, stat, readFile } from 'node:fs/promises';
14
14
  import { Console } from 'node:console';
15
15
  import { Writable } from 'node:stream';
@@ -272,6 +272,9 @@ const skipErrorProperties = new Set([
272
272
  "sourceURL",
273
273
  "column",
274
274
  "line",
275
+ "fileName",
276
+ "lineNumber",
277
+ "columnNumber",
275
278
  "VITEST_TEST_NAME",
276
279
  "VITEST_TEST_PATH",
277
280
  "VITEST_AFTER_ENV_TEARDOWN",
@@ -573,6 +576,7 @@ class BaseReporter {
573
576
  if (testModule.state() === "failed") {
574
577
  this.logFailedTask(testModule.task);
575
578
  }
579
+ this.printTestModule(testModule);
576
580
  }
577
581
  logFailedTask(task) {
578
582
  if (this.ctx.config.silent === "passed-only") {
@@ -581,81 +585,102 @@ class BaseReporter {
581
585
  }
582
586
  }
583
587
  }
584
- onTaskUpdate(packs) {
585
- for (const pack of packs) {
586
- const task = this.ctx.state.idMap.get(pack[0]);
587
- if (task) {
588
- this.printTask(task);
588
+ printTestModule(testModule) {
589
+ const moduleState = testModule.state();
590
+ if (moduleState === "queued" || moduleState === "pending") {
591
+ return;
592
+ }
593
+ let testsCount = 0;
594
+ let failedCount = 0;
595
+ let skippedCount = 0;
596
+ const logs = [];
597
+ const originalLog = this.log.bind(this);
598
+ this.log = (msg) => logs.push(msg);
599
+ const visit = (suiteState, children) => {
600
+ for (const child of children) {
601
+ if (child.type === "suite") {
602
+ const suiteState = child.state();
603
+ if (!this.ctx.config.hideSkippedTests || suiteState !== "skipped") {
604
+ this.printTestSuite(child);
605
+ }
606
+ visit(suiteState, child.children);
607
+ } else {
608
+ const testResult = child.result();
609
+ testsCount++;
610
+ if (testResult.state === "failed") {
611
+ failedCount++;
612
+ } else if (testResult.state === "skipped") {
613
+ skippedCount++;
614
+ }
615
+ if (this.ctx.config.hideSkippedTests && suiteState === "skipped") {
616
+ continue;
617
+ }
618
+ this.printTestCase(moduleState, child);
619
+ }
589
620
  }
621
+ };
622
+ try {
623
+ visit(moduleState, testModule.children);
624
+ } finally {
625
+ this.log = originalLog;
626
+ }
627
+ this.log(this.getModuleLog(testModule, {
628
+ tests: testsCount,
629
+ failed: failedCount,
630
+ skipped: skippedCount
631
+ }));
632
+ logs.forEach((log) => this.log(log));
633
+ }
634
+ printTestCase(moduleState, test) {
635
+ const testResult = test.result();
636
+ const { duration, retryCount, repeatCount } = test.diagnostic() || {};
637
+ const padding = this.getTestIndentation(test.task);
638
+ let suffix = this.getDurationPrefix(test.task);
639
+ if (retryCount != null && retryCount > 0) {
640
+ suffix += c.yellow(` (retry x${retryCount})`);
641
+ }
642
+ if (repeatCount != null && repeatCount > 0) {
643
+ suffix += c.yellow(` (repeat x${repeatCount})`);
644
+ }
645
+ if (testResult.state === "failed") {
646
+ this.log(c.red(` ${padding}${taskFail} ${this.getTestName(test.task, c.dim(" > "))}`) + suffix);
647
+ testResult.errors.forEach((error) => {
648
+ const message = this.formatShortError(error);
649
+ if (message) {
650
+ this.log(c.red(` ${padding}${message}`));
651
+ }
652
+ });
653
+ } else if (duration && duration > this.ctx.config.slowTestThreshold) {
654
+ this.log(` ${padding}${c.yellow(c.dim(F_CHECK))} ${this.getTestName(test.task, c.dim(" > "))} ${suffix}`);
655
+ } else if (this.ctx.config.hideSkippedTests && testResult.state === "skipped") ; else if (testResult.state === "skipped" && testResult.note) {
656
+ this.log(` ${padding}${getStateSymbol(test.task)} ${this.getTestName(test.task, c.dim(" > "))}${c.dim(c.gray(` [${testResult.note}]`))}`);
657
+ } else if (this.renderSucceed || moduleState === "failed") {
658
+ this.log(` ${padding}${getStateSymbol(test.task)} ${this.getTestName(test.task, c.dim(" > "))}${suffix}`);
590
659
  }
591
660
  }
592
- /**
593
- * Callback invoked with a single `Task` from `onTaskUpdate`
594
- */
595
- printTask(task) {
596
- if (!("filepath" in task) || !task.result?.state || task.result?.state === "run" || task.result?.state === "queued") {
597
- return;
661
+ getModuleLog(testModule, counts) {
662
+ let state = c.dim(`${counts.tests} test${counts.tests > 1 ? "s" : ""}`);
663
+ if (counts.failed) {
664
+ state += c.dim(" | ") + c.red(`${counts.failed} failed`);
598
665
  }
599
- const suites = getSuites(task);
600
- const allTests = getTests(task);
601
- const failed = allTests.filter((t) => t.result?.state === "fail");
602
- const skipped = allTests.filter((t) => t.mode === "skip" || t.mode === "todo");
603
- let state = c.dim(`${allTests.length} test${allTests.length > 1 ? "s" : ""}`);
604
- if (failed.length) {
605
- state += c.dim(" | ") + c.red(`${failed.length} failed`);
666
+ if (counts.skipped) {
667
+ state += c.dim(" | ") + c.yellow(`${counts.skipped} skipped`);
606
668
  }
607
- if (skipped.length) {
608
- state += c.dim(" | ") + c.yellow(`${skipped.length} skipped`);
609
- }
610
- let suffix = c.dim("(") + state + c.dim(")") + this.getDurationPrefix(task);
611
- if (this.ctx.config.logHeapUsage && task.result.heap != null) {
612
- suffix += c.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
669
+ let suffix = c.dim("(") + state + c.dim(")") + this.getDurationPrefix(testModule.task);
670
+ const diagnostic = testModule.diagnostic();
671
+ if (diagnostic.heap != null) {
672
+ suffix += c.magenta(` ${Math.floor(diagnostic.heap / 1024 / 1024)} MB heap used`);
613
673
  }
614
- let title = getStateSymbol(task);
615
- if (task.meta.typecheck) {
674
+ let title = getStateSymbol(testModule.task);
675
+ if (testModule.meta().typecheck) {
616
676
  title += ` ${c.bgBlue(c.bold(" TS "))}`;
617
677
  }
618
- if (task.projectName) {
619
- title += ` ${formatProjectName(task.projectName, "")}`;
620
- }
621
- this.log(` ${title} ${task.name} ${suffix}`);
622
- for (const suite of suites) {
623
- if (this.ctx.config.hideSkippedTests && (suite.mode === "skip" || suite.result?.state === "skip")) {
624
- continue;
625
- }
626
- const tests = suite.tasks.filter((task) => task.type === "test");
627
- if (!("filepath" in suite)) {
628
- this.printSuite(suite);
629
- }
630
- for (const test of tests) {
631
- const { duration, retryCount, repeatCount } = test.result || {};
632
- const padding = this.getTestIndentation(test);
633
- let suffix = this.getDurationPrefix(test);
634
- if (retryCount != null && retryCount > 0) {
635
- suffix += c.yellow(` (retry x${retryCount})`);
636
- }
637
- if (repeatCount != null && repeatCount > 0) {
638
- suffix += c.yellow(` (repeat x${repeatCount})`);
639
- }
640
- if (test.result?.state === "fail") {
641
- this.log(c.red(` ${padding}${taskFail} ${this.getTestName(test, c.dim(" > "))}`) + suffix);
642
- test.result?.errors?.forEach((error) => {
643
- const message = this.formatShortError(error);
644
- if (message) {
645
- this.log(c.red(` ${padding}${message}`));
646
- }
647
- });
648
- } else if (duration && duration > this.ctx.config.slowTestThreshold) {
649
- this.log(` ${padding}${c.yellow(c.dim(F_CHECK))} ${this.getTestName(test, c.dim(" > "))} ${suffix}`);
650
- } else if (this.ctx.config.hideSkippedTests && (test.mode === "skip" || test.result?.state === "skip")) ; else if (test.result?.state === "skip" && test.result.note) {
651
- this.log(` ${padding}${getStateSymbol(test)} ${this.getTestName(test)}${c.dim(c.gray(` [${test.result.note}]`))}`);
652
- } else if (this.renderSucceed || failed.length > 0) {
653
- this.log(` ${padding}${getStateSymbol(test)} ${this.getTestName(test, c.dim(" > "))}${suffix}`);
654
- }
655
- }
678
+ if (testModule.project.name) {
679
+ title += ` ${formatProjectName(testModule.project.name, "")}`;
656
680
  }
681
+ return ` ${title} ${testModule.task.name} ${suffix}`;
657
682
  }
658
- printSuite(_task) {}
683
+ printTestSuite(_suite) {}
659
684
  getTestName(test, separator) {
660
685
  return getTestName(test, separator);
661
686
  }
@@ -691,7 +716,7 @@ class BaseReporter {
691
716
  }
692
717
  onWatcherRerun(files, trigger) {
693
718
  this.watchFilters = files;
694
- this.failedUnwatchedFiles = this.ctx.state.getFiles().filter((file) => !files.includes(file.filepath) && hasFailed(file));
719
+ this.failedUnwatchedFiles = this.ctx.state.getTestModules().filter((testModule) => !files.includes(testModule.task.filepath) && testModule.state() === "failed");
695
720
  files.forEach((filepath) => {
696
721
  let reruns = this._filesInWatchMode.get(filepath) ?? 0;
697
722
  this._filesInWatchMode.set(filepath, ++reruns);
@@ -713,8 +738,8 @@ class BaseReporter {
713
738
  this.log(BADGE_PADDING + c.dim(" Test name pattern: ") + c.blue(String(this.ctx.configOverride.testNamePattern)));
714
739
  }
715
740
  this.log("");
716
- for (const task of this.failedUnwatchedFiles) {
717
- this.printTask(task);
741
+ for (const testModule of this.failedUnwatchedFiles) {
742
+ this.printTestModule(testModule);
718
743
  }
719
744
  this._timeStart = formatTimeString(new Date());
720
745
  this.start = performance$1.now();
@@ -778,7 +803,7 @@ class BaseReporter {
778
803
  }
779
804
  reportTestSummary(files, errors) {
780
805
  this.log();
781
- const affectedFiles = [...this.failedUnwatchedFiles, ...files];
806
+ const affectedFiles = [...this.failedUnwatchedFiles.map((m) => m.task), ...files];
782
807
  const tests = getTests(affectedFiles);
783
808
  const snapshotOutput = renderSnapshotSummary(this.ctx.config.root, this.ctx.snapshot.summary);
784
809
  for (const [index, snapshot] of snapshotOutput.entries()) {
@@ -1409,9 +1434,9 @@ class DotReporter extends BaseReporter {
1409
1434
  this.ctx.onClose(() => this.renderer?.stop());
1410
1435
  }
1411
1436
  }
1412
- printTask(task) {
1437
+ printTestModule(testModule) {
1413
1438
  if (!this.isTTY) {
1414
- super.printTask(task);
1439
+ super.printTestModule(testModule);
1415
1440
  }
1416
1441
  }
1417
1442
  onWatcherRerun(files, trigger) {
@@ -2059,35 +2084,43 @@ class TapFlatReporter extends TapReporter {
2059
2084
  class VerboseReporter extends DefaultReporter {
2060
2085
  verbose = true;
2061
2086
  renderSucceed = true;
2062
- printTask(task) {
2087
+ printTestModule(module) {
2063
2088
  if (this.isTTY) {
2064
- return super.printTask(task);
2089
+ return super.printTestModule(module);
2065
2090
  }
2066
- if (task.type !== "test" || !task.result?.state || task.result?.state === "run" || task.result?.state === "queued") {
2091
+ }
2092
+ onTestCaseResult(test) {
2093
+ super.onTestCaseResult(test);
2094
+ if (this.isTTY) {
2067
2095
  return;
2068
2096
  }
2069
- let title = ` ${getStateSymbol(task)} `;
2070
- if (task.file.projectName) {
2071
- title += formatProjectName(task.file.projectName);
2097
+ const testResult = test.result();
2098
+ if (this.ctx.config.hideSkippedTests && testResult.state === "skipped") {
2099
+ return;
2072
2100
  }
2073
- title += getFullName(task, c.dim(" > "));
2074
- title += super.getDurationPrefix(task);
2075
- if (this.ctx.config.logHeapUsage && task.result.heap != null) {
2076
- title += c.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
2101
+ let title = ` ${getStateSymbol(test.task)} `;
2102
+ if (test.project.name) {
2103
+ title += formatProjectName(test.project.name);
2077
2104
  }
2078
- if (task.result?.note) {
2079
- title += c.dim(c.gray(` [${task.result.note}]`));
2105
+ title += getFullName(test.task, c.dim(" > "));
2106
+ title += this.getDurationPrefix(test.task);
2107
+ const diagnostic = test.diagnostic();
2108
+ if (diagnostic?.heap != null) {
2109
+ title += c.magenta(` ${Math.floor(diagnostic.heap / 1024 / 1024)} MB heap used`);
2080
2110
  }
2081
- this.ctx.logger.log(title);
2082
- if (task.result.state === "fail") {
2083
- task.result.errors?.forEach((error) => this.log(c.red(` ${F_RIGHT} ${error?.message}`)));
2111
+ if (testResult.state === "skipped" && testResult.note) {
2112
+ title += c.dim(c.gray(` [${testResult.note}]`));
2113
+ }
2114
+ this.log(title);
2115
+ if (testResult.state === "failed") {
2116
+ testResult.errors.forEach((error) => this.log(c.red(` ${F_RIGHT} ${error?.message}`)));
2084
2117
  }
2085
2118
  }
2086
- printSuite(task) {
2087
- const indentation = " ".repeat(getIndentation(task));
2088
- const tests = getTests(task);
2089
- const state = getStateSymbol(task);
2090
- this.log(` ${indentation}${state} ${task.name} ${c.dim(`(${tests.length})`)}`);
2119
+ printTestSuite(testSuite) {
2120
+ const indentation = " ".repeat(getIndentation(testSuite.task));
2121
+ const tests = Array.from(testSuite.children.allTests());
2122
+ const state = getStateSymbol(testSuite.task);
2123
+ this.log(` ${indentation}${state} ${testSuite.name} ${c.dim(`(${tests.length})`)}`);
2091
2124
  }
2092
2125
  getTestName(test) {
2093
2126
  return test.name;
@@ -2316,16 +2349,23 @@ class BenchmarkReporter extends DefaultReporter {
2316
2349
  });
2317
2350
  }
2318
2351
  }
2319
- super.onTaskUpdate(packs);
2320
2352
  }
2321
- printTask(task) {
2322
- if (task?.type !== "suite" || !task.result?.state || task.result?.state === "run" || task.result?.state === "queued") {
2353
+ onTestSuiteResult(testSuite) {
2354
+ super.onTestSuiteResult(testSuite);
2355
+ this.printSuiteTable(testSuite);
2356
+ }
2357
+ printTestModule(testModule) {
2358
+ this.printSuiteTable(testModule);
2359
+ }
2360
+ printSuiteTable(testTask) {
2361
+ const state = testTask.state();
2362
+ if (state === "pending" || state === "queued") {
2323
2363
  return;
2324
2364
  }
2325
- const benches = task.tasks.filter((t) => t.meta.benchmark);
2326
- const duration = task.result.duration;
2365
+ const benches = testTask.task.tasks.filter((t) => t.meta.benchmark);
2366
+ const duration = testTask.task.result?.duration || 0;
2327
2367
  if (benches.length > 0 && benches.every((t) => t.result?.state !== "run" && t.result?.state !== "queued")) {
2328
- let title = `\n ${getStateSymbol(task)} ${formatProjectName(task.file.projectName)}${getFullName(task, c.dim(" > "))}`;
2368
+ let title = `\n ${getStateSymbol(testTask.task)} ${formatProjectName(testTask.project.name)}${getFullName(testTask.task, c.dim(" > "))}`;
2329
2369
  if (duration != null && duration > this.ctx.config.slowTestThreshold) {
2330
2370
  title += c.yellow(` ${Math.round(duration)}${c.dim("ms")}`);
2331
2371
  }
@@ -1,9 +1,10 @@
1
- import { Task, Suite, File, TaskMeta, TaskResultPack, SequenceSetupFiles, SequenceHooks, CancelReason } from '@vitest/runner';
1
+ import { Task, TaskMeta, Suite, File, TaskResultPack, SequenceSetupFiles, SequenceHooks, CancelReason } from '@vitest/runner';
2
2
  import { b as Awaitable, U as UserConsoleLog, c as Arrayable$1, A as AfterSuiteRunMeta, f as EnvironmentOptions, P as ProvidedContext } from './environment.d.C8UItCbf.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
+ import { MockedModule } from '@vitest/mocker';
7
8
  import { StackTraceParserOptions } from '@vitest/utils/source-map';
8
9
  import { a as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.DevWltVl.js';
9
10
  import { PrettyFormatOptions } from '@vitest/pretty-format';
@@ -93,6 +94,10 @@ declare class ReportedTaskImplementation {
93
94
  * If the test is not finished yet or was skipped, it will return `true`.
94
95
  */
95
96
  ok(): boolean;
97
+ /**
98
+ * Custom metadata that was attached to the test during its execution.
99
+ */
100
+ meta(): TaskMeta;
96
101
  }
97
102
  declare class TestCase extends ReportedTaskImplementation {
98
103
  #private;
@@ -126,10 +131,6 @@ declare class TestCase extends ReportedTaskImplementation {
126
131
  */
127
132
  result(): TestResult;
128
133
  /**
129
- * Custom metadata that was attached to the test during its execution.
130
- */
131
- meta(): TaskMeta;
132
- /**
133
134
  * Useful information about the test like duration, memory usage, etc.
134
135
  * Diagnostic is only available after the test has finished.
135
136
  */
@@ -211,6 +212,10 @@ declare class TestSuite extends SuiteImplementation {
211
212
  */
212
213
  ok: () => boolean;
213
214
  /**
215
+ * The meta information attached to the suite during its collection or execution.
216
+ */
217
+ meta: () => TaskMeta;
218
+ /**
214
219
  * Checks the running state of the suite.
215
220
  */
216
221
  state(): TestSuiteState;
@@ -238,6 +243,10 @@ declare class TestModule extends SuiteImplementation {
238
243
  */
239
244
  ok: () => boolean;
240
245
  /**
246
+ * The meta information attached to the module during its collection or execution.
247
+ */
248
+ meta: () => TaskMeta;
249
+ /**
241
250
  * Useful information about the module like duration, memory usage, etc.
242
251
  * If the module was not executed yet, all diagnostic values will return `0`.
243
252
  */
@@ -357,6 +366,11 @@ interface ModuleDiagnostic {
357
366
  * Accumulated duration of all tests and hooks in the module.
358
367
  */
359
368
  readonly duration: number;
369
+ /**
370
+ * The amount of memory used by the test module in bytes.
371
+ * This value is only available if the test was executed with `logHeapUsage` flag.
372
+ */
373
+ readonly heap: number | undefined;
360
374
  }
361
375
 
362
376
  type BuiltinPool = "browser" | "threads" | "forks" | "vmThreads" | "vmForks" | "typescript";
@@ -626,7 +640,7 @@ declare abstract class BaseReporter implements Reporter {
626
640
  start: number;
627
641
  end: number;
628
642
  watchFilters?: string[];
629
- failedUnwatchedFiles: Task[];
643
+ failedUnwatchedFiles: TestModule[];
630
644
  isTTY: boolean;
631
645
  ctx: Vitest;
632
646
  renderSucceed: boolean;
@@ -643,12 +657,10 @@ declare abstract class BaseReporter implements Reporter {
643
657
  onTestSuiteResult(testSuite: TestSuite): void;
644
658
  onTestModuleEnd(testModule: TestModule): void;
645
659
  private logFailedTask;
646
- onTaskUpdate(packs: TaskResultPack[]): void;
647
- /**
648
- * Callback invoked with a single `Task` from `onTaskUpdate`
649
- */
650
- protected printTask(task: Task): void;
651
- protected printSuite(_task: Task): void;
660
+ protected printTestModule(testModule: TestModule): void;
661
+ protected printTestCase(moduleState: TestModuleState, test: TestCase): void;
662
+ private getModuleLog;
663
+ protected printTestSuite(_suite: TestSuite): void;
652
664
  protected getTestName(test: Task, separator?: string): string;
653
665
  protected formatShortError(error: ErrorWithDiff): string;
654
666
  protected getTestIndentation(_test: Task): string;
@@ -915,7 +927,7 @@ declare class DotReporter extends BaseReporter {
915
927
  private tests;
916
928
  private finishedTests;
917
929
  onInit(ctx: Vitest): void;
918
- printTask(task: Task): void;
930
+ printTestModule(testModule: TestModule): void;
919
931
  onWatcherRerun(files: string[], trigger?: string): void;
920
932
  onFinished(files?: File[], errors?: unknown[]): void;
921
933
  onTestModuleCollected(module: TestModule): void;
@@ -955,8 +967,9 @@ declare class TapFlatReporter extends TapReporter {
955
967
  declare class VerboseReporter extends DefaultReporter {
956
968
  protected verbose: boolean;
957
969
  renderSucceed: boolean;
958
- printTask(task: Task): void;
959
- protected printSuite(task: Task): void;
970
+ printTestModule(module: TestModule): void;
971
+ onTestCaseResult(test: TestCase): void;
972
+ protected printTestSuite(testSuite: TestSuite): void;
960
973
  protected getTestName(test: Task): string;
961
974
  protected getTestIndentation(test: Task): string;
962
975
  protected formatShortError(): string;
@@ -980,7 +993,9 @@ declare class BenchmarkReporter extends DefaultReporter {
980
993
  compare?: Parameters<typeof renderTable>[0]["compare"];
981
994
  onInit(ctx: Vitest): Promise<void>;
982
995
  onTaskUpdate(packs: TaskResultPack[]): void;
983
- printTask(task: Task): void;
996
+ onTestSuiteResult(testSuite: TestSuite): void;
997
+ protected printTestModule(testModule: TestModule): void;
998
+ private printSuiteTable;
984
999
  onFinished(files?: File[], errors?: unknown[]): Promise<void>;
985
1000
  }
986
1001
 
@@ -2260,8 +2275,14 @@ interface CDPSession {
2260
2275
  once: (event: string, listener: (...args: unknown[]) => void) => void;
2261
2276
  off: (event: string, listener: (...args: unknown[]) => void) => void;
2262
2277
  }
2278
+ interface BrowserModuleMocker {
2279
+ register: (sessionId: string, module: MockedModule) => Promise<void>;
2280
+ delete: (sessionId: string, url: string) => Promise<void>;
2281
+ clear: (sessionId: string) => Promise<void>;
2282
+ }
2263
2283
  interface BrowserProvider {
2264
2284
  name: string;
2285
+ mocker?: BrowserModuleMocker;
2265
2286
  /**
2266
2287
  * @experimental opt-in into file parallelisation
2267
2288
  */
@@ -2611,7 +2632,6 @@ declare class TestProject {
2611
2632
  private isInSourceTestCode;
2612
2633
  private filterFiles;
2613
2634
  private _parentBrowser?;
2614
- private _parent?;
2615
2635
  /**
2616
2636
  * Closes the project and all associated resources. This can only be called once; the closing promise is cached until the server restarts.
2617
2637
  * If the resources are needed again, create a new project.
@@ -3020,4 +3040,5 @@ declare class Vitest {
3020
3040
  type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
3021
3041
  type OnTestsRerunHandler = (testFiles: TestSpecification[]) => Promise<void> | void;
3022
3042
 
3023
- export { type JsonOptions$1 as $, type ApiConfig as A, type BaseCoverageOptions as B, CoverageMap as C, type DepsOptimizationOptions as D, type BenchmarkUserOptions as E, type VitestOptions as F, type TestSequencer as G, TestSpecification as H, type InlineConfig as I, TestModule as J, type OnTestsRerunHandler as K, Logger as L, type ModuleDiagnostic as M, VitestPackageInstaller as N, type OnServerRestartHandler as O, type Pool as P, type ProcessPool as Q, type ResolvedCoverageOptions as R, type SerializedTestSpecification as S, TestProject as T, type UserWorkspaceConfig as U, Vitest as V, type WorkspaceProjectConfiguration as W, type WorkspaceSpec as X, getFilePoolName as Y, type SerializedTestProject as Z, type HTMLOptions as _, type ReportContext as a, type JUnitOptions as a0, type TaskOptions as a1, TestCase as a2, TestCollection as a3, type TestDiagnostic as a4, type TestModuleState as a5, type TestResult as a6, type TestResultFailed as a7, type TestResultPassed as a8, type TestResultSkipped as a9, BenchmarkReporter as aA, BenchmarkReportsMap as aB, DefaultReporter as aC, DotReporter as aD, GithubActionsReporter as aE, HangingProcessReporter as aF, JsonReporter as aG, JUnitReporter as aH, ReportersMap as aI, TapFlatReporter as aJ, TapReporter as aK, VerboseBenchmarkReporter as aL, VerboseReporter as aM, BaseReporter as aN, type BenchmarkBuiltinReporters as aO, type BuiltinReporterOptions as aP, type BuiltinReporters as aQ, type JsonAssertionResult as aR, type JsonTestResult as aS, type JsonTestResults as aT, type TestState as aa, TestSuite as ab, type TestSuiteState as ac, type TestSequencerConstructor as ad, type BrowserBuiltinProvider as ae, type BrowserCommand as af, type BrowserCommandContext as ag, type BrowserInstanceOption as ah, type BrowserOrchestrator as ai, type BrowserProvider as aj, type BrowserProviderInitializationOptions as ak, type BrowserProviderModule as al, type BrowserProviderOptions as am, type BrowserServerState as an, type BrowserServerStateSession as ao, type CDPSession as ap, type ParentProjectBrowser as aq, type ProjectBrowser as ar, type ResolvedBrowserOptions as as, type ResolvedProjectConfig as at, type ResolveSnapshotPathHandler as au, type ResolveSnapshotPathHandlerContext as av, type TestRunResult as aw, type ReportedHookContext as ax, type TestRunEndReason as ay, BasicReporter as az, type TestProjectConfiguration as b, type CoverageV8Options as c, type UserProjectConfigFn as d, type UserProjectConfigExport as e, type TestProjectInlineConfiguration as f, type CoverageProvider as g, type CoverageProviderModule as h, type CoverageReporter as i, type CoverageProviderName as j, type CoverageOptions as k, type CoverageIstanbulOptions as l, type CustomProviderOptions as m, type Reporter as n, type BrowserScript as o, type BrowserConfigOptions as p, type BuiltinEnvironment as q, type VitestEnvironment as r, type PoolOptions as s, type CSSModuleScopeStrategy as t, type VitestRunMode as u, type TransformModePatterns as v, type TypecheckConfig as w, type UserConfig as x, type ResolvedConfig as y, type ProjectConfig as z };
3043
+ export { CoverageMap as C, TestSpecification as H, TestModule as J, Logger as L, VitestPackageInstaller as N, TestProject as T, Vitest as V, getFilePoolName as Y, TestCase as a2, TestCollection as a3, BasicReporter as aA, BenchmarkReporter as aB, BenchmarkReportsMap as aC, DefaultReporter as aD, DotReporter as aE, GithubActionsReporter as aF, HangingProcessReporter as aG, JsonReporter as aH, JUnitReporter as aI, ReportersMap as aJ, TapFlatReporter as aK, TapReporter as aL, VerboseBenchmarkReporter as aM, VerboseReporter as aN, BaseReporter as aO, TestSuite as ab };
3044
+ export type { JsonOptions$1 as $, ApiConfig as A, BaseCoverageOptions as B, DepsOptimizationOptions as D, BenchmarkUserOptions as E, VitestOptions as F, TestSequencer as G, InlineConfig as I, OnTestsRerunHandler as K, ModuleDiagnostic as M, OnServerRestartHandler as O, Pool as P, ProcessPool as Q, ResolvedCoverageOptions as R, SerializedTestSpecification as S, UserWorkspaceConfig as U, WorkspaceProjectConfiguration as W, WorkspaceSpec as X, SerializedTestProject as Z, HTMLOptions as _, ReportContext as a, JUnitOptions as a0, TaskOptions as a1, TestDiagnostic as a4, TestModuleState as a5, TestResult as a6, TestResultFailed as a7, TestResultPassed as a8, TestResultSkipped as a9, BenchmarkBuiltinReporters as aP, BuiltinReporterOptions as aQ, BuiltinReporters as aR, JsonAssertionResult as aS, JsonTestResult as aT, JsonTestResults as aU, TestState as aa, TestSuiteState as ac, TestSequencerConstructor as ad, BrowserBuiltinProvider as ae, BrowserCommand as af, BrowserCommandContext as ag, BrowserInstanceOption as ah, BrowserModuleMocker as ai, BrowserOrchestrator as aj, BrowserProvider as ak, BrowserProviderInitializationOptions as al, BrowserProviderModule as am, BrowserProviderOptions as an, BrowserServerState as ao, BrowserServerStateSession as ap, CDPSession as aq, ParentProjectBrowser as ar, ProjectBrowser as as, ResolvedBrowserOptions as at, ResolvedProjectConfig as au, ResolveSnapshotPathHandler as av, ResolveSnapshotPathHandlerContext as aw, TestRunResult as ax, ReportedHookContext as ay, TestRunEndReason 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 };
@@ -34,12 +34,12 @@ function convertTasksToEvents(file, onTask) {
34
34
  visit(task);
35
35
  } else {
36
36
  onTask?.(task);
37
- packs.push([
38
- task.id,
39
- task.result,
40
- task.meta
41
- ]);
42
- if (task.mode !== "skip" && task.mode !== "todo") {
37
+ if (suite.mode !== "skip" && suite.mode !== "todo") {
38
+ packs.push([
39
+ task.id,
40
+ task.result,
41
+ task.meta
42
+ ]);
43
43
  events.push([task.id, "test-prepare"], [task.id, "test-finished"]);
44
44
  }
45
45
  }
@@ -191,4 +191,4 @@ var utils = /*#__PURE__*/Object.freeze({
191
191
  withLabel: withLabel
192
192
  });
193
193
 
194
- export { F_POINTER as F, formatProjectName as a, taskFail as b, F_CHECK as c, divider as d, F_RIGHT as e, formatTimeString as f, getStateSymbol as g, getStateString as h, formatTime as i, countTestErrors as j, F_TREE_NODE_END as k, F_TREE_NODE_MIDDLE as l, padSummaryTitle as p, renderSnapshotSummary as r, truncateString as t, utils as u, withLabel as w };
194
+ export { F_POINTER as F, taskFail as a, F_CHECK as b, formatProjectName as c, divider as d, F_RIGHT as e, formatTimeString as f, getStateSymbol as g, getStateString as h, formatTime as i, countTestErrors as j, F_TREE_NODE_END as k, F_TREE_NODE_MIDDLE as l, padSummaryTitle as p, renderSnapshotSummary as r, truncateString as t, utils as u, withLabel as w };
@@ -1,5 +1,5 @@
1
1
  import { HookHandler } from 'vite';
2
- import { V as Vitest, T as TestProject, b as TestProjectConfiguration, I as InlineConfig } from './reporters.d.5g6jXhoW.js';
2
+ import { V as Vitest, T as TestProject, b as TestProjectConfiguration, I as InlineConfig } from './reporters.d.CfRkRKN2.js';
3
3
 
4
4
  interface VitestPluginContext {
5
5
  vitest: Vitest;