vitest 4.0.0-beta.10 → 4.0.0-beta.11

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 (61) hide show
  1. package/LICENSE.md +81 -0
  2. package/dist/browser.d.ts +9 -5
  3. package/dist/browser.js +8 -5
  4. package/dist/chunks/{benchmark.CJUa-Hsa.js → benchmark.LXhJ0F0X.js} +2 -2
  5. package/dist/chunks/{browser.d.yFAklsD1.d.ts → browser.d.Dx7DO_Ce.d.ts} +1 -1
  6. package/dist/chunks/{cac.DCxo_nSu.js → cac.elvK37c9.js} +8 -8
  7. package/dist/chunks/{cli-api.BJJXh9BV.js → cli-api.C7plPyhs.js} +64 -34
  8. package/dist/chunks/{console.7h5kHUIf.js → console.CiTi59Jy.js} +2 -2
  9. package/dist/chunks/{coverage.BCU-r2QL.js → coverage.CG6Uhorw.js} +14 -18
  10. package/dist/chunks/{globals.DG-S3xFe.js → globals.BjvYA-AD.js} +7 -5
  11. package/dist/chunks/{index.CMfqw92x.js → index.AZOjjqWP.js} +2 -2
  12. package/dist/chunks/{index.BjKEiSn0.js → index.BhY64fF0.js} +3 -3
  13. package/dist/chunks/{index.BIP7prJq.js → index.BwBttQPf.js} +67 -71
  14. package/dist/chunks/{moduleRunner.d.D9nBoC4p.d.ts → moduleRunner.d.BNa-CL9e.d.ts} +1 -1
  15. package/dist/chunks/{node.CyipiPvJ.js → node.BsdMi6DV.js} +2 -2
  16. package/dist/chunks/{plugin.d.BMVSnsGV.d.ts → plugin.d.C5phQR6o.d.ts} +1 -1
  17. package/dist/chunks/{reporters.d.BUWjmRYq.d.ts → reporters.d.CVzhsTvK.d.ts} +16 -11
  18. package/dist/chunks/{resolveSnapshotEnvironment.Bkht6Yor.js → resolveSnapshotEnvironment.DQVamkje.js} +5 -5
  19. package/dist/chunks/{rpc.BKr6mtxz.js → rpc.jKGRSXIH.js} +2 -2
  20. package/dist/chunks/{setup-common.uiMcU3cv.js → setup-common.NAWRuMRP.js} +3 -3
  21. package/dist/chunks/{startModuleRunner.p67gbNo9.js → startModuleRunner.oAuCu1yL.js} +27 -10
  22. package/dist/chunks/{test.BiqSKISg.js → test.KC5tH8hC.js} +6 -6
  23. package/dist/chunks/{typechecker.DB-fIMaH.js → typechecker.gXq-5P3n.js} +640 -7
  24. package/dist/chunks/{utils.D2R2NiOH.js → utils.DGKhod2J.js} +1 -1
  25. package/dist/chunks/{vi.ZPgvtBao.js → vi.CiJ0Laa6.js} +4 -2
  26. package/dist/chunks/{worker.d.BDsXGkwh.d.ts → worker.d.B_Fd9M_w.d.ts} +1 -76
  27. package/dist/{worker.js → chunks/worker.rPGLlbkW.js} +65 -32
  28. package/dist/cli.js +7 -5
  29. package/dist/config.d.ts +5 -5
  30. package/dist/coverage.d.ts +3 -3
  31. package/dist/coverage.js +3 -4
  32. package/dist/index.d.ts +4 -4
  33. package/dist/index.js +7 -5
  34. package/dist/module-evaluator.d.ts +2 -2
  35. package/dist/module-evaluator.js +1 -1
  36. package/dist/module-runner.js +5 -5
  37. package/dist/node.d.ts +12 -9
  38. package/dist/node.js +16 -12
  39. package/dist/reporters.d.ts +3 -3
  40. package/dist/reporters.js +7 -5
  41. package/dist/runners.js +8 -6
  42. package/dist/snapshot.js +3 -3
  43. package/dist/suite.js +4 -3
  44. package/dist/{chunks/base.Cjha6usc.js → worker-base.js} +88 -14
  45. package/dist/{chunks/vm.Ca0Y0W5f.js → worker-vm.js} +69 -8
  46. package/dist/workers/runVmTests.js +12 -9
  47. package/package.json +20 -19
  48. package/browser.d.ts +0 -1
  49. package/dist/chunks/moduleTransport.I-bgQy0S.js +0 -19
  50. package/dist/chunks/resolver.Bx6lE0iq.js +0 -119
  51. package/dist/chunks/utils.C2YI6McM.js +0 -52
  52. package/dist/chunks/worker.d.BNcX_2mH.d.ts +0 -8
  53. package/dist/workers/forks.js +0 -67
  54. package/dist/workers/threads.js +0 -55
  55. package/dist/workers/vmForks.js +0 -48
  56. package/dist/workers/vmThreads.js +0 -38
  57. package/dist/workers.d.ts +0 -38
  58. package/dist/workers.js +0 -48
  59. package/execute.d.ts +0 -1
  60. package/utils.d.ts +0 -1
  61. package/workers.d.ts +0 -1
@@ -1,16 +1,18 @@
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.DB-fIMaH.js';
4
+ import { g as getOutputFile, h as hasFailedSnapshot, T as TypeCheckError } from './typechecker.gXq-5P3n.js';
5
5
  import { performance as performance$1 } from 'node:perf_hooks';
6
- import { getTestName, getFullName, hasFailed, getTests, getSuites, getTasks } from '@vitest/runner/utils';
7
- import { slash, toArray, isPrimitive, inspect, positionToOffset, lineSplitRE } from '@vitest/utils';
6
+ import { getTestName, hasFailed, getTests, getSuites, getTasks, getFullName } from '@vitest/runner/utils';
7
+ import { slash, toArray, isPrimitive } from '@vitest/utils/helpers';
8
8
  import { parseStacktrace, parseErrorStacktrace, defaultStackIgnorePatterns } from '@vitest/utils/source-map';
9
9
  import c from 'tinyrainbow';
10
10
  import { i as isTTY } from './env.D4Lgay0q.js';
11
11
  import { stripVTControlCharacters } from 'node:util';
12
12
  import { Console } from 'node:console';
13
13
  import { Writable } from 'node:stream';
14
+ import { inspect } from '@vitest/utils/display';
15
+ import { positionToOffset, lineSplitRE } from '@vitest/utils/offset';
14
16
  import { createRequire } from 'node:module';
15
17
  import { hostname } from 'node:os';
16
18
 
@@ -232,6 +234,7 @@ const testPass = c.green(F_CHECK);
232
234
  const taskFail = c.red(F_CROSS);
233
235
  const suiteFail = c.red(F_POINTER);
234
236
  const pending$1 = c.gray("·");
237
+ const separator = c.dim(" > ");
235
238
  const labelDefaultColors = [
236
239
  c.bgYellow,
237
240
  c.bgCyan,
@@ -351,6 +354,7 @@ var utils = /*#__PURE__*/Object.freeze({
351
354
  pending: pending$1,
352
355
  pointer: pointer,
353
356
  renderSnapshotSummary: renderSnapshotSummary,
357
+ separator: separator,
354
358
  skipped: skipped,
355
359
  suiteFail: suiteFail,
356
360
  taskFail: taskFail,
@@ -440,19 +444,10 @@ class BaseReporter {
440
444
  })), logs.forEach((log) => this.log(log));
441
445
  }
442
446
  printTestCase(moduleState, test) {
443
- const testResult = test.result(), { duration, retryCount, repeatCount } = test.diagnostic() || {}, padding = this.getTestIndentation(test.task);
444
- let suffix = this.getDurationPrefix(test.task);
445
- if (retryCount != null && retryCount > 0) suffix += c.yellow(` (retry x${retryCount})`);
446
- if (repeatCount != null && repeatCount > 0) suffix += c.yellow(` (repeat x${repeatCount})`);
447
- if (testResult.state === "failed")
448
- // print short errors, full errors will be at the end in summary
449
- this.log(c.red(` ${padding}${taskFail} ${this.getTestName(test.task, c.dim(" > "))}`) + suffix), testResult.errors.forEach((error) => {
450
- const message = this.formatShortError(error);
451
- if (message) this.log(c.red(` ${padding}${message}`));
452
- });
453
- else if (duration && duration > this.ctx.config.slowTestThreshold) this.log(` ${padding}${c.yellow(c.dim(F_CHECK))} ${this.getTestName(test.task, c.dim(" > "))} ${suffix}`);
454
- else if (this.ctx.config.hideSkippedTests && testResult.state === "skipped") ; else if (testResult.state === "skipped" && testResult.note) this.log(` ${padding}${getStateSymbol(test.task)} ${this.getTestName(test.task, c.dim(" > "))}${c.dim(c.gray(` [${testResult.note}]`))}`);
455
- else if (this.renderSucceed || moduleState === "failed") this.log(` ${padding}${getStateSymbol(test.task)} ${this.getTestName(test.task, c.dim(" > "))}${suffix}`);
447
+ const testResult = test.result(), { duration = 0 } = test.diagnostic() || {}, padding = this.getTestIndentation(test.task), suffix = this.getTestCaseSuffix(test);
448
+ if (testResult.state === "failed") this.log(c.red(` ${padding}${taskFail} ${this.getTestName(test.task, separator)}`) + suffix);
449
+ else if (duration > this.ctx.config.slowTestThreshold) this.log(` ${padding}${c.yellow(c.dim(F_CHECK))} ${this.getTestName(test.task, separator)} ${suffix}`);
450
+ else if (this.ctx.config.hideSkippedTests && testResult.state === "skipped") ; else if (this.renderSucceed || moduleState === "failed") this.log(` ${padding}${this.getStateSymbol(test)} ${this.getTestName(test.task, separator)}${suffix}`);
456
451
  }
457
452
  getModuleLog(testModule, counts) {
458
453
  let state = c.dim(`${counts.tests} test${counts.tests > 1 ? "s" : ""}`);
@@ -461,25 +456,25 @@ class BaseReporter {
461
456
  let suffix = c.dim("(") + state + c.dim(")") + this.getDurationPrefix(testModule.task);
462
457
  const diagnostic = testModule.diagnostic();
463
458
  if (diagnostic.heap != null) suffix += c.magenta(` ${Math.floor(diagnostic.heap / 1024 / 1024)} MB heap used`);
464
- let title = getStateSymbol(testModule.task);
465
- if (testModule.meta().typecheck) title += ` ${c.bgBlue(c.bold(" TS "))}`;
466
- if (testModule.project.name) title += ` ${formatProjectName(testModule.project, "")}`;
459
+ const title = this.getEntityPrefix(testModule);
467
460
  return ` ${title} ${testModule.task.name} ${suffix}`;
468
461
  }
469
- printTestSuite(_suite) {
470
- // Suite name is included in getTestName by default
462
+ printTestSuite(testSuite) {
463
+ if (!this.renderSucceed) return;
464
+ const indentation = " ".repeat(getIndentation(testSuite.task)), tests = Array.from(testSuite.children.allTests()), state = this.getStateSymbol(testSuite);
465
+ this.log(` ${indentation}${state} ${testSuite.name} ${c.dim(`(${tests.length})`)}`);
471
466
  }
472
- getTestName(test, separator) {
473
- return getTestName(test, separator);
467
+ getTestName(test, _separator) {
468
+ return test.name;
474
469
  }
475
470
  getFullName(test, separator) {
476
- return getFullName(test, separator);
477
- }
478
- formatShortError(error) {
479
- return `${F_RIGHT} ${error.message}`;
471
+ if (test === test.file) return test.name;
472
+ let name = test.file.name;
473
+ if (test.location) name += c.dim(`:${test.location.line}:${test.location.column}`);
474
+ return name += separator, name += getTestName(test, separator), name;
480
475
  }
481
- getTestIndentation(_test) {
482
- return " ";
476
+ getTestIndentation(test) {
477
+ return " ".repeat(getIndentation(test));
483
478
  }
484
479
  printAnnotations(test, console, padding = 0) {
485
480
  const annotations = test.annotations();
@@ -493,10 +488,29 @@ class BaseReporter {
493
488
  this[console](`${PADDING} ${c.blue(F_DOWN_RIGHT)} ${message}`);
494
489
  });
495
490
  }
491
+ getEntityPrefix(entity) {
492
+ let title = this.getStateSymbol(entity);
493
+ if (entity.project.name) title += ` ${formatProjectName(entity.project, "")}`;
494
+ if (entity.meta().typecheck) title += ` ${c.bgBlue(c.bold(" TS "))}`;
495
+ return title;
496
+ }
497
+ getTestCaseSuffix(testCase) {
498
+ const { heap, retryCount, repeatCount } = testCase.diagnostic() || {}, testResult = testCase.result();
499
+ let suffix = this.getDurationPrefix(testCase.task);
500
+ if (retryCount != null && retryCount > 0) suffix += c.yellow(` (retry x${retryCount})`);
501
+ if (repeatCount != null && repeatCount > 0) suffix += c.yellow(` (repeat x${repeatCount})`);
502
+ if (heap != null) suffix += c.magenta(` ${Math.floor(heap / 1024 / 1024)} MB heap used`);
503
+ if (testResult.state === "skipped" && testResult.note) suffix += c.dim(c.gray(` [${testResult.note}]`));
504
+ return suffix;
505
+ }
506
+ getStateSymbol(test) {
507
+ return getStateSymbol(test.task);
508
+ }
496
509
  getDurationPrefix(task) {
497
- if (!task.result?.duration) return "";
498
- const color = task.result.duration > this.ctx.config.slowTestThreshold ? c.yellow : c.green;
499
- return color(` ${Math.round(task.result.duration)}${c.dim("ms")}`);
510
+ const duration = task.result?.duration && Math.round(task.result?.duration);
511
+ if (duration == null) return "";
512
+ const color = duration > this.ctx.config.slowTestThreshold ? c.yellow : c.green;
513
+ return color(` ${duration}${c.dim("ms")}`);
500
514
  }
501
515
  onWatcherStart(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
502
516
  const failed = errors.length > 0 || hasFailed(files);
@@ -531,7 +545,7 @@ class BaseReporter {
531
545
  const output = log.type === "stdout" ? this.ctx.logger.outputStream : this.ctx.logger.errorStream, write = (msg) => output.write(msg);
532
546
  let headerText = "unknown test";
533
547
  const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : void 0;
534
- if (task) headerText = this.getFullName(task, c.dim(" > "));
548
+ if (task) headerText = this.getFullName(task, separator);
535
549
  else if (log.taskId && log.taskId !== "__vitest__unknown_test__") headerText = log.taskId;
536
550
  if (write(c.gray(log.type + c.dim(` | ${headerText}\n`)) + log.content), log.origin) {
537
551
  // browser logs don't have an extra end of line at the end like Node.js does
@@ -551,7 +565,7 @@ class BaseReporter {
551
565
  if (this.ctx.config.silent === true || this.ctx.config.silent === "passed-only" && taskState !== "failed") return false;
552
566
  if (this.ctx.config.onConsoleLog) {
553
567
  const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : void 0, entity = task && this.ctx.state.getReportedEntity(task), shouldLog = this.ctx.config.onConsoleLog(log.content, log.type, entity);
554
- if (shouldLog === false) return shouldLog;
568
+ if (shouldLog === false) return false;
555
569
  }
556
570
  return true;
557
571
  }
@@ -606,7 +620,7 @@ class BaseReporter {
606
620
  for (const bench of topBenches) {
607
621
  const group = bench.suite || bench.file;
608
622
  if (!group) continue;
609
- const groupName = this.getFullName(group, c.dim(" > ")), project = this.ctx.projects.find((p) => p.name === bench.file.projectName);
623
+ const groupName = this.getFullName(group, separator), project = this.ctx.projects.find((p) => p.name === bench.file.projectName);
610
624
  this.log(` ${formatProjectName(project)}${bench.name}${c.dim(` - ${groupName}`)}`);
611
625
  const siblings = group.tasks.filter((i) => i.meta.benchmark && i.result?.benchmark && i !== bench).sort((a, b) => a.result.benchmark.rank - b.result.benchmark.rank);
612
626
  for (const sibling of siblings) {
@@ -633,7 +647,7 @@ class BaseReporter {
633
647
  for (const [error, tasks] of errorsQueue) {
634
648
  for (const task of tasks) {
635
649
  const filepath = task?.filepath || "", projectName = task?.projectName || task.file?.projectName || "", project = this.ctx.projects.find((p) => p.name === projectName);
636
- let name = this.getFullName(task, c.dim(" > "));
650
+ let name = this.getFullName(task, separator);
637
651
  if (filepath) name += c.dim(` [ ${this.relative(filepath)} ]`);
638
652
  this.ctx.logger.error(`${c.bgRed(c.bold(" FAIL "))} ${formatProjectName(project)}${name}`);
639
653
  }
@@ -664,6 +678,9 @@ function sum(items, cb) {
664
678
  return total + Math.max(cb(next) || 0, 0);
665
679
  }, 0);
666
680
  }
681
+ function getIndentation(suite, level = 1) {
682
+ return suite.suite && !("filepath" in suite.suite) ? getIndentation(suite.suite, level + 1) : level;
683
+ }
667
684
 
668
685
  const DEFAULT_RENDER_INTERVAL_MS = 1e3, ESC = "\x1B[", CLEAR_LINE = `${ESC}K`, MOVE_CURSOR_ONE_ROW_UP = `${ESC}1A`, SYNC_START = `${ESC}?2026h`, SYNC_END = `${ESC}?2026l`;
669
686
  /**
@@ -1252,7 +1269,7 @@ function handleImportOutsideModuleError(stack, logger) {
1252
1269
  if (!esmErrors.some((e) => stack.includes(e))) return;
1253
1270
  const path = normalize(stack.split("\n")[0].trim());
1254
1271
  let name = path.split("/node_modules/").pop() || "";
1255
- if (name?.startsWith("@")) name = name.split("/").slice(0, 2).join("/");
1272
+ if (name[0] === "@") name = name.split("/").slice(0, 2).join("/");
1256
1273
  else name = name.split("/")[0];
1257
1274
  if (name) printModuleWarningForPackage(logger, path, name);
1258
1275
  else printModuleWarningForSourceCode(logger, path);
@@ -1792,48 +1809,26 @@ class TapFlatReporter extends TapReporter {
1792
1809
  }
1793
1810
  }
1794
1811
 
1812
+ class TreeReporter extends DefaultReporter {
1813
+ verbose = true;
1814
+ renderSucceed = true;
1815
+ }
1816
+
1795
1817
  class VerboseReporter extends DefaultReporter {
1796
1818
  verbose = true;
1797
1819
  renderSucceed = true;
1798
- printTestModule(module) {
1799
- // still print the test module in TTY,
1800
- // but don't print it in the CLI because we
1801
- // print all the tests when they finish
1802
- // instead of printing them when the test file finishes
1803
- if (this.isTTY) return super.printTestModule(module);
1820
+ printTestModule(_module) {
1821
+ // don't print test module, only print tests
1804
1822
  }
1805
1823
  onTestCaseResult(test) {
1806
- // don't print tests in TTY as they go, only print them
1807
- // in the CLI when they finish
1808
- if (super.onTestCaseResult(test), this.isTTY) return;
1824
+ super.onTestCaseResult(test);
1809
1825
  const testResult = test.result();
1810
1826
  if (this.ctx.config.hideSkippedTests && testResult.state === "skipped") return;
1811
- let title = ` ${getStateSymbol(test.task)} `;
1812
- if (test.project.name) title += formatProjectName(test.project);
1813
- title += getFullName(test.task, c.dim(" > ")), title += this.getDurationPrefix(test.task);
1814
- const diagnostic = test.diagnostic();
1815
- if (diagnostic?.heap != null) title += c.magenta(` ${Math.floor(diagnostic.heap / 1024 / 1024)} MB heap used`);
1816
- if (testResult.state === "skipped" && testResult.note) title += c.dim(c.gray(` [${testResult.note}]`));
1817
- if (this.log(title), testResult.state === "failed") testResult.errors.forEach((error) => this.log(c.red(` ${F_RIGHT} ${error?.message}`)));
1827
+ let title = ` ${this.getEntityPrefix(test)} `;
1828
+ if (title += test.module.task.name, test.location) title += c.dim(`:${test.location.line}:${test.location.column}`);
1829
+ if (title += separator, title += getTestName(test.task, separator), title += this.getTestCaseSuffix(test), this.log(title), testResult.state === "failed") testResult.errors.forEach((error) => this.log(c.red(` ${F_RIGHT} ${error.message}`)));
1818
1830
  if (test.annotations().length) this.log(), this.printAnnotations(test, "log", 3), this.log();
1819
1831
  }
1820
- printTestSuite(testSuite) {
1821
- const indentation = " ".repeat(getIndentation(testSuite.task)), tests = Array.from(testSuite.children.allTests()), state = getStateSymbol(testSuite.task);
1822
- this.log(` ${indentation}${state} ${testSuite.name} ${c.dim(`(${tests.length})`)}`);
1823
- }
1824
- getTestName(test) {
1825
- return test.name;
1826
- }
1827
- getTestIndentation(test) {
1828
- return " ".repeat(getIndentation(test));
1829
- }
1830
- formatShortError() {
1831
- // Short errors are not shown in tree-view
1832
- return "";
1833
- }
1834
- }
1835
- function getIndentation(suite, level = 1) {
1836
- return suite.suite && !("filepath" in suite.suite) ? getIndentation(suite.suite, level + 1) : level;
1837
1832
  }
1838
1833
 
1839
1834
  const ReportersMap = {
@@ -1845,8 +1840,9 @@ const ReportersMap = {
1845
1840
  "tap": TapReporter,
1846
1841
  "tap-flat": TapFlatReporter,
1847
1842
  "junit": JUnitReporter,
1843
+ "tree": TreeReporter,
1848
1844
  "hanging-process": HangingProcessReporter,
1849
1845
  "github-actions": GithubActionsReporter
1850
1846
  };
1851
1847
 
1852
- export { BlobReporter as B, DefaultReporter as D, F_RIGHT as F, GithubActionsReporter as G, HangingProcessReporter as H, JsonReporter as J, ReportersMap as R, TapFlatReporter as T, VerboseReporter as V, DotReporter as a, JUnitReporter as b, TapReporter as c, printError as d, errorBanner as e, formatProjectName as f, getStateSymbol as g, divider as h, generateCodeFrame as i, parse as p, readBlobs as r, stringify as s, truncateString as t, utils as u, withLabel as w };
1848
+ export { BlobReporter as B, DefaultReporter as D, F_RIGHT as F, GithubActionsReporter as G, HangingProcessReporter as H, JsonReporter as J, ReportersMap as R, TapFlatReporter as T, VerboseReporter as V, DotReporter as a, JUnitReporter as b, TapReporter as c, stringify as d, printError as e, formatProjectName as f, getStateSymbol as g, errorBanner as h, divider as i, generateCodeFrame as j, parse as p, readBlobs as r, separator as s, truncateString as t, utils as u, withLabel as w };
@@ -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 { R as RuntimeRPC, W as WorkerGlobalState } from './worker.d.BDsXGkwh.js';
5
+ import { a as RuntimeRPC, W as WorkerGlobalState } from './worker.d.B_Fd9M_w.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,6 +1,6 @@
1
1
  import { NodeSnapshotEnvironment } from '@vitest/snapshot/environment';
2
- import { g as getWorkerState } from './utils.D2R2NiOH.js';
3
- import '@vitest/utils';
2
+ import { g as getWorkerState } from './utils.DGKhod2J.js';
3
+ import '@vitest/utils/timers';
4
4
 
5
5
  class VitestNodeSnapshotEnvironment extends NodeSnapshotEnvironment {
6
6
  getHeader() {
@@ -1,4 +1,4 @@
1
- import { V as Vitest, T as TestProject, a as TestProjectConfiguration } from './reporters.d.BUWjmRYq.js';
1
+ import { V as Vitest, T as TestProject, a as TestProjectConfiguration } from './reporters.d.CVzhsTvK.js';
2
2
 
3
3
  interface VitestPluginContext {
4
4
  vitest: Vitest;
@@ -5,7 +5,7 @@ import { Writable } from 'node:stream';
5
5
  import { ViteDevServer, TransformResult as TransformResult$1, UserConfig as UserConfig$1, DepOptimizationConfig, ServerOptions, ConfigEnv, AliasOptions } from 'vite';
6
6
  import { MockedModule } from '@vitest/mocker';
7
7
  import { StackTraceParserOptions } from '@vitest/utils/source-map';
8
- import { B as BrowserTesterOptions, S as SerializedTestSpecification } from './browser.d.yFAklsD1.js';
8
+ import { B as BrowserTesterOptions, S as SerializedTestSpecification } from './browser.d.Dx7DO_Ce.js';
9
9
  import { a as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.B_LthbQq.js';
10
10
  import { PrettyFormatOptions } from '@vitest/pretty-format';
11
11
  import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
@@ -1922,13 +1922,15 @@ declare abstract class BaseReporter implements Reporter {
1922
1922
  protected printTestModule(testModule: TestModule): void;
1923
1923
  protected printTestCase(moduleState: TestModuleState, test: TestCase): void;
1924
1924
  private getModuleLog;
1925
- protected printTestSuite(_suite: TestSuite): void;
1926
- protected getTestName(test: Task, separator?: string): string;
1925
+ protected printTestSuite(testSuite: TestSuite): void;
1926
+ protected getTestName(test: Task, _separator?: string): string;
1927
1927
  protected getFullName(test: Task, separator?: string): string;
1928
- protected formatShortError(error: TestError): string;
1929
- protected getTestIndentation(_test: Task): string;
1928
+ protected getTestIndentation(test: Task): string;
1930
1929
  protected printAnnotations(test: TestCase, console: "log" | "error", padding?: number): void;
1931
- protected getDurationPrefix(task: Task): string;
1930
+ protected getEntityPrefix(entity: TestCase | TestModule | TestSuite): string;
1931
+ protected getTestCaseSuffix(testCase: TestCase): string;
1932
+ protected getStateSymbol(test: TestCase | TestModule | TestSuite): string;
1933
+ private getDurationPrefix;
1932
1934
  onWatcherStart(files?: File[], errors?: unknown[]): void;
1933
1935
  onWatcherRerun(files: string[], trigger?: string): void;
1934
1936
  onUserConsoleLog(log: UserConsoleLog, taskState?: TestResult["state"]): void;
@@ -2111,15 +2113,16 @@ declare class TapFlatReporter extends TapReporter {
2111
2113
  onTestRunEnd(testModules: ReadonlyArray<TestModule>): void;
2112
2114
  }
2113
2115
 
2116
+ declare class TreeReporter extends DefaultReporter {
2117
+ protected verbose: boolean;
2118
+ renderSucceed: boolean;
2119
+ }
2120
+
2114
2121
  declare class VerboseReporter extends DefaultReporter {
2115
2122
  protected verbose: boolean;
2116
2123
  renderSucceed: boolean;
2117
- printTestModule(module: TestModule): void;
2124
+ printTestModule(_module: TestModule): void;
2118
2125
  onTestCaseResult(test: TestCase): void;
2119
- protected printTestSuite(testSuite: TestSuite): void;
2120
- protected getTestName(test: Task): string;
2121
- protected getTestIndentation(test: Task): string;
2122
- protected formatShortError(): string;
2123
2126
  }
2124
2127
 
2125
2128
  type FormattedBenchmarkResult = BenchmarkResult & {
@@ -2165,6 +2168,7 @@ declare const ReportersMap: {
2165
2168
  tap: typeof TapReporter;
2166
2169
  "tap-flat": typeof TapFlatReporter;
2167
2170
  junit: typeof JUnitReporter;
2171
+ tree: typeof TreeReporter;
2168
2172
  "hanging-process": typeof HangingProcessReporter;
2169
2173
  "github-actions": typeof GithubActionsReporter;
2170
2174
  };
@@ -2173,6 +2177,7 @@ interface BuiltinReporterOptions {
2173
2177
  "default": DefaultReporterOptions;
2174
2178
  "verbose": DefaultReporterOptions;
2175
2179
  "dot": BaseOptions;
2180
+ "tree": BaseOptions;
2176
2181
  "json": JsonOptions;
2177
2182
  "blob": BlobOptions;
2178
2183
  "tap": never;
@@ -1,8 +1,8 @@
1
1
  import { chai } from '@vitest/expect';
2
- import { l as loadDiffConfig, b as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.uiMcU3cv.js';
3
- import { r as rpc } from './rpc.BKr6mtxz.js';
4
- import { g as getWorkerState } from './utils.D2R2NiOH.js';
5
- import { V as VitestTestRunner, N as NodeBenchmarkRunner } from './test.BiqSKISg.js';
2
+ import { l as loadDiffConfig, b as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.NAWRuMRP.js';
3
+ import { r as rpc } from './rpc.jKGRSXIH.js';
4
+ import { g as getWorkerState } from './utils.DGKhod2J.js';
5
+ import { V as VitestTestRunner, N as NodeBenchmarkRunner } from './test.KC5tH8hC.js';
6
6
 
7
7
  function setupChaiConfig(config) {
8
8
  Object.assign(chai.config, config);
@@ -70,7 +70,7 @@ async function resolveTestRunner(config, moduleRunner) {
70
70
 
71
71
  async function resolveSnapshotEnvironment(config, executor) {
72
72
  if (!config.snapshotEnvironment) {
73
- const { VitestNodeSnapshotEnvironment } = await import('./node.CyipiPvJ.js');
73
+ const { VitestNodeSnapshotEnvironment } = await import('./node.BsdMi6DV.js');
74
74
  return new VitestNodeSnapshotEnvironment();
75
75
  }
76
76
  const mod = await executor.import(config.snapshotEnvironment);
@@ -1,6 +1,6 @@
1
- import { getSafeTimers } from '@vitest/utils';
1
+ import { getSafeTimers } from '@vitest/utils/timers';
2
2
  import { c as createBirpc } from './index.Bgo3tNWt.js';
3
- import { g as getWorkerState } from './utils.D2R2NiOH.js';
3
+ import { g as getWorkerState } from './utils.DGKhod2J.js';
4
4
 
5
5
  const { get } = Reflect;
6
6
  function withSafeTimers(fn) {
@@ -1,7 +1,7 @@
1
1
  import { r as resolveCoverageProviderModule } from './coverage.D_JHT54q.js';
2
2
  import { addSerializer } from '@vitest/snapshot';
3
- import { setSafeTimers } from '@vitest/utils';
4
- import { g as getWorkerState } from './utils.D2R2NiOH.js';
3
+ import { setSafeTimers } from '@vitest/utils/timers';
4
+ import { g as getWorkerState } from './utils.DGKhod2J.js';
5
5
 
6
6
  async function startCoverageInsideWorker(options, loader, runtimeOptions) {
7
7
  const coverageModule = await resolveCoverageProviderModule(options, loader);
@@ -18,7 +18,7 @@ async function stopCoverageInsideWorker(options, loader, runtimeOptions) {
18
18
 
19
19
  let globalSetup = false;
20
20
  async function setupCommonEnv(config) {
21
- if (setupDefines(config), setupEnv(config.env), !globalSetup && (globalSetup = true, setSafeTimers(), config.globals)) (await import('./globals.DG-S3xFe.js')).registerApiGlobally();
21
+ if (setupDefines(config), setupEnv(config.env), !globalSetup && (globalSetup = true, setSafeTimers(), config.globals)) (await import('./globals.BjvYA-AD.js')).registerApiGlobally();
22
22
  }
23
23
  function setupDefines(config) {
24
24
  for (const key in config.defines) globalThis[key] = config.defines[key];
@@ -1,16 +1,15 @@
1
1
  import fs from 'node:fs';
2
- import { builtinModules, isBuiltin } from 'node:module';
3
- import { highlight, isBareImport } from '@vitest/utils';
2
+ import nodeModule, { isBuiltin } from 'node:module';
3
+ import { isBareImport } from '@vitest/utils/helpers';
4
4
  import { pathToFileURL } from 'node:url';
5
5
  import { normalize as normalize$1, join as join$1 } from 'pathe';
6
6
  import { distDir } from '../path.js';
7
- import { processError } from '@vitest/utils/error';
7
+ import { serializeValue } from '@vitest/utils/serialize';
8
8
  import { VitestModuleEvaluator, unwrapId } from '../module-evaluator.js';
9
9
  import { resolve as resolve$1, isAbsolute as isAbsolute$1 } from 'node:path';
10
10
  import vm from 'node:vm';
11
11
  import { MockerRegistry, mockObject, RedirectedModule, AutomockedModule } from '@vitest/mocker';
12
12
  import * as viteModuleRunner from 'vite/module-runner';
13
- import { V as VitestTransport } from './moduleTransport.I-bgQy0S.js';
14
13
 
15
14
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
16
15
  function normalizeWindowsPath(input = "") {
@@ -136,7 +135,7 @@ function findMockRedirect(root, mockPath, external) {
136
135
  return existsSync(fullPath) ? fullPath : null;
137
136
  }
138
137
  const builtins = new Set([
139
- ...builtinModules,
138
+ ...nodeModule.builtinModules,
140
139
  "assert/strict",
141
140
  "diagnostics_channel",
142
141
  "dns/promises",
@@ -157,7 +156,7 @@ const builtins = new Set([
157
156
  "node:test/reporters"
158
157
  ]), NODE_BUILTIN_NAMESPACE = "node:";
159
158
  function isNodeBuiltin(id) {
160
- return prefixedBuiltins$1.has(id) ? true : builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(5) : id);
159
+ return nodeModule.isBuiltin ? nodeModule.isBuiltin(id) : prefixedBuiltins$1.has(id) ? true : builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(5) : id);
161
160
  }
162
161
 
163
162
  const spyModulePath = resolve$1(distDir, "spy.js");
@@ -282,13 +281,13 @@ class VitestMocker {
282
281
  if (this.filterPublicKeys.includes(prop)) return void 0;
283
282
  throw this.createError(`[vitest] No "${String(prop)}" export is defined on the "${mock.raw}" mock. Did you forget to return it from "vi.mock"?
284
283
  If you need to partially mock a module, you can use "importOriginal" helper inside:
285
- `, highlight(`vi.mock(import("${mock.raw}"), async (importOriginal) => {
284
+ `, `vi.mock(import("${mock.raw}"), async (importOriginal) => {
286
285
  const actual = await importOriginal()
287
286
  return {
288
287
  ...actual,
289
288
  // your mocked methods
290
289
  }
291
- })`));
290
+ })`);
292
291
  }
293
292
  return val;
294
293
  } });
@@ -437,6 +436,24 @@ function fixLeadingSlashes(id) {
437
436
  return id.startsWith("//") ? id.replace(multipleSlashRe, "/") : id;
438
437
  }
439
438
 
439
+ class VitestTransport {
440
+ constructor(options) {
441
+ this.options = options;
442
+ }
443
+ async invoke(event) {
444
+ if (event.type !== "custom") return { error: /* @__PURE__ */ new Error(`Vitest Module Runner doesn't support Vite HMR events.`) };
445
+ if (event.event !== "vite:invoke") return { error: /* @__PURE__ */ new Error(`Vitest Module Runner doesn't support ${event.event} event.`) };
446
+ const { name, data } = event.data;
447
+ if (name !== "fetchModule") return { error: /* @__PURE__ */ new Error(`Unknown method: ${name}. Expected "fetchModule".`) };
448
+ try {
449
+ const result = await this.options.fetchModule(...data);
450
+ return { result };
451
+ } catch (error) {
452
+ return { error };
453
+ }
454
+ }
455
+ }
456
+
440
457
  // eslint-disable-next-line ts/ban-ts-comment
441
458
  // @ts-ignore
442
459
  const createNodeImportMeta = viteModuleRunner.createNodeImportMeta;
@@ -551,7 +568,7 @@ function listenForErrors(state) {
551
568
  // if there is another listener, assume that it's handled by user code
552
569
  // one is Vitest's own listener
553
570
  if (listeners.length > 1) return;
554
- const error = processError(err);
571
+ const error = serializeValue(err);
555
572
  if (typeof error === "object" && error != null) {
556
573
  if (error.VITEST_TEST_NAME = worker.current?.type === "test" ? worker.current.name : void 0, worker.filepath) error.VITEST_TEST_PATH = worker.filepath;
557
574
  error.VITEST_AFTER_ENV_TEARDOWN = worker.environmentTeardownRun;
@@ -662,4 +679,4 @@ function toBuiltin(id) {
662
679
  return id;
663
680
  }
664
681
 
665
- export { VitestModuleRunner as V, VITEST_VM_CONTEXT_SYMBOL as a, createNodeImportMeta as c, startVitestModuleRunner as s };
682
+ export { VitestModuleRunner as V, VITEST_VM_CONTEXT_SYMBOL as a, VitestTransport as b, createNodeImportMeta as c, startVitestModuleRunner as s };
@@ -1,13 +1,14 @@
1
1
  import { updateTask } from '@vitest/runner';
2
- import { createDefer, getSafeTimers } from '@vitest/utils';
3
- import { a as getBenchOptions, g as getBenchFn } from './benchmark.CJUa-Hsa.js';
4
- import { g as getWorkerState } from './utils.D2R2NiOH.js';
2
+ import { createDefer } from '@vitest/utils/helpers';
3
+ import { getSafeTimers } from '@vitest/utils/timers';
4
+ import { a as getBenchOptions, g as getBenchFn } from './benchmark.LXhJ0F0X.js';
5
+ import { g as getWorkerState } from './utils.DGKhod2J.js';
5
6
  import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
6
7
  import { getTests, getNames, getTestName } from '@vitest/runner/utils';
7
8
  import { processError } from '@vitest/utils/error';
8
9
  import { normalize } from 'pathe';
9
- import { a as getSnapshotClient, i as inject, c as createExpect, v as vi } from './vi.ZPgvtBao.js';
10
- import { r as rpc } from './rpc.BKr6mtxz.js';
10
+ import { a as getSnapshotClient, i as inject, c as createExpect, v as vi } from './vi.CiJ0Laa6.js';
11
+ import { r as rpc } from './rpc.jKGRSXIH.js';
11
12
 
12
13
  function createBenchmarkResult(name) {
13
14
  return {
@@ -93,7 +94,6 @@ class NodeBenchmarkRunner {
93
94
  }
94
95
  }
95
96
 
96
- // import type { VitestExecutor } from '../execute'
97
97
  // worker context is shared between all tests
98
98
  const workerContext = Object.create(null);
99
99
  class VitestTestRunner {