vitest 0.26.3 → 0.27.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 (39) hide show
  1. package/LICENSE.md +2 -54
  2. package/dist/browser.d.ts +3 -3
  3. package/dist/browser.js +15 -15
  4. package/dist/{chunk-api-setup.47a09f0f.js → chunk-api-setup.16ac28c0.js} +9 -4
  5. package/dist/{chunk-integrations-coverage.befed097.js → chunk-integrations-coverage.44413252.js} +19 -1
  6. package/dist/chunk-integrations-globals.3dfaeb99.js +27 -0
  7. package/dist/{chunk-typecheck-constants.06e1fe5b.js → chunk-mock-date.a1c85759.js} +9 -27
  8. package/dist/{chunk-node-git.a90c0582.js → chunk-node-git.543e964a.js} +1 -2
  9. package/dist/{chunk-runtime-chain.f51aa930.js → chunk-runtime-chain.6df5a66b.js} +1191 -1027
  10. package/dist/{chunk-runtime-error.f5c8aaf2.js → chunk-runtime-error.fad2c32b.js} +2 -2
  11. package/dist/{chunk-runtime-mocker.887bf8c8.js → chunk-runtime-mocker.a677dd28.js} +8 -6
  12. package/dist/{chunk-runtime-rpc.54d72169.js → chunk-runtime-rpc.7f83c8a9.js} +2 -2
  13. package/dist/{chunk-runtime-setup.a06d5c72.js → chunk-runtime-setup.731b2b04.js} +51 -52
  14. package/dist/{chunk-snapshot-manager.70695b70.js → chunk-snapshot-manager.700322bf.js} +408 -272
  15. package/dist/{chunk-utils-env.3fdc1793.js → chunk-utils-env.b861e3a0.js} +1 -63
  16. package/dist/{chunk-utils-import.e7f64637.js → chunk-utils-import.2baa69a9.js} +22 -8
  17. package/dist/chunk-utils-source-map.60562959.js +408 -0
  18. package/dist/{chunk-utils-timers.715da787.js → chunk-utils-timers.52534f96.js} +2977 -3458
  19. package/dist/cli-wrapper.js +11 -11
  20. package/dist/cli.js +12 -624
  21. package/dist/config.cjs +2 -1
  22. package/dist/config.d.ts +1 -1
  23. package/dist/config.js +2 -1
  24. package/dist/entry.js +14 -14
  25. package/dist/environments.d.ts +1 -1
  26. package/dist/{index-761e769b.d.ts → index-2d10c3fd.d.ts} +1 -1
  27. package/dist/index.d.ts +4 -4
  28. package/dist/index.js +12 -12
  29. package/dist/loader.js +3 -3
  30. package/dist/node.d.ts +2 -2
  31. package/dist/node.js +8 -8
  32. package/dist/spy.js +2 -102
  33. package/dist/suite.js +10 -10
  34. package/dist/{types-bae746aa.d.ts → types-e1e1d1e5.d.ts} +88 -76
  35. package/dist/vendor-index.723a074f.js +102 -0
  36. package/dist/worker.js +7 -7
  37. package/package.json +9 -5
  38. package/dist/chunk-integrations-globals.ee28730b.js +0 -27
  39. package/dist/chunk-utils-source-map.5278ee22.js +0 -86
@@ -1,7 +1,7 @@
1
- import { j as join, c as basename, d as dirname, r as relative, b as resolve, e as distDir, f as rootDir, p as picocolors, g as isAbsolute, i as isNode, h as configFiles, k as defaultPort, n as normalize, t as toNamespacedPath, E as EXIT_CODE_RESTART } from './chunk-utils-env.3fdc1793.js';
2
- import { p as pLimit, s as someTasksAreOnly, i as interpretTaskModes, g as getCoverageProvider, C as CoverageProviderMap } from './chunk-integrations-coverage.befed097.js';
1
+ import { j as join, c as basename, d as dirname, r as relative, e as extname, b as resolve, f as distDir, g as rootDir, h as isAbsolute, i as isNode, k as configFiles, l as defaultPort, n as normalize, t as toNamespacedPath, E as EXIT_CODE_RESTART } from './chunk-utils-env.b861e3a0.js';
2
+ import { p as pLimit, g as generateHash, c as calculateSuiteHash, s as someTasksAreOnly, i as interpretTaskModes, a as getCoverageProvider, C as CoverageProviderMap } from './chunk-integrations-coverage.44413252.js';
3
3
  import { g as getEnvPackageName } from './chunk-env-node.b3664da2.js';
4
- import { T as TYPECHECK_SUITE, z as ensurePackageInstalled, A as AggregateErrorPonyfill, s as slash$1, l as relativePath, B as getTests, f as getFullName, v as hasFailed, C as hasFailedSnapshot, D as getTypecheckTests, E as getSuites, F as isTypecheckTest, k as notNullish, q as shuffle, t as toArray, n as noop$1, G as deepMerge, b as getCallLastIndex, H as removeUndefinedValues, I as isWindows, J as stdout } from './chunk-typecheck-constants.06e1fe5b.js';
4
+ import { y as ensurePackageInstalled, A as AggregateErrorPonyfill, s as slash$1, k as relativePath, z as getTests, e as getFullName, u as hasFailed, B as hasFailedSnapshot, C as getSuites, j as notNullish, l as shuffle, t as toArray, n as noop$1, D as deepMerge, b as getCallLastIndex, E as removeUndefinedValues, F as isWindows, G as stdout } from './chunk-mock-date.a1c85759.js';
5
5
  import { loadConfigFromFile, normalizePath, createServer, mergeConfig } from 'vite';
6
6
  import path$a from 'node:path';
7
7
  import url, { fileURLToPath } from 'node:url';
@@ -14,6 +14,7 @@ import require$$0$1 from 'stream';
14
14
  import require$$2 from 'events';
15
15
  import require$$0$2, { existsSync as existsSync$1, readFileSync } from 'fs';
16
16
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
17
+ import c from 'picocolors';
17
18
  import { ViteNodeRunner } from 'vite-node/client';
18
19
  import { ViteNodeServer } from 'vite-node/server';
19
20
  import { writeFile, rm } from 'node:fs/promises';
@@ -27,8 +28,8 @@ import { cpus, hostname } from 'node:os';
27
28
  import { Tinypool } from 'tinypool';
28
29
  import { c as createBirpc } from './vendor-index.783e7f3e.js';
29
30
  import { performance } from 'perf_hooks';
30
- import { c as stripAnsi, d as safeSetInterval, e as safeClearInterval, g as cliTruncate, s as safeSetTimeout, h as stringWidth, i as ansiStyles, j as sliceAnsi, a as stringify$5, u as unifiedDiff, b as safeClearTimeout } from './chunk-utils-timers.715da787.js';
31
- import { p as parseStacktrace, a as positionToOffset, l as lineSplitRE } from './chunk-utils-source-map.5278ee22.js';
31
+ import { s as stripAnsi, c as cliTruncate, b as parseStacktrace, d as stringWidth, e as sliceAnsi, a as positionToOffset, l as lineSplitRE } from './chunk-utils-source-map.60562959.js';
32
+ import { g as safeSetInterval, h as safeClearInterval, s as safeSetTimeout, d as ansiStyles, c as createPatch, a as stringify$5, b as safeClearTimeout } from './chunk-utils-timers.52534f96.js';
32
33
  import { resolveModule } from 'local-pkg';
33
34
  import { createHash } from 'crypto';
34
35
  import { slash as slash$2, cleanUrl } from 'vite-node/utils';
@@ -40,7 +41,7 @@ import { stripLiteral } from 'strip-literal';
40
41
  import require$$0$3 from 'readline';
41
42
  import { p as prompts } from './vendor-index.9f20a9be.js';
42
43
 
43
- var version$1 = "0.26.3";
44
+ var version$1 = "0.27.0";
44
45
 
45
46
  class EndError extends Error {
46
47
  constructor(value) {
@@ -6892,9 +6893,9 @@ async function makeTscErrorInfo(errInfo) {
6892
6893
  }
6893
6894
  ];
6894
6895
  }
6895
- async function getTsconfigPath(root, config) {
6896
+ async function getTsconfig(root, config) {
6896
6897
  var _a;
6897
- const tempConfigPath = path$a.join(root, "tsconfig.temp.json");
6898
+ const tempConfigPath = join(root, "tsconfig.temp.json");
6898
6899
  const configName = ((_a = config.tsconfig) == null ? void 0 : _a.includes("jsconfig.json")) ? "jsconfig.json" : void 0;
6899
6900
  const tsconfig = ie(config.tsconfig || root, configName);
6900
6901
  if (!tsconfig)
@@ -6904,13 +6905,13 @@ async function getTsconfigPath(root, config) {
6904
6905
  tmpTsConfig.compilerOptions = tmpTsConfig.compilerOptions || {};
6905
6906
  tmpTsConfig.compilerOptions.emitDeclarationOnly = false;
6906
6907
  tmpTsConfig.compilerOptions.incremental = true;
6907
- tmpTsConfig.compilerOptions.tsBuildInfoFile = path$a.join(
6908
+ tmpTsConfig.compilerOptions.tsBuildInfoFile = join(
6908
6909
  __dirname,
6909
6910
  "tsconfig.tmp.tsbuildinfo"
6910
6911
  );
6911
6912
  const tsconfigFinalContent = JSON.stringify(tmpTsConfig, null, 2);
6912
6913
  await writeFile(tempConfigPath, tsconfigFinalContent);
6913
- return tempConfigPath;
6914
+ return { path: tempConfigPath, config: tmpTsConfig };
6914
6915
  } catch (err) {
6915
6916
  throw new Error("failed to write tsconfig.temp.json", { cause: err });
6916
6917
  }
@@ -6966,18 +6967,16 @@ async function collectTests(ctx, filepath) {
6966
6967
  ecmaVersion: "latest",
6967
6968
  allowAwaitOutsideFunction: true
6968
6969
  });
6970
+ const testFilepath = relative(ctx.config.root, filepath);
6969
6971
  const file = {
6970
6972
  filepath,
6971
6973
  type: "suite",
6972
- id: filepath,
6973
- name: relative(ctx.config.root, filepath),
6974
+ id: generateHash(testFilepath),
6975
+ name: testFilepath,
6974
6976
  mode: "run",
6975
6977
  tasks: [],
6976
6978
  start: ast.start,
6977
- end: ast.end,
6978
- result: {
6979
- state: "pass"
6980
- }
6979
+ end: ast.end
6981
6980
  };
6982
6981
  const definitions = [];
6983
6982
  const getName = (callee) => {
@@ -7004,14 +7003,16 @@ async function collectTests(ctx, filepath) {
7004
7003
  return;
7005
7004
  const { arguments: [{ value: message }] } = node;
7006
7005
  const property = (_a = callee == null ? void 0 : callee.property) == null ? void 0 : _a.name;
7007
- const mode = !property || property === name ? "run" : property;
7008
- if (!["run", "skip", "todo", "only"].includes(mode))
7006
+ let mode = !property || property === name ? "run" : property;
7007
+ if (!["run", "skip", "todo", "only", "skipIf", "runIf"].includes(mode))
7009
7008
  throw new Error(`${name}.${mode} syntax is not supported when testing types`);
7009
+ if (mode === "skipIf" || mode === "runIf")
7010
+ mode = "skip";
7010
7011
  definitions.push({
7011
7012
  start: node.start,
7012
7013
  end: node.end,
7013
7014
  name: message,
7014
- type: name,
7015
+ type: name === "it" || name === "test" ? "test" : "suite",
7015
7016
  mode
7016
7017
  });
7017
7018
  }
@@ -7023,33 +7024,49 @@ async function collectTests(ctx, filepath) {
7023
7024
  lastSuite = suite.suite;
7024
7025
  return lastSuite;
7025
7026
  };
7026
- definitions.sort((a, b) => a.start - b.start).forEach((definition, idx) => {
7027
+ definitions.sort((a, b) => a.start - b.start).forEach((definition) => {
7027
7028
  const latestSuite = updateLatestSuite(definition.start);
7028
7029
  let mode = definition.mode;
7029
7030
  if (latestSuite.mode !== "run")
7030
7031
  mode = latestSuite.mode;
7031
- const state = mode === "run" ? "pass" : mode;
7032
+ if (definition.type === "suite") {
7033
+ const task2 = {
7034
+ type: definition.type,
7035
+ id: "",
7036
+ suite: latestSuite,
7037
+ file,
7038
+ tasks: [],
7039
+ mode,
7040
+ name: definition.name,
7041
+ end: definition.end,
7042
+ start: definition.start,
7043
+ meta: {
7044
+ typecheck: true
7045
+ }
7046
+ };
7047
+ definition.task = task2;
7048
+ latestSuite.tasks.push(task2);
7049
+ lastSuite = task2;
7050
+ return;
7051
+ }
7032
7052
  const task = {
7033
- type: "suite",
7034
- id: idx.toString(),
7053
+ type: definition.type,
7054
+ id: "",
7035
7055
  suite: latestSuite,
7036
7056
  file,
7037
- tasks: [],
7038
7057
  mode,
7058
+ context: {},
7039
7059
  name: definition.name,
7040
7060
  end: definition.end,
7041
7061
  start: definition.start,
7042
- result: {
7043
- state
7062
+ meta: {
7063
+ typecheck: true
7044
7064
  }
7045
7065
  };
7046
7066
  definition.task = task;
7047
7067
  latestSuite.tasks.push(task);
7048
- if (definition.type === "describe" || definition.type === "suite")
7049
- lastSuite = task;
7050
- else
7051
- Object.defineProperty(task, TYPECHECK_SUITE, { value: true });
7052
7068
  });
7069
+ calculateSuiteHash(file);
7053
7070
  const hasOnly = someTasksAreOnly(file);
7054
7071
  interpretTaskModes(file, ctx.config.testNamePattern, hasOnly, false, ctx.config.allowOnly);
7055
7072
  return {
@@ -7091,9 +7108,15 @@ class Typechecker {
7091
7108
  async collectFileTests(filepath) {
7092
7109
  return collectTests(this.ctx, filepath);
7093
7110
  }
7111
+ getFiles() {
7112
+ return this.files.filter((filename) => {
7113
+ const extension = extname(filename);
7114
+ return extension !== ".js" || this.allowJs;
7115
+ });
7116
+ }
7094
7117
  async collectTests() {
7095
7118
  const tests = (await Promise.all(
7096
- this.files.map((filepath) => this.collectFileTests(filepath))
7119
+ this.getFiles().map((filepath) => this.collectFileTests(filepath))
7097
7120
  )).reduce((acc, data) => {
7098
7121
  if (!data)
7099
7122
  return acc;
@@ -7105,7 +7128,7 @@ class Typechecker {
7105
7128
  }
7106
7129
  async prepareResults(output) {
7107
7130
  const typeErrors = await this.parseTscLikeOutput(output);
7108
- const testFiles = new Set(this.files);
7131
+ const testFiles = new Set(this.getFiles());
7109
7132
  if (!this._tests)
7110
7133
  this._tests = await this.collectTests();
7111
7134
  const sourceErrors = [];
@@ -7126,31 +7149,25 @@ class Typechecker {
7126
7149
  if (task.suite)
7127
7150
  markFailed(task.suite);
7128
7151
  };
7129
- errors.forEach(({ error, originalError }, idx) => {
7152
+ errors.forEach(({ error, originalError }) => {
7153
+ var _a;
7130
7154
  const originalPos = (mapConsumer == null ? void 0 : mapConsumer.generatedPositionFor({
7131
7155
  line: originalError.line,
7132
7156
  column: originalError.column,
7133
7157
  source: path
7134
7158
  })) || originalError;
7135
7159
  const index = indexMap.get(`${originalPos.line}:${originalPos.column}`);
7136
- const definition = index != null && sortedDefinitions.find((def) => def.start <= index && def.end >= index) || file;
7137
- const suite = "task" in definition ? definition.task : definition;
7160
+ const definition = index != null && sortedDefinitions.find((def) => def.start <= index && def.end >= index);
7161
+ const suite = definition ? definition.task : file;
7138
7162
  const state = suite.mode === "run" || suite.mode === "only" ? "fail" : suite.mode;
7139
- const task = {
7140
- type: "typecheck",
7141
- id: `${path}${idx.toString()}`,
7142
- name: `error expect ${idx + 1}`,
7143
- mode: suite.mode,
7144
- file,
7145
- suite,
7146
- result: {
7147
- state,
7148
- error: state === "fail" ? error : void 0
7149
- }
7163
+ const errors2 = ((_a = suite.result) == null ? void 0 : _a.errors) || [];
7164
+ suite.result = {
7165
+ state,
7166
+ errors: errors2
7150
7167
  };
7151
- if (state === "fail")
7152
- markFailed(suite);
7153
- suite.tasks.push(task);
7168
+ errors2.push(error);
7169
+ if (state === "fail" && suite.suite)
7170
+ markFailed(suite.suite);
7154
7171
  });
7155
7172
  });
7156
7173
  typeErrors.forEach((errors, path) => {
@@ -7203,11 +7220,18 @@ class Typechecker {
7203
7220
  const packageName = checker === "tsc" ? "typescript" : "vue-tsc";
7204
7221
  await ensurePackageInstalled(packageName, root);
7205
7222
  }
7223
+ async prepare() {
7224
+ const { root, typecheck } = this.ctx.config;
7225
+ await this.ensurePackageInstalled(root, typecheck.checker);
7226
+ const { config, path } = await getTsconfig(root, typecheck);
7227
+ this.tempConfigPath = path;
7228
+ this.allowJs = typecheck.allowJs || config.allowJs || false;
7229
+ }
7206
7230
  async start() {
7207
7231
  var _a, _b, _c;
7232
+ if (!this.tempConfigPath)
7233
+ throw new Error("tsconfig was not initialized");
7208
7234
  const { root, watch, typecheck } = this.ctx.config;
7209
- await this.ensurePackageInstalled(root, typecheck.checker);
7210
- this.tempConfigPath = await getTsconfigPath(root, typecheck);
7211
7235
  const args = ["--noEmit", "--pretty", "false", "-p", this.tempConfigPath];
7212
7236
  if (watch)
7213
7237
  args.push("--watch");
@@ -7248,7 +7272,6 @@ class Typechecker {
7248
7272
  await child;
7249
7273
  this._result = await this.prepareResults(output);
7250
7274
  await ((_c = this._onParseEnd) == null ? void 0 : _c.call(this, this._result));
7251
- await this.clear();
7252
7275
  }
7253
7276
  }
7254
7277
  getResult() {
@@ -7426,8 +7449,8 @@ const F_LONG_DASH = "\u23AF";
7426
7449
 
7427
7450
  const spinnerMap = /* @__PURE__ */ new WeakMap();
7428
7451
  const hookSpinnerMap = /* @__PURE__ */ new WeakMap();
7429
- const pointer = picocolors.exports.yellow(F_POINTER);
7430
- const skipped = picocolors.exports.dim(picocolors.exports.gray(F_DOWN));
7452
+ const pointer = c.yellow(F_POINTER);
7453
+ const skipped = c.dim(c.gray(F_DOWN));
7431
7454
  function getCols(delta = 0) {
7432
7455
  var _a;
7433
7456
  let length = (_a = process.stdout) == null ? void 0 : _a.columns;
@@ -7458,44 +7481,50 @@ function formatTestPath(root, path) {
7458
7481
  const dir = dirname(path);
7459
7482
  const ext = ((_a = path.match(/(\.(spec|test)\.[cm]?[tj]sx?)$/)) == null ? void 0 : _a[0]) || "";
7460
7483
  const base = basename(path, ext);
7461
- return slash$1(picocolors.exports.dim(`${dir}/`) + picocolors.exports.bold(base)) + picocolors.exports.dim(ext);
7484
+ return slash$1(c.dim(`${dir}/`) + c.bold(base)) + c.dim(ext);
7462
7485
  }
7463
7486
  function renderSnapshotSummary(rootDir, snapshots) {
7464
7487
  const summary = [];
7465
7488
  if (snapshots.added)
7466
- summary.push(picocolors.exports.bold(picocolors.exports.green(`${snapshots.added} written`)));
7489
+ summary.push(c.bold(c.green(`${snapshots.added} written`)));
7467
7490
  if (snapshots.unmatched)
7468
- summary.push(picocolors.exports.bold(picocolors.exports.red(`${snapshots.unmatched} failed`)));
7491
+ summary.push(c.bold(c.red(`${snapshots.unmatched} failed`)));
7469
7492
  if (snapshots.updated)
7470
- summary.push(picocolors.exports.bold(picocolors.exports.green(`${snapshots.updated} updated `)));
7493
+ summary.push(c.bold(c.green(`${snapshots.updated} updated `)));
7471
7494
  if (snapshots.filesRemoved) {
7472
7495
  if (snapshots.didUpdate)
7473
- summary.push(picocolors.exports.bold(picocolors.exports.green(`${snapshots.filesRemoved} files removed `)));
7496
+ summary.push(c.bold(c.green(`${snapshots.filesRemoved} files removed `)));
7474
7497
  else
7475
- summary.push(picocolors.exports.bold(picocolors.exports.yellow(`${snapshots.filesRemoved} files obsolete `)));
7498
+ summary.push(c.bold(c.yellow(`${snapshots.filesRemoved} files obsolete `)));
7476
7499
  }
7477
7500
  if (snapshots.filesRemovedList && snapshots.filesRemovedList.length) {
7478
7501
  const [head, ...tail] = snapshots.filesRemovedList;
7479
- summary.push(`${picocolors.exports.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, head)}`);
7502
+ summary.push(`${c.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, head)}`);
7480
7503
  tail.forEach((key) => {
7481
- summary.push(` ${picocolors.exports.gray(F_DOT)} ${formatTestPath(rootDir, key)}`);
7504
+ summary.push(` ${c.gray(F_DOT)} ${formatTestPath(rootDir, key)}`);
7482
7505
  });
7483
7506
  }
7484
7507
  if (snapshots.unchecked) {
7485
7508
  if (snapshots.didUpdate)
7486
- summary.push(picocolors.exports.bold(picocolors.exports.green(`${snapshots.unchecked} removed`)));
7509
+ summary.push(c.bold(c.green(`${snapshots.unchecked} removed`)));
7487
7510
  else
7488
- summary.push(picocolors.exports.bold(picocolors.exports.yellow(`${snapshots.unchecked} obsolete`)));
7511
+ summary.push(c.bold(c.yellow(`${snapshots.unchecked} obsolete`)));
7489
7512
  snapshots.uncheckedKeysByFile.forEach((uncheckedFile) => {
7490
- summary.push(`${picocolors.exports.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, uncheckedFile.filePath)}`);
7491
- uncheckedFile.keys.forEach((key) => summary.push(` ${picocolors.exports.gray(F_DOT)} ${key}`));
7513
+ summary.push(`${c.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, uncheckedFile.filePath)}`);
7514
+ uncheckedFile.keys.forEach((key) => summary.push(` ${c.gray(F_DOT)} ${key}`));
7492
7515
  });
7493
7516
  }
7494
7517
  return summary;
7495
7518
  }
7519
+ function countTestErrors(tasks) {
7520
+ return tasks.reduce((c2, i) => {
7521
+ var _a, _b;
7522
+ return c2 + (((_b = (_a = i.result) == null ? void 0 : _a.errors) == null ? void 0 : _b.length) || 0);
7523
+ }, 0);
7524
+ }
7496
7525
  function getStateString(tasks, name = "tests", showTotal = true) {
7497
7526
  if (tasks.length === 0)
7498
- return picocolors.exports.dim(`no ${name}`);
7527
+ return c.dim(`no ${name}`);
7499
7528
  const passed = tasks.filter((i) => {
7500
7529
  var _a;
7501
7530
  return ((_a = i.result) == null ? void 0 : _a.state) === "pass";
@@ -7507,17 +7536,17 @@ function getStateString(tasks, name = "tests", showTotal = true) {
7507
7536
  const skipped2 = tasks.filter((i) => i.mode === "skip");
7508
7537
  const todo = tasks.filter((i) => i.mode === "todo");
7509
7538
  return [
7510
- failed.length ? picocolors.exports.bold(picocolors.exports.red(`${failed.length} failed`)) : null,
7511
- passed.length ? picocolors.exports.bold(picocolors.exports.green(`${passed.length} passed`)) : null,
7512
- skipped2.length ? picocolors.exports.yellow(`${skipped2.length} skipped`) : null,
7513
- todo.length ? picocolors.exports.gray(`${todo.length} todo`) : null
7514
- ].filter(Boolean).join(picocolors.exports.dim(" | ")) + (showTotal ? picocolors.exports.gray(` (${tasks.length})`) : "");
7539
+ failed.length ? c.bold(c.red(`${failed.length} failed`)) : null,
7540
+ passed.length ? c.bold(c.green(`${passed.length} passed`)) : null,
7541
+ skipped2.length ? c.yellow(`${skipped2.length} skipped`) : null,
7542
+ todo.length ? c.gray(`${todo.length} todo`) : null
7543
+ ].filter(Boolean).join(c.dim(" | ")) + (showTotal ? c.gray(` (${tasks.length})`) : "");
7515
7544
  }
7516
7545
  function getStateSymbol(task) {
7517
7546
  if (task.mode === "skip" || task.mode === "todo")
7518
7547
  return skipped;
7519
7548
  if (!task.result)
7520
- return picocolors.exports.gray("\xB7");
7549
+ return c.gray("\xB7");
7521
7550
  if (task.result.state === "run") {
7522
7551
  if (task.type === "suite")
7523
7552
  return pointer;
@@ -7526,13 +7555,13 @@ function getStateSymbol(task) {
7526
7555
  spinner = elegantSpinner();
7527
7556
  spinnerMap.set(task, spinner);
7528
7557
  }
7529
- return picocolors.exports.yellow(spinner());
7558
+ return c.yellow(spinner());
7530
7559
  }
7531
7560
  if (task.result.state === "pass") {
7532
- return task.type === "benchmark" ? picocolors.exports.green(F_DOT) : picocolors.exports.green(F_CHECK);
7561
+ return task.type === "benchmark" ? c.green(F_DOT) : c.green(F_CHECK);
7533
7562
  }
7534
7563
  if (task.result.state === "fail") {
7535
- return task.type === "suite" ? pointer : picocolors.exports.red(F_CROSS);
7564
+ return task.type === "suite" ? pointer : c.red(F_CROSS);
7536
7565
  }
7537
7566
  return " ";
7538
7567
  }
@@ -7550,7 +7579,7 @@ function getHookStateSymbol(task, hookName) {
7550
7579
  spinner = elegantSpinner();
7551
7580
  spinnerMap2.set(hookName, spinner);
7552
7581
  }
7553
- return picocolors.exports.yellow(spinner());
7582
+ return c.yellow(spinner());
7554
7583
  }
7555
7584
  }
7556
7585
  const spinnerFrames = process.platform === "win32" ? ["-", "\\", "|", "/"] : ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
@@ -7569,24 +7598,24 @@ function formatProjectName(name, suffix = " ") {
7569
7598
  return "";
7570
7599
  const index = name.split("").reduce((acc, v, idx) => acc + v.charCodeAt(0) + idx, 0);
7571
7600
  const colors = [
7572
- picocolors.exports.blue,
7573
- picocolors.exports.yellow,
7574
- picocolors.exports.cyan,
7575
- picocolors.exports.green,
7576
- picocolors.exports.magenta
7601
+ c.blue,
7602
+ c.yellow,
7603
+ c.cyan,
7604
+ c.green,
7605
+ c.magenta
7577
7606
  ];
7578
7607
  return colors[index % colors.length](`|${name}|`) + suffix;
7579
7608
  }
7580
7609
 
7581
7610
  var _a;
7582
7611
  const BADGE_PADDING = " ";
7583
- const HELP_HINT = `${picocolors.exports.dim("press ")}${picocolors.exports.bold("h")}${picocolors.exports.dim(" to show help")}`;
7584
- const HELP_UPDATE_SNAP = picocolors.exports.dim("press ") + picocolors.exports.bold(picocolors.exports.yellow("u")) + picocolors.exports.dim(" to update snapshot");
7585
- const HELP_QUITE = `${picocolors.exports.dim("press ")}${picocolors.exports.bold("q")}${picocolors.exports.dim(" to quit")}`;
7612
+ const HELP_HINT = `${c.dim("press ")}${c.bold("h")}${c.dim(" to show help")}`;
7613
+ const HELP_UPDATE_SNAP = c.dim("press ") + c.bold(c.yellow("u")) + c.dim(" to update snapshot");
7614
+ const HELP_QUITE = `${c.dim("press ")}${c.bold("q")}${c.dim(" to quit")}`;
7586
7615
  const WAIT_FOR_CHANGE_PASS = `
7587
- ${picocolors.exports.bold(picocolors.exports.inverse(picocolors.exports.green(" PASS ")))}${picocolors.exports.green(" Waiting for file changes...")}`;
7616
+ ${c.bold(c.inverse(c.green(" PASS ")))}${c.green(" Waiting for file changes...")}`;
7588
7617
  const WAIT_FOR_CHANGE_FAIL = `
7589
- ${picocolors.exports.bold(picocolors.exports.inverse(picocolors.exports.red(" FAIL ")))}${picocolors.exports.red(" Tests failed. Watching for file changes...")}`;
7618
+ ${c.bold(c.inverse(c.red(" FAIL ")))}${c.red(" Tests failed. Watching for file changes...")}`;
7590
7619
  const LAST_RUN_LOG_TIMEOUT = 1500;
7591
7620
  class BaseReporter {
7592
7621
  constructor() {
@@ -7621,7 +7650,7 @@ class BaseReporter {
7621
7650
  }
7622
7651
  }
7623
7652
  onTaskUpdate(packs) {
7624
- var _a2, _b, _c;
7653
+ var _a2, _b, _c, _d;
7625
7654
  if (this.isTTY)
7626
7655
  return;
7627
7656
  const logger = this.ctx.logger;
@@ -7634,22 +7663,24 @@ class BaseReporter {
7634
7663
  return ((_a3 = t.result) == null ? void 0 : _a3.state) === "fail";
7635
7664
  });
7636
7665
  const skipped = tests.filter((t) => t.mode === "skip" || t.mode === "todo");
7637
- let state = picocolors.exports.dim(`${tests.length} test${tests.length > 1 ? "s" : ""}`);
7666
+ let state = c.dim(`${tests.length} test${tests.length > 1 ? "s" : ""}`);
7638
7667
  if (failed.length)
7639
- state += ` ${picocolors.exports.dim("|")} ${picocolors.exports.red(`${failed.length} failed`)}`;
7668
+ state += ` ${c.dim("|")} ${c.red(`${failed.length} failed`)}`;
7640
7669
  if (skipped.length)
7641
- state += ` ${picocolors.exports.dim("|")} ${picocolors.exports.yellow(`${skipped.length} skipped`)}`;
7642
- let suffix = picocolors.exports.dim(" (") + state + picocolors.exports.dim(")");
7670
+ state += ` ${c.dim("|")} ${c.yellow(`${skipped.length} skipped`)}`;
7671
+ let suffix = c.dim(" (") + state + c.dim(")");
7643
7672
  if (task.result.duration) {
7644
- const color = task.result.duration > this.ctx.config.slowTestThreshold ? picocolors.exports.yellow : picocolors.exports.gray;
7645
- suffix += color(` ${Math.round(task.result.duration)}${picocolors.exports.dim("ms")}`);
7673
+ const color = task.result.duration > this.ctx.config.slowTestThreshold ? c.yellow : c.gray;
7674
+ suffix += color(` ${Math.round(task.result.duration)}${c.dim("ms")}`);
7646
7675
  }
7647
7676
  if (this.ctx.config.logHeapUsage && task.result.heap != null)
7648
- suffix += picocolors.exports.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
7677
+ suffix += c.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
7649
7678
  logger.log(` ${getStateSymbol(task)} ${task.name} ${suffix}`);
7650
7679
  for (const test of failed) {
7651
- logger.log(picocolors.exports.red(` ${pointer} ${getFullName(test)}`));
7652
- logger.log(picocolors.exports.red(` ${F_RIGHT} ${(_c = test.result.error) == null ? void 0 : _c.message}`));
7680
+ logger.log(c.red(` ${pointer} ${getFullName(test)}`));
7681
+ (_d = (_c = test.result) == null ? void 0 : _c.errors) == null ? void 0 : _d.forEach((e) => {
7682
+ logger.log(c.red(` ${F_RIGHT} ${e == null ? void 0 : e.message}`));
7683
+ });
7653
7684
  }
7654
7685
  }
7655
7686
  }
@@ -7669,13 +7700,13 @@ class BaseReporter {
7669
7700
  hints.unshift(HELP_UPDATE_SNAP);
7670
7701
  else
7671
7702
  hints.push(HELP_QUITE);
7672
- this.ctx.logger.log(BADGE_PADDING + hints.join(picocolors.exports.dim(", ")));
7703
+ this.ctx.logger.log(BADGE_PADDING + hints.join(c.dim(", ")));
7673
7704
  if (this._lastRunCount) {
7674
7705
  const LAST_RUN_TEXT = `rerun x${this._lastRunCount}`;
7675
7706
  const LAST_RUN_TEXTS = [
7676
- picocolors.exports.blue(LAST_RUN_TEXT),
7677
- picocolors.exports.gray(LAST_RUN_TEXT),
7678
- picocolors.exports.dim(picocolors.exports.gray(LAST_RUN_TEXT))
7707
+ c.blue(LAST_RUN_TEXT),
7708
+ c.gray(LAST_RUN_TEXT),
7709
+ c.dim(c.gray(LAST_RUN_TEXT))
7679
7710
  ];
7680
7711
  this.ctx.logger.logUpdate(BADGE_PADDING + LAST_RUN_TEXTS[0]);
7681
7712
  this._lastRunTimeout = 0;
@@ -7703,8 +7734,8 @@ class BaseReporter {
7703
7734
  let reruns = this._filesInWatchMode.get(filepath) ?? 0;
7704
7735
  this._filesInWatchMode.set(filepath, ++reruns);
7705
7736
  });
7706
- const BADGE = picocolors.exports.inverse(picocolors.exports.bold(picocolors.exports.blue(" RERUN ")));
7707
- const TRIGGER = trigger ? picocolors.exports.dim(` ${this.relative(trigger)}`) : "";
7737
+ const BADGE = c.inverse(c.bold(c.blue(" RERUN ")));
7738
+ const TRIGGER = trigger ? c.dim(` ${this.relative(trigger)}`) : "";
7708
7739
  if (files.length > 1) {
7709
7740
  this.ctx.logger.clearFullScreen(`
7710
7741
  ${BADGE}${TRIGGER}
@@ -7714,7 +7745,7 @@ ${BADGE}${TRIGGER}
7714
7745
  const rerun = this._filesInWatchMode.get(files[0]) ?? 1;
7715
7746
  this._lastRunCount = rerun;
7716
7747
  this.ctx.logger.clearFullScreen(`
7717
- ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
7748
+ ${BADGE}${TRIGGER} ${c.blue(`x${rerun}`)}
7718
7749
  `);
7719
7750
  }
7720
7751
  this._timeStart = new Date();
@@ -7724,7 +7755,7 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
7724
7755
  if (!this.shouldLog(log))
7725
7756
  return;
7726
7757
  const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : void 0;
7727
- this.ctx.logger.log(picocolors.exports.gray(log.type + picocolors.exports.dim(` | ${task ? getFullName(task) : "unknown test"}`)));
7758
+ this.ctx.logger.log(c.gray(log.type + c.dim(` | ${task ? getFullName(task) : "unknown test"}`)));
7728
7759
  process[log.type].write(`${log.content}
7729
7760
  `);
7730
7761
  }
@@ -7738,7 +7769,7 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
7738
7769
  return true;
7739
7770
  }
7740
7771
  onServerRestart(reason) {
7741
- this.ctx.logger.log(picocolors.exports.bold(picocolors.exports.magenta(
7772
+ this.ctx.logger.log(c.bold(c.magenta(
7742
7773
  reason === "config" ? "\nRestarting due to config changes..." : "\nRestarting Vitest..."
7743
7774
  )));
7744
7775
  }
@@ -7750,7 +7781,7 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
7750
7781
  await this.reportTestSummary(files);
7751
7782
  }
7752
7783
  async reportTestSummary(files) {
7753
- const tests = this.mode === "typecheck" ? getTypecheckTests(files) : getTests(files);
7784
+ const tests = getTests(files);
7754
7785
  const logger = this.ctx.logger;
7755
7786
  const executionTime = this.end - this.start;
7756
7787
  const collectTime = files.reduce((acc, test) => acc + Math.max(0, test.collectDuration || 0), 0);
@@ -7761,7 +7792,7 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
7761
7792
  }, 0);
7762
7793
  const transformTime = Array.from(this.ctx.vitenode.fetchCache.values()).reduce((a, b) => a + ((b == null ? void 0 : b.duration) || 0), 0);
7763
7794
  const threadTime = collectTime + testsTime + setupTime;
7764
- const padTitle = (str) => picocolors.exports.dim(`${str.padStart(11)} `);
7795
+ const padTitle = (str) => c.dim(`${str.padStart(11)} `);
7765
7796
  const time = (time2) => {
7766
7797
  if (time2 > 1e3)
7767
7798
  return `${(time2 / 1e3).toFixed(2)}s`;
@@ -7778,8 +7809,11 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
7778
7809
  logger.log(padTitle("Test Files"), getStateString(files));
7779
7810
  logger.log(padTitle("Tests"), getStateString(tests));
7780
7811
  if (this.mode === "typecheck") {
7781
- const typechecks = getTests(files).filter((t) => t.type === "typecheck");
7782
- logger.log(padTitle("Type Errors"), getStateString(typechecks, "errors", false));
7812
+ const failed = tests.filter((t) => {
7813
+ var _a2, _b, _c;
7814
+ return ((_a2 = t.meta) == null ? void 0 : _a2.typecheck) && ((_c = (_b = t.result) == null ? void 0 : _b.errors) == null ? void 0 : _c.length);
7815
+ });
7816
+ logger.log(padTitle("Type Errors"), failed.length ? c.bold(c.red(`${failed} failed`)) : c.dim("no errors"));
7783
7817
  }
7784
7818
  logger.log(padTitle("Start at"), formatTimeString(this._timeStart));
7785
7819
  if (this.watchFilters)
@@ -7787,7 +7821,7 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
7787
7821
  else if (this.mode === "typecheck")
7788
7822
  logger.log(padTitle("Duration"), time(executionTime));
7789
7823
  else
7790
- logger.log(padTitle("Duration"), time(executionTime) + picocolors.exports.dim(` (transform ${time(transformTime)}, setup ${time(setupTime)}, collect ${time(collectTime)}, tests ${time(testsTime)})`));
7824
+ logger.log(padTitle("Duration"), time(executionTime) + c.dim(` (transform ${time(transformTime)}, setup ${time(setupTime)}, collect ${time(collectTime)}, tests ${time(testsTime)})`));
7791
7825
  logger.log();
7792
7826
  }
7793
7827
  async printErrorsSummary(files) {
@@ -7796,24 +7830,23 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
7796
7830
  const tests = getTests(files);
7797
7831
  const failedSuites = suites.filter((i) => {
7798
7832
  var _a2;
7799
- return (_a2 = i.result) == null ? void 0 : _a2.error;
7833
+ return (_a2 = i.result) == null ? void 0 : _a2.errors;
7800
7834
  });
7801
7835
  const failedTests = tests.filter((i) => {
7802
7836
  var _a2;
7803
7837
  return ((_a2 = i.result) == null ? void 0 : _a2.state) === "fail";
7804
7838
  });
7805
- const failedTotal = failedSuites.length + failedTests.length;
7839
+ const failedTotal = countTestErrors(failedSuites) + countTestErrors(failedTests);
7806
7840
  let current = 1;
7807
- const errorDivider = () => logger.error(`${picocolors.exports.red(picocolors.exports.dim(divider(`[${current++}/${failedTotal}]`, void 0, 1)))}
7841
+ const errorDivider = () => logger.error(`${c.red(c.dim(divider(`[${current++}/${failedTotal}]`, void 0, 1)))}
7808
7842
  `);
7809
7843
  if (failedSuites.length) {
7810
- logger.error(picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(` Failed Suites ${failedSuites.length} `)))));
7844
+ logger.error(c.red(divider(c.bold(c.inverse(` Failed Suites ${failedSuites.length} `)))));
7811
7845
  logger.error();
7812
7846
  await this.printTaskErrors(failedSuites, errorDivider);
7813
7847
  }
7814
7848
  if (failedTests.length) {
7815
- const message = this.mode === "typecheck" ? "Type Errors" : "Failed Tests";
7816
- logger.error(picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(` ${message} ${failedTests.length} `)))));
7849
+ logger.error(c.red(divider(c.bold(c.inverse(` Failed Tests ${failedTests.length} `)))));
7817
7850
  logger.error();
7818
7851
  await this.printTaskErrors(failedTests, errorDivider);
7819
7852
  }
@@ -7827,47 +7860,48 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
7827
7860
  return ((_b = (_a2 = i.result) == null ? void 0 : _a2.benchmark) == null ? void 0 : _b.rank) === 1;
7828
7861
  });
7829
7862
  logger.log(`
7830
- ${picocolors.exports.cyan(picocolors.exports.inverse(picocolors.exports.bold(" BENCH ")))} ${picocolors.exports.cyan("Summary")}
7863
+ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
7831
7864
  `);
7832
7865
  for (const bench of topBenchs) {
7833
7866
  const group = bench.suite;
7834
7867
  if (!group)
7835
7868
  continue;
7836
7869
  const groupName = getFullName(group);
7837
- logger.log(` ${bench.name}${picocolors.exports.dim(` - ${groupName}`)}`);
7870
+ logger.log(` ${bench.name}${c.dim(` - ${groupName}`)}`);
7838
7871
  const siblings = group.tasks.filter((i) => {
7839
7872
  var _a2;
7840
7873
  return ((_a2 = i.result) == null ? void 0 : _a2.benchmark) && i !== bench;
7841
7874
  }).sort((a, b) => a.result.benchmark.rank - b.result.benchmark.rank);
7842
7875
  for (const sibling of siblings) {
7843
7876
  const number = `${(sibling.result.benchmark.mean / bench.result.benchmark.mean).toFixed(2)}x`;
7844
- logger.log(` ${picocolors.exports.green(number)} ${picocolors.exports.gray("faster than")} ${sibling.name}`);
7877
+ logger.log(` ${c.green(number)} ${c.gray("faster than")} ${sibling.name}`);
7845
7878
  }
7846
7879
  logger.log("");
7847
7880
  }
7848
7881
  }
7849
7882
  async printTaskErrors(tasks, errorDivider) {
7850
- var _a2, _b;
7883
+ var _a2, _b, _c;
7851
7884
  const errorsQueue = [];
7852
7885
  for (const task of tasks) {
7853
- const error = (_a2 = task.result) == null ? void 0 : _a2.error;
7854
- const errorItem = (error == null ? void 0 : error.stackStr) && errorsQueue.find((i) => {
7855
- var _a3;
7856
- return ((_a3 = i[0]) == null ? void 0 : _a3.stackStr) === error.stackStr;
7886
+ (_b = (_a2 = task.result) == null ? void 0 : _a2.errors) == null ? void 0 : _b.forEach((error) => {
7887
+ const errorItem = (error == null ? void 0 : error.stackStr) && errorsQueue.find((i) => {
7888
+ var _a3;
7889
+ return ((_a3 = i[0]) == null ? void 0 : _a3.stackStr) === error.stackStr;
7890
+ });
7891
+ if (errorItem)
7892
+ errorItem[1].push(task);
7893
+ else
7894
+ errorsQueue.push([error, [task]]);
7857
7895
  });
7858
- if (errorItem)
7859
- errorItem[1].push(task);
7860
- else
7861
- errorsQueue.push([error, [task]]);
7862
7896
  }
7863
7897
  for (const [error, tasks2] of errorsQueue) {
7864
7898
  for (const task of tasks2) {
7865
7899
  const filepath = (task == null ? void 0 : task.filepath) || "";
7866
- const projectName = (task == null ? void 0 : task.projectName) || ((_b = task.file) == null ? void 0 : _b.projectName);
7900
+ const projectName = (task == null ? void 0 : task.projectName) || ((_c = task.file) == null ? void 0 : _c.projectName);
7867
7901
  let name = getFullName(task);
7868
7902
  if (filepath)
7869
- name = `${name} ${picocolors.exports.dim(`[ ${this.relative(filepath)} ]`)}`;
7870
- this.ctx.logger.error(`${picocolors.exports.red(picocolors.exports.bold(picocolors.exports.inverse(" FAIL ")))} ${formatProjectName(projectName)}${name}`);
7903
+ name = `${name} ${c.dim(`[ ${this.relative(filepath)} ]`)}`;
7904
+ this.ctx.logger.error(`${c.red(c.bold(c.inverse(" FAIL ")))} ${formatProjectName(projectName)}${name}`);
7871
7905
  }
7872
7906
  await this.ctx.logger.printError(error);
7873
7907
  errorDivider();
@@ -7893,7 +7927,7 @@ function formatFilepath$1(path) {
7893
7927
  if (firstDot < 0)
7894
7928
  firstDot = basename.length;
7895
7929
  firstDot += lastSlash;
7896
- return picocolors.exports.dim(path.slice(0, lastSlash)) + path.slice(lastSlash, firstDot) + picocolors.exports.dim(path.slice(firstDot));
7930
+ return c.dim(path.slice(0, lastSlash)) + path.slice(lastSlash, firstDot) + c.dim(path.slice(firstDot));
7897
7931
  }
7898
7932
  function formatNumber$1(number) {
7899
7933
  const res = String(number.toFixed(number < 100 ? 4 : 2)).split(".");
@@ -7903,7 +7937,7 @@ function renderHookState(task, hookName, level = 0) {
7903
7937
  var _a, _b;
7904
7938
  const state = (_b = (_a = task.result) == null ? void 0 : _a.hooks) == null ? void 0 : _b[hookName];
7905
7939
  if (state && state === "run")
7906
- return `${" ".repeat(level)} ${getHookStateSymbol(task, hookName)} ${picocolors.exports.dim(`[ ${hookName} ]`)}`;
7940
+ return `${" ".repeat(level)} ${getHookStateSymbol(task, hookName)} ${c.dim(`[ ${hookName} ]`)}`;
7907
7941
  return "";
7908
7942
  }
7909
7943
  function renderBenchmarkItems$1(result) {
@@ -7932,16 +7966,16 @@ function renderBenchmark$1(task, tasks) {
7932
7966
  });
7933
7967
  return [
7934
7968
  padded[0],
7935
- picocolors.exports.dim(" "),
7936
- picocolors.exports.blue(padded[1]),
7937
- picocolors.exports.dim(" ops/sec "),
7938
- picocolors.exports.cyan(padded[3]),
7939
- picocolors.exports.dim(` (${padded[4]} samples)`),
7940
- result.rank === 1 ? picocolors.exports.bold(picocolors.exports.green(" fastest")) : result.rank === benchs.length && benchs.length > 2 ? picocolors.exports.bold(picocolors.exports.gray(" slowest")) : ""
7969
+ c.dim(" "),
7970
+ c.blue(padded[1]),
7971
+ c.dim(" ops/sec "),
7972
+ c.cyan(padded[3]),
7973
+ c.dim(` (${padded[4]} samples)`),
7974
+ result.rank === 1 ? c.bold(c.green(" fastest")) : result.rank === benchs.length && benchs.length > 2 ? c.bold(c.gray(" slowest")) : ""
7941
7975
  ].join("");
7942
7976
  }
7943
7977
  function renderTree$1(tasks, options, level = 0) {
7944
- var _a, _b, _c, _d, _e, _f;
7978
+ var _a, _b, _c, _d, _e, _f, _g;
7945
7979
  let output = [];
7946
7980
  for (const task of tasks) {
7947
7981
  let suffix = "";
@@ -7949,26 +7983,26 @@ function renderTree$1(tasks, options, level = 0) {
7949
7983
  if (level === 0 && task.type === "suite" && task.projectName)
7950
7984
  prefix += formatProjectName(task.projectName);
7951
7985
  if (task.type === "test" && ((_a = task.result) == null ? void 0 : _a.retryCount) && task.result.retryCount > 1)
7952
- suffix += picocolors.exports.yellow(` (retry x${task.result.retryCount})`);
7953
- if (task.type === "suite" && !isTypecheckTest(task)) {
7954
- const tests = options.mode === "typecheck" ? getTypecheckTests(task) : getTests(task);
7955
- suffix += picocolors.exports.dim(` (${tests.length})`);
7986
+ suffix += c.yellow(` (retry x${task.result.retryCount})`);
7987
+ if (task.type === "suite" && !((_b = task.meta) == null ? void 0 : _b.typecheck)) {
7988
+ const tests = getTests(task);
7989
+ suffix += c.dim(` (${tests.length})`);
7956
7990
  }
7957
7991
  if (task.mode === "skip" || task.mode === "todo")
7958
- suffix += ` ${picocolors.exports.dim(picocolors.exports.gray("[skipped]"))}`;
7959
- if (((_b = task.result) == null ? void 0 : _b.duration) != null) {
7992
+ suffix += ` ${c.dim(c.gray("[skipped]"))}`;
7993
+ if (((_c = task.result) == null ? void 0 : _c.duration) != null) {
7960
7994
  if (task.result.duration > DURATION_LONG$1)
7961
- suffix += picocolors.exports.yellow(` ${Math.round(task.result.duration)}${picocolors.exports.dim("ms")}`);
7995
+ suffix += c.yellow(` ${Math.round(task.result.duration)}${c.dim("ms")}`);
7962
7996
  }
7963
- if (options.showHeap && ((_c = task.result) == null ? void 0 : _c.heap) != null)
7964
- suffix += picocolors.exports.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
7997
+ if (options.showHeap && ((_d = task.result) == null ? void 0 : _d.heap) != null)
7998
+ suffix += c.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
7965
7999
  let name = task.name;
7966
8000
  if (level === 0)
7967
8001
  name = formatFilepath$1(name);
7968
8002
  const padding = " ".repeat(level);
7969
8003
  const body = task.type === "benchmark" ? renderBenchmark$1(task, tasks) : name;
7970
8004
  output.push(padding + prefix + body + suffix);
7971
- if (((_d = task.result) == null ? void 0 : _d.state) !== "pass" && outputMap$1.get(task) != null) {
8005
+ if (((_e = task.result) == null ? void 0 : _e.state) !== "pass" && outputMap$1.get(task) != null) {
7972
8006
  let data = outputMap$1.get(task);
7973
8007
  if (typeof data === "string") {
7974
8008
  data = stripAnsi(data.trim().split("\n").filter(Boolean).pop());
@@ -7977,13 +8011,13 @@ function renderTree$1(tasks, options, level = 0) {
7977
8011
  }
7978
8012
  if (data != null) {
7979
8013
  const out = `${" ".repeat(level)}${F_RIGHT} ${data}`;
7980
- output.push(` ${picocolors.exports.gray(cliTruncate(out, getCols(-3)))}`);
8014
+ output.push(` ${c.gray(cliTruncate(out, getCols(-3)))}`);
7981
8015
  }
7982
8016
  }
7983
8017
  output = output.concat(renderHookState(task, "beforeAll", level + 1));
7984
8018
  output = output.concat(renderHookState(task, "beforeEach", level + 1));
7985
8019
  if (task.type === "suite" && task.tasks.length > 0) {
7986
- if (((_e = task.result) == null ? void 0 : _e.state) === "fail" || ((_f = task.result) == null ? void 0 : _f.state) === "run" || options.renderSucceed)
8020
+ if (((_f = task.result) == null ? void 0 : _f.state) === "fail" || ((_g = task.result) == null ? void 0 : _g.state) === "run" || options.renderSucceed)
7987
8021
  output = output.concat(renderTree$1(task.tasks, options, level + 1));
7988
8022
  }
7989
8023
  output = output.concat(renderHookState(task, "afterAll", level + 1));
@@ -8032,7 +8066,7 @@ class DefaultReporter extends BaseReporter {
8032
8066
  }
8033
8067
  async onTestRemoved(trigger) {
8034
8068
  await this.stopListRender();
8035
- this.ctx.logger.clearScreen(picocolors.exports.yellow("Test removed...") + (trigger ? picocolors.exports.dim(` [ ${this.relative(trigger)} ]
8069
+ this.ctx.logger.clearScreen(c.yellow("Test removed...") + (trigger ? c.dim(` [ ${this.relative(trigger)} ]
8036
8070
  `) : ""), true);
8037
8071
  const files = this.ctx.state.getFiles(this.watchFilters);
8038
8072
  createListRenderer(files, this.rendererOptions).stop();
@@ -8079,10 +8113,10 @@ class DefaultReporter extends BaseReporter {
8079
8113
  }
8080
8114
  }
8081
8115
 
8082
- const check = picocolors.exports.green("\xB7");
8083
- const cross = picocolors.exports.red("x");
8084
- const pending = picocolors.exports.yellow("*");
8085
- const skip = picocolors.exports.dim(picocolors.exports.gray("-"));
8116
+ const check = c.green("\xB7");
8117
+ const cross = c.red("x");
8118
+ const pending = c.yellow("*");
8119
+ const skip = c.dim(c.gray("-"));
8086
8120
  function render(tasks) {
8087
8121
  const all = getTests(tasks);
8088
8122
  return all.map((i) => {
@@ -8194,14 +8228,14 @@ class JsonReporter$1 {
8194
8228
  this.start = Date.now();
8195
8229
  }
8196
8230
  async logTasks(files) {
8197
- var _a, _b;
8231
+ var _a, _b, _c;
8198
8232
  const suites = getSuites(files);
8199
8233
  const numTotalTestSuites = suites.length;
8200
8234
  const tests = getTests(files);
8201
8235
  const numTotalTests = tests.length;
8202
8236
  const numFailedTestSuites = suites.filter((s) => {
8203
8237
  var _a2;
8204
- return (_a2 = s.result) == null ? void 0 : _a2.error;
8238
+ return (_a2 = s.result) == null ? void 0 : _a2.errors;
8205
8239
  }).length;
8206
8240
  const numPassedTestSuites = numTotalTestSuites - numFailedTestSuites;
8207
8241
  const numPendingTestSuites = suites.filter((s) => {
@@ -8233,7 +8267,7 @@ class JsonReporter$1 {
8233
8267
  return Math.max(prev, (((_a2 = next.result) == null ? void 0 : _a2.startTime) ?? 0) + (((_b2 = next.result) == null ? void 0 : _b2.duration) ?? 0));
8234
8268
  }, startTime);
8235
8269
  const assertionResults = await Promise.all(tests2.map(async (t) => {
8236
- var _a2, _b2, _c, _d;
8270
+ var _a2, _b2, _c2, _d;
8237
8271
  const ancestorTitles = [];
8238
8272
  let iter = t.suite;
8239
8273
  while (iter) {
@@ -8247,7 +8281,7 @@ class JsonReporter$1 {
8247
8281
  status: StatusMap[((_a2 = t.result) == null ? void 0 : _a2.state) || t.mode] || "skipped",
8248
8282
  title: t.name,
8249
8283
  duration: (_b2 = t.result) == null ? void 0 : _b2.duration,
8250
- failureMessages: ((_d = (_c = t.result) == null ? void 0 : _c.error) == null ? void 0 : _d.message) == null ? [] : [t.result.error.message],
8284
+ failureMessages: ((_d = (_c2 = t.result) == null ? void 0 : _c2.errors) == null ? void 0 : _d.map((e) => e.message)) || [],
8251
8285
  location: await this.getFailureLocation(t)
8252
8286
  };
8253
8287
  }));
@@ -8265,7 +8299,7 @@ class JsonReporter$1 {
8265
8299
  var _a2;
8266
8300
  return ((_a2 = t.result) == null ? void 0 : _a2.state) === "fail";
8267
8301
  }) ? "failed" : "passed",
8268
- message: ((_b = (_a = file.result) == null ? void 0 : _a.error) == null ? void 0 : _b.message) ?? "",
8302
+ message: ((_c = (_b = (_a = file.result) == null ? void 0 : _a.errors) == null ? void 0 : _b[0]) == null ? void 0 : _c.message) ?? "",
8269
8303
  name: file.filepath
8270
8304
  });
8271
8305
  }
@@ -8302,8 +8336,8 @@ class JsonReporter$1 {
8302
8336
  }
8303
8337
  }
8304
8338
  async getFailureLocation(test) {
8305
- var _a;
8306
- const error = (_a = test.result) == null ? void 0 : _a.error;
8339
+ var _a, _b;
8340
+ const error = (_b = (_a = test.result) == null ? void 0 : _a.errors) == null ? void 0 : _b[0];
8307
8341
  if (!error)
8308
8342
  return;
8309
8343
  const stack = parseStacktrace(error);
@@ -8328,10 +8362,13 @@ class VerboseReporter extends DefaultReporter {
8328
8362
  if (task && task.type === "test" && ((_a = task.result) == null ? void 0 : _a.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
8329
8363
  let title = ` ${getStateSymbol(task)} ${getFullName(task)}`;
8330
8364
  if (this.ctx.config.logHeapUsage && task.result.heap != null)
8331
- title += picocolors.exports.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
8365
+ title += c.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
8332
8366
  this.ctx.logger.log(title);
8333
- if (task.result.state === "fail")
8334
- this.ctx.logger.log(picocolors.exports.red(` ${F_RIGHT} ${(_c = task.result.error) == null ? void 0 : _c.message}`));
8367
+ if (task.result.state === "fail") {
8368
+ (_c = task.result.errors) == null ? void 0 : _c.forEach((error) => {
8369
+ this.ctx.logger.log(c.red(` ${F_RIGHT} ${error == null ? void 0 : error.message}`));
8370
+ });
8371
+ }
8335
8372
  }
8336
8373
  }
8337
8374
  }
@@ -8397,22 +8434,23 @@ class TapReporter {
8397
8434
  this.logger.log("}");
8398
8435
  } else {
8399
8436
  this.logger.log(`${ok} ${id} - ${tapString(task.name)}${comment}`);
8400
- if (((_b = task.result) == null ? void 0 : _b.state) === "fail" && task.result.error) {
8401
- this.logger.indent();
8402
- const error = task.result.error;
8403
- const stacks = parseStacktrace(error);
8404
- const stack = stacks[0];
8405
- this.logger.log("---");
8406
- this.logger.log("error:");
8437
+ if (((_b = task.result) == null ? void 0 : _b.state) === "fail" && task.result.errors) {
8407
8438
  this.logger.indent();
8408
- this.logErrorDetails(error);
8409
- this.logger.unindent();
8410
- if (stack)
8411
- this.logger.log(`at: ${yamlString(`${stack.file}:${stack.line}:${stack.column}`)}`);
8412
- if (error.showDiff) {
8413
- this.logger.log(`actual: ${yamlString(error.actual)}`);
8414
- this.logger.log(`expected: ${yamlString(error.expected)}`);
8415
- }
8439
+ task.result.errors.forEach((error) => {
8440
+ const stacks = parseStacktrace(error);
8441
+ const stack = stacks[0];
8442
+ this.logger.log("---");
8443
+ this.logger.log("error:");
8444
+ this.logger.indent();
8445
+ this.logErrorDetails(error);
8446
+ this.logger.unindent();
8447
+ if (stack)
8448
+ this.logger.log(`at: ${yamlString(`${stack.file}:${stack.line}:${stack.column}`)}`);
8449
+ if (error.showDiff) {
8450
+ this.logger.log(`actual: ${yamlString(error.actual)}`);
8451
+ this.logger.log(`expected: ${yamlString(error.expected)}`);
8452
+ }
8453
+ });
8416
8454
  this.logger.log("...");
8417
8455
  this.logger.unindent();
8418
8456
  }
@@ -8528,21 +8566,23 @@ class JUnitReporter {
8528
8566
  name: task.name,
8529
8567
  time: getDuration(task)
8530
8568
  }, async () => {
8531
- var _a;
8569
+ var _a, _b;
8532
8570
  await this.writeLogs(task, "out");
8533
8571
  await this.writeLogs(task, "err");
8534
8572
  if (task.mode === "skip" || task.mode === "todo")
8535
8573
  await this.logger.log("<skipped/>");
8536
8574
  if (((_a = task.result) == null ? void 0 : _a.state) === "fail") {
8537
- const error = task.result.error;
8538
- await this.writeElement("failure", {
8539
- message: error == null ? void 0 : error.message,
8540
- type: (error == null ? void 0 : error.name) ?? (error == null ? void 0 : error.nameStr)
8541
- }, async () => {
8542
- if (!error)
8543
- return;
8544
- await this.writeErrorDetails(error);
8545
- });
8575
+ const promises = ((_b = task.result.errors) == null ? void 0 : _b.map(async (error) => {
8576
+ await this.writeElement("failure", {
8577
+ message: error == null ? void 0 : error.message,
8578
+ type: (error == null ? void 0 : error.name) ?? (error == null ? void 0 : error.nameStr)
8579
+ }, async () => {
8580
+ if (!error)
8581
+ return;
8582
+ await this.writeErrorDetails(error);
8583
+ });
8584
+ })) || [];
8585
+ await Promise.all(promises);
8546
8586
  }
8547
8587
  });
8548
8588
  }
@@ -8692,7 +8732,7 @@ function formatFilepath(path) {
8692
8732
  if (firstDot < 0)
8693
8733
  firstDot = basename.length;
8694
8734
  firstDot += lastSlash;
8695
- return picocolors.exports.dim(path.slice(0, lastSlash)) + path.slice(lastSlash, firstDot) + picocolors.exports.dim(path.slice(firstDot));
8735
+ return c.dim(path.slice(0, lastSlash)) + path.slice(lastSlash, firstDot) + c.dim(path.slice(firstDot));
8696
8736
  }
8697
8737
  function formatNumber(number) {
8698
8738
  const res = String(number.toFixed(number < 100 ? 4 : 2)).split(".");
@@ -8708,7 +8748,7 @@ function renderTableHead(tasks) {
8708
8748
  return `${" ".repeat(3)}${tableHead.map((i, idx) => {
8709
8749
  const width = Math.max(...allItems.map((i2) => i2[idx].length));
8710
8750
  return idx ? i.padStart(width, " ") : i.padEnd(width, " ");
8711
- }).map(picocolors.exports.bold).join(" ")}`;
8751
+ }).map(c.bold).join(" ")}`;
8712
8752
  }
8713
8753
  function renderBenchmarkItems(result) {
8714
8754
  return [
@@ -8742,17 +8782,17 @@ function renderBenchmark(task, tasks) {
8742
8782
  });
8743
8783
  return [
8744
8784
  padded[0],
8745
- picocolors.exports.blue(padded[1]),
8746
- picocolors.exports.cyan(padded[2]),
8747
- picocolors.exports.cyan(padded[3]),
8748
- picocolors.exports.cyan(padded[4]),
8749
- picocolors.exports.cyan(padded[5]),
8750
- picocolors.exports.cyan(padded[6]),
8751
- picocolors.exports.cyan(padded[7]),
8752
- picocolors.exports.cyan(padded[8]),
8753
- picocolors.exports.dim(padded[9]),
8754
- picocolors.exports.dim(padded[10]),
8755
- result.rank === 1 ? picocolors.exports.bold(picocolors.exports.green(" fastest")) : result.rank === benchs.length && benchs.length > 2 ? picocolors.exports.bold(picocolors.exports.gray(" slowest")) : ""
8785
+ c.blue(padded[1]),
8786
+ c.cyan(padded[2]),
8787
+ c.cyan(padded[3]),
8788
+ c.cyan(padded[4]),
8789
+ c.cyan(padded[5]),
8790
+ c.cyan(padded[6]),
8791
+ c.cyan(padded[7]),
8792
+ c.cyan(padded[8]),
8793
+ c.dim(padded[9]),
8794
+ c.dim(padded[10]),
8795
+ result.rank === 1 ? c.bold(c.green(" fastest")) : result.rank === benchs.length && benchs.length > 2 ? c.bold(c.gray(" slowest")) : ""
8756
8796
  ].join(" ");
8757
8797
  }
8758
8798
  function renderTree(tasks, options, level = 0) {
@@ -8768,15 +8808,15 @@ ${padding}`;
8768
8808
  prefix += ` ${getStateSymbol(task)} `;
8769
8809
  let suffix = "";
8770
8810
  if (task.type === "suite")
8771
- suffix += picocolors.exports.dim(` (${getTests(task).length})`);
8811
+ suffix += c.dim(` (${getTests(task).length})`);
8772
8812
  if (task.mode === "skip" || task.mode === "todo")
8773
- suffix += ` ${picocolors.exports.dim(picocolors.exports.gray("[skipped]"))}`;
8813
+ suffix += ` ${c.dim(c.gray("[skipped]"))}`;
8774
8814
  if (((_a = task.result) == null ? void 0 : _a.duration) != null) {
8775
8815
  if (task.result.duration > DURATION_LONG)
8776
- suffix += picocolors.exports.yellow(` ${Math.round(task.result.duration)}${picocolors.exports.dim("ms")}`);
8816
+ suffix += c.yellow(` ${Math.round(task.result.duration)}${c.dim("ms")}`);
8777
8817
  }
8778
8818
  if (options.showHeap && ((_b = task.result) == null ? void 0 : _b.heap) != null)
8779
- suffix += picocolors.exports.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
8819
+ suffix += c.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
8780
8820
  let name = task.name;
8781
8821
  if (level === 0)
8782
8822
  name = formatFilepath(name);
@@ -8791,7 +8831,7 @@ ${padding}`;
8791
8831
  }
8792
8832
  if (data != null) {
8793
8833
  const out = `${" ".repeat(level)}${F_RIGHT} ${data}`;
8794
- output.push(` ${picocolors.exports.gray(cliTruncate(out, getCols(-3)))}`);
8834
+ output.push(` ${c.gray(cliTruncate(out, getCols(-3)))}`);
8795
8835
  }
8796
8836
  }
8797
8837
  if (task.type === "suite" && task.tasks.length > 0) {
@@ -8843,7 +8883,7 @@ class TableReporter extends BaseReporter {
8843
8883
  }
8844
8884
  async onTestRemoved(trigger) {
8845
8885
  await this.stopListRender();
8846
- this.ctx.logger.clearScreen(picocolors.exports.yellow("Test removed...") + (trigger ? picocolors.exports.dim(` [ ${this.relative(trigger)} ]
8886
+ this.ctx.logger.clearScreen(c.yellow("Test removed...") + (trigger ? c.dim(` [ ${this.relative(trigger)} ]
8847
8887
  `) : ""), true);
8848
8888
  const files = this.ctx.state.getFiles(this.watchFilters);
8849
8889
  createTableRenderer(files, this.rendererOptions).stop();
@@ -9073,10 +9113,11 @@ const defaultCoverageExcludes = [
9073
9113
  "**/.{eslint,mocha,prettier}rc.{js,cjs,yml}"
9074
9114
  ];
9075
9115
  const coverageConfigDefaults = {
9116
+ all: false,
9076
9117
  provider: "c8",
9077
9118
  enabled: false,
9078
9119
  clean: true,
9079
- cleanOnRerun: false,
9120
+ cleanOnRerun: true,
9080
9121
  reportsDirectory: "./coverage",
9081
9122
  excludeNodeModules: true,
9082
9123
  exclude: defaultCoverageExcludes,
@@ -9338,8 +9379,8 @@ function resolveConfig(mode, options, viteConfig) {
9338
9379
  if (options.dom) {
9339
9380
  if (((_a = viteConfig.test) == null ? void 0 : _a.environment) != null && viteConfig.test.environment !== "happy-dom") {
9340
9381
  console.warn(
9341
- picocolors.exports.yellow(
9342
- `${picocolors.exports.inverse(picocolors.exports.yellow(" Vitest "))} Your config.test.environment ("${viteConfig.test.environment}") conflicts with --dom flag ("happy-dom"), ignoring "${viteConfig.test.environment}"`
9382
+ c.yellow(
9383
+ `${c.inverse(c.yellow(" Vitest "))} Your config.test.environment ("${viteConfig.test.environment}") conflicts with --dom flag ("happy-dom"), ignoring "${viteConfig.test.environment}"`
9343
9384
  )
9344
9385
  );
9345
9386
  }
@@ -9419,10 +9460,8 @@ function resolveConfig(mode, options, viteConfig) {
9419
9460
  if (options.related)
9420
9461
  resolved.related = toArray(options.related).map((file) => resolve(resolved.root, file));
9421
9462
  if (mode !== "benchmark") {
9422
- resolved.reporters = Array.from(/* @__PURE__ */ new Set([
9423
- ...toArray(resolved.reporters),
9424
- ...toArray(resolved.reporter)
9425
- ])).filter(Boolean);
9463
+ const reporters = resolved.reporter ?? resolved.reporters;
9464
+ resolved.reporters = Array.from(new Set(toArray(reporters))).filter(Boolean);
9426
9465
  }
9427
9466
  if (!resolved.reporters.length)
9428
9467
  resolved.reporters.push("default");
@@ -9938,7 +9977,100 @@ createLogUpdate(process$1.stdout);
9938
9977
 
9939
9978
  createLogUpdate(process$1.stderr);
9940
9979
 
9941
- var version = "0.26.3";
9980
+ var version = "0.27.0";
9981
+
9982
+ function formatLine(line, outputTruncateLength) {
9983
+ var _a;
9984
+ return cliTruncate(line, (outputTruncateLength ?? (((_a = process.stdout) == null ? void 0 : _a.columns) || 80)) - 4);
9985
+ }
9986
+ function unifiedDiff(actual, expected, options = {}) {
9987
+ if (actual === expected)
9988
+ return "";
9989
+ const { outputTruncateLength, outputDiffLines, outputDiffMaxLines, noColor, showLegend = true } = options;
9990
+ const indent = " ";
9991
+ const diffLimit = outputDiffLines || 15;
9992
+ const diffMaxLines = outputDiffMaxLines || 50;
9993
+ const counts = {
9994
+ "+": 0,
9995
+ "-": 0
9996
+ };
9997
+ let previousState = null;
9998
+ let previousCount = 0;
9999
+ const str = (str2) => str2;
10000
+ const dim = noColor ? str : c.dim;
10001
+ const green = noColor ? str : c.green;
10002
+ const red = noColor ? str : c.red;
10003
+ function preprocess(line) {
10004
+ if (!line || line.match(/\\ No newline/))
10005
+ return;
10006
+ const char = line[0];
10007
+ if ("-+".includes(char)) {
10008
+ if (previousState !== char) {
10009
+ previousState = char;
10010
+ previousCount = 0;
10011
+ }
10012
+ previousCount++;
10013
+ counts[char]++;
10014
+ if (previousCount === diffLimit)
10015
+ return dim(`${char} ...`);
10016
+ else if (previousCount > diffLimit)
10017
+ return;
10018
+ }
10019
+ return line;
10020
+ }
10021
+ const msg = createPatch("string", expected, actual);
10022
+ let lines = msg.split("\n").slice(5).map(preprocess).filter(Boolean);
10023
+ let moreLines = 0;
10024
+ const isCompact = counts["+"] === 1 && counts["-"] === 1 && lines.length === 2;
10025
+ if (lines.length > diffMaxLines) {
10026
+ const firstDiff = lines.findIndex((line) => line[0] === "-" || line[0] === "+");
10027
+ const displayLines = lines.slice(firstDiff - 2, diffMaxLines);
10028
+ const lastDisplayedIndex = firstDiff - 2 + diffMaxLines;
10029
+ if (lastDisplayedIndex < lines.length)
10030
+ moreLines = lines.length - lastDisplayedIndex;
10031
+ lines = displayLines;
10032
+ }
10033
+ let formatted = lines.map((line) => {
10034
+ line = line.replace(/\\"/g, '"');
10035
+ if (line[0] === "-") {
10036
+ line = formatLine(line.slice(1), outputTruncateLength);
10037
+ if (isCompact)
10038
+ return green(line);
10039
+ return green(`- ${formatLine(line, outputTruncateLength)}`);
10040
+ }
10041
+ if (line[0] === "+") {
10042
+ line = formatLine(line.slice(1), outputTruncateLength);
10043
+ if (isCompact)
10044
+ return red(line);
10045
+ return red(`+ ${formatLine(line, outputTruncateLength)}`);
10046
+ }
10047
+ if (line.match(/@@/))
10048
+ return "--";
10049
+ return ` ${line}`;
10050
+ });
10051
+ if (moreLines)
10052
+ formatted.push(dim(`... ${moreLines} more lines`));
10053
+ if (showLegend) {
10054
+ if (isCompact) {
10055
+ formatted = [
10056
+ `${green("- Expected")} ${formatted[0]}`,
10057
+ `${red("+ Received")} ${formatted[1]}`
10058
+ ];
10059
+ } else {
10060
+ if (formatted[0].includes('"'))
10061
+ formatted[0] = formatted[0].replace('"', "");
10062
+ const last = formatted.length - 1;
10063
+ if (formatted[last].endsWith('"'))
10064
+ formatted[last] = formatted[last].slice(0, formatted[last].length - 1);
10065
+ formatted.unshift(
10066
+ green(`- Expected - ${counts["-"]}`),
10067
+ red(`+ Received + ${counts["+"]}`),
10068
+ ""
10069
+ );
10070
+ }
10071
+ }
10072
+ return formatted.map((i) => i ? indent + i : i).join("\n");
10073
+ }
9942
10074
 
9943
10075
  async function printError(error, ctx, options = {}) {
9944
10076
  const { showCodeFrame = true, fullStack = false, type } = options;
@@ -9965,12 +10097,12 @@ async function printError(error, ctx, options = {}) {
9965
10097
  printErrorType(type, ctx);
9966
10098
  printErrorMessage(e, ctx.logger);
9967
10099
  if (e.frame) {
9968
- ctx.logger.error(picocolors.exports.yellow(e.frame));
10100
+ ctx.logger.error(c.yellow(e.frame));
9969
10101
  } else {
9970
10102
  printStack(ctx, stacks, nearest, errorProperties, (s) => {
9971
10103
  if (showCodeFrame && s === nearest && nearest) {
9972
10104
  const sourceCode = readFileSync(nearest.file, "utf-8");
9973
- ctx.logger.error(picocolors.exports.yellow(generateCodeFrame(sourceCode, 4, s.line, s.column)));
10105
+ ctx.logger.error(c.yellow(generateCodeFrame(sourceCode, 4, s.line, s.column)));
9974
10106
  }
9975
10107
  });
9976
10108
  }
@@ -9989,7 +10121,7 @@ async function printError(error, ctx, options = {}) {
9989
10121
  }
9990
10122
  function printErrorType(type, ctx) {
9991
10123
  ctx.logger.error(`
9992
- ${picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(` ${type} `))))}`);
10124
+ ${c.red(divider(c.bold(c.inverse(` ${type} `))))}`);
9993
10125
  }
9994
10126
  const skipErrorProperties = /* @__PURE__ */ new Set([
9995
10127
  "nameStr",
@@ -10027,16 +10159,16 @@ function handleImportOutsideModuleError(stack, ctx) {
10027
10159
  name = name.split("/").slice(0, 2).join("/");
10028
10160
  else
10029
10161
  name = name.split("/")[0];
10030
- ctx.logger.error(picocolors.exports.yellow(
10031
- `Module ${path} seems to be an ES Module but shipped in a CommonJS package. You might want to create an issue to the package ${picocolors.exports.bold(`"${name}"`)} asking them to ship the file in .mjs extension or add "type": "module" in their package.json.
10162
+ ctx.logger.error(c.yellow(
10163
+ `Module ${path} seems to be an ES Module but shipped in a CommonJS package. You might want to create an issue to the package ${c.bold(`"${name}"`)} asking them to ship the file in .mjs extension or add "type": "module" in their package.json.
10032
10164
 
10033
10165
  As a temporary workaround you can try to inline the package by updating your config:
10034
10166
 
10035
- ` + picocolors.exports.gray(picocolors.exports.dim("// vitest.config.js")) + "\n" + picocolors.exports.green(`export default {
10167
+ ` + c.gray(c.dim("// vitest.config.js")) + "\n" + c.green(`export default {
10036
10168
  test: {
10037
10169
  deps: {
10038
10170
  inline: [
10039
- ${picocolors.exports.yellow(picocolors.exports.bold(`"${name}"`))}
10171
+ ${c.yellow(c.bold(`"${name}"`))}
10040
10172
  ]
10041
10173
  }
10042
10174
  }
@@ -10046,8 +10178,8 @@ As a temporary workaround you can try to inline the package by updating your con
10046
10178
  }
10047
10179
  function displayDiff(actual, expected, console, options = {}) {
10048
10180
  const diff = unifiedDiff(actual, expected, options);
10049
- const dim = options.noColor ? (s) => s : picocolors.exports.dim;
10050
- const black = options.noColor ? (s) => s : picocolors.exports.black;
10181
+ const dim = options.noColor ? (s) => s : c.dim;
10182
+ const black = options.noColor ? (s) => s : c.black;
10051
10183
  if (diff)
10052
10184
  console.error(diff + "\n");
10053
10185
  else if (actual && expected && actual !== '"undefined"' && expected !== '"undefined"')
@@ -10055,16 +10187,16 @@ function displayDiff(actual, expected, console, options = {}) {
10055
10187
  }
10056
10188
  function printErrorMessage(error, logger) {
10057
10189
  const errorName = error.name || error.nameStr || "Unknown Error";
10058
- logger.error(picocolors.exports.red(`${picocolors.exports.bold(errorName)}: ${error.message}`));
10190
+ logger.error(c.red(`${c.bold(errorName)}: ${error.message}`));
10059
10191
  }
10060
10192
  function printStack(ctx, stack, highlight, errorProperties, onStack) {
10061
10193
  if (!stack.length)
10062
10194
  return;
10063
10195
  const logger = ctx.logger;
10064
10196
  for (const frame of stack) {
10065
- const color = frame === highlight ? picocolors.exports.yellow : picocolors.exports.gray;
10197
+ const color = frame === highlight ? c.yellow : c.gray;
10066
10198
  const path = relative(ctx.config.root, frame.file);
10067
- logger.error(color(` ${picocolors.exports.dim(F_POINTER)} ${[frame.method, picocolors.exports.dim(`${path}:${frame.line}:${frame.column}`)].filter(Boolean).join(" ")}`));
10199
+ logger.error(color(` ${c.dim(F_POINTER)} ${[frame.method, c.dim(`${path}:${frame.line}:${frame.column}`)].filter(Boolean).join(" ")}`));
10068
10200
  onStack == null ? void 0 : onStack(frame);
10069
10201
  if (frame.file in ctx.state.filesMap)
10070
10202
  break;
@@ -10072,9 +10204,9 @@ function printStack(ctx, stack, highlight, errorProperties, onStack) {
10072
10204
  logger.error();
10073
10205
  const hasProperties = Object.keys(errorProperties).length > 0;
10074
10206
  if (hasProperties) {
10075
- logger.error(picocolors.exports.red(picocolors.exports.dim(divider())));
10207
+ logger.error(c.red(c.dim(divider())));
10076
10208
  const propertiesString = stringify$5(errorProperties, 10, { printBasicPrototype: false });
10077
- logger.error(picocolors.exports.red(picocolors.exports.bold("Serialized Error:")), picocolors.exports.gray(propertiesString));
10209
+ logger.error(c.red(c.bold("Serialized Error:")), c.gray(propertiesString));
10078
10210
  }
10079
10211
  }
10080
10212
  function generateCodeFrame(source, indent = 0, lineNumber, columnNumber, range = 2) {
@@ -10086,7 +10218,7 @@ function generateCodeFrame(source, indent = 0, lineNumber, columnNumber, range =
10086
10218
  let res = [];
10087
10219
  const columns = ((_a = process.stdout) == null ? void 0 : _a.columns) || 80;
10088
10220
  function lineNo(no = "") {
10089
- return picocolors.exports.gray(`${String(no).padStart(3, " ")}| `);
10221
+ return c.gray(`${String(no).padStart(3, " ")}| `);
10090
10222
  }
10091
10223
  for (let i = 0; i < lines.length; i++) {
10092
10224
  count += lines[i].length + 1;
@@ -10101,11 +10233,11 @@ function generateCodeFrame(source, indent = 0, lineNumber, columnNumber, range =
10101
10233
  if (j === i) {
10102
10234
  const pad = start - (count - lineLength);
10103
10235
  const length = Math.max(1, end > count ? lineLength - pad : end - start);
10104
- res.push(lineNo() + " ".repeat(pad) + picocolors.exports.red("^".repeat(length)));
10236
+ res.push(lineNo() + " ".repeat(pad) + c.red("^".repeat(length)));
10105
10237
  } else if (j > i) {
10106
10238
  if (end > count) {
10107
10239
  const length = Math.max(1, Math.min(end - count, lineLength));
10108
- res.push(lineNo() + picocolors.exports.red("^".repeat(length)));
10240
+ res.push(lineNo() + c.red("^".repeat(length)));
10109
10241
  }
10110
10242
  count += lineLength + 1;
10111
10243
  }
@@ -10170,62 +10302,62 @@ class Logger {
10170
10302
  }
10171
10303
  printNoTestFound(filters) {
10172
10304
  const config = this.ctx.config;
10173
- const comma = picocolors.exports.dim(", ");
10305
+ const comma = c.dim(", ");
10174
10306
  if (filters == null ? void 0 : filters.length)
10175
- this.console.error(picocolors.exports.dim("filter: ") + picocolors.exports.yellow(filters.join(comma)));
10307
+ this.console.error(c.dim("filter: ") + c.yellow(filters.join(comma)));
10176
10308
  if (config.include)
10177
- this.console.error(picocolors.exports.dim("include: ") + picocolors.exports.yellow(config.include.join(comma)));
10309
+ this.console.error(c.dim("include: ") + c.yellow(config.include.join(comma)));
10178
10310
  if (config.exclude)
10179
- this.console.error(picocolors.exports.dim("exclude: ") + picocolors.exports.yellow(config.exclude.join(comma)));
10311
+ this.console.error(c.dim("exclude: ") + c.yellow(config.exclude.join(comma)));
10180
10312
  if (config.watchExclude)
10181
- this.console.error(picocolors.exports.dim("watch exclude: ") + picocolors.exports.yellow(config.watchExclude.join(comma)));
10313
+ this.console.error(c.dim("watch exclude: ") + c.yellow(config.watchExclude.join(comma)));
10182
10314
  if (config.passWithNoTests)
10183
10315
  this.log(`No ${config.mode} files found, exiting with code 0
10184
10316
  `);
10185
10317
  else
10186
- this.error(picocolors.exports.red(`
10318
+ this.error(c.red(`
10187
10319
  No ${config.mode} files found, exiting with code 1`));
10188
10320
  }
10189
10321
  printBanner() {
10190
10322
  var _a, _b, _c;
10191
10323
  this.log();
10192
- const versionTest = this.ctx.config.watch ? picocolors.exports.blue(`v${version}`) : picocolors.exports.cyan(`v${version}`);
10193
- const mode = this.ctx.config.watch ? picocolors.exports.blue(" DEV ") : picocolors.exports.cyan(" RUN ");
10194
- this.log(`${picocolors.exports.inverse(picocolors.exports.bold(mode))} ${versionTest} ${picocolors.exports.gray(this.ctx.config.root)}`);
10324
+ const versionTest = this.ctx.config.watch ? c.blue(`v${version}`) : c.cyan(`v${version}`);
10325
+ const mode = this.ctx.config.watch ? c.blue(" DEV ") : c.cyan(" RUN ");
10326
+ this.log(`${c.inverse(c.bold(mode))} ${versionTest} ${c.gray(this.ctx.config.root)}`);
10195
10327
  if (this.ctx.config.browser)
10196
- this.log(picocolors.exports.dim(picocolors.exports.green(` Browser runner started at http://${((_a = this.ctx.config.api) == null ? void 0 : _a.host) || "localhost"}:${picocolors.exports.bold(`${this.ctx.server.config.server.port}`)}`)));
10328
+ this.log(c.dim(c.green(` Browser runner started at http://${((_a = this.ctx.config.api) == null ? void 0 : _a.host) || "localhost"}:${c.bold(`${this.ctx.server.config.server.port}`)}`)));
10197
10329
  else if (this.ctx.config.ui)
10198
- this.log(picocolors.exports.dim(picocolors.exports.green(` UI started at http://${((_b = this.ctx.config.api) == null ? void 0 : _b.host) || "localhost"}:${picocolors.exports.bold(`${this.ctx.server.config.server.port}`)}${this.ctx.config.uiBase}`)));
10330
+ this.log(c.dim(c.green(` UI started at http://${((_b = this.ctx.config.api) == null ? void 0 : _b.host) || "localhost"}:${c.bold(`${this.ctx.server.config.server.port}`)}${this.ctx.config.uiBase}`)));
10199
10331
  else if (this.ctx.config.api)
10200
- this.log(picocolors.exports.dim(picocolors.exports.green(` API started at http://${((_c = this.ctx.config.api) == null ? void 0 : _c.host) || "localhost"}:${picocolors.exports.bold(`${this.ctx.config.api.port}`)}`)));
10332
+ this.log(c.dim(c.green(` API started at http://${((_c = this.ctx.config.api) == null ? void 0 : _c.host) || "localhost"}:${c.bold(`${this.ctx.config.api.port}`)}`)));
10201
10333
  if (this.ctx.coverageProvider)
10202
- this.log(picocolors.exports.dim(" Coverage enabled with ") + picocolors.exports.yellow(this.ctx.coverageProvider.name));
10334
+ this.log(c.dim(" Coverage enabled with ") + c.yellow(this.ctx.coverageProvider.name));
10203
10335
  this.log();
10204
10336
  }
10205
10337
  async printUnhandledErrors(errors) {
10206
- const errorMessage = picocolors.exports.red(picocolors.exports.bold(
10338
+ const errorMessage = c.red(c.bold(
10207
10339
  `
10208
10340
  Vitest caught ${errors.length} unhandled error${errors.length > 1 ? "s" : ""} during the test run.
10209
10341
  This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.`
10210
10342
  ));
10211
- this.log(picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(" Unhandled Errors ")))));
10343
+ this.log(c.red(divider(c.bold(c.inverse(" Unhandled Errors ")))));
10212
10344
  this.log(errorMessage);
10213
10345
  await Promise.all(errors.map(async (err) => {
10214
10346
  await this.printError(err, true, err.type || "Unhandled Error");
10215
10347
  }));
10216
- this.log(picocolors.exports.red(divider()));
10348
+ this.log(c.red(divider()));
10217
10349
  }
10218
10350
  async printSourceTypeErrors(errors) {
10219
- const errorMessage = picocolors.exports.red(picocolors.exports.bold(
10351
+ const errorMessage = c.red(c.bold(
10220
10352
  `
10221
10353
  Vitest found ${errors.length} error${errors.length > 1 ? "s" : ""} not related to your test files.`
10222
10354
  ));
10223
- this.log(picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(" Source Errors ")))));
10355
+ this.log(c.red(divider(c.bold(c.inverse(" Source Errors ")))));
10224
10356
  this.log(errorMessage);
10225
10357
  await Promise.all(errors.map(async (err) => {
10226
10358
  await this.printError(err, true);
10227
10359
  }));
10228
- this.log(picocolors.exports.red(divider()));
10360
+ this.log(c.red(divider()));
10229
10361
  }
10230
10362
  }
10231
10363
 
@@ -10263,7 +10395,7 @@ class Vitest {
10263
10395
  this.state = new StateManager();
10264
10396
  this.cache = new VitestCache();
10265
10397
  this.snapshot = new SnapshotManager({ ...resolved.snapshotOptions });
10266
- if (this.config.watch)
10398
+ if (this.config.watch && this.mode !== "typecheck")
10267
10399
  this.registerWatcher();
10268
10400
  this.vitenode = new ViteNodeServer(server, this.config);
10269
10401
  const node = this.vitenode;
@@ -10333,8 +10465,9 @@ class Vitest {
10333
10465
  this.configOverride || {}
10334
10466
  );
10335
10467
  }
10336
- async typecheck(filters) {
10337
- const testsFilesList = await this.globTestFiles(filters);
10468
+ async typecheck(filters = []) {
10469
+ const { include, exclude } = this.config.typecheck;
10470
+ const testsFilesList = await this.globFiles(filters, include, exclude);
10338
10471
  const checker = new Typechecker(this, testsFilesList);
10339
10472
  this.typechecker = checker;
10340
10473
  checker.onParseEnd(async ({ files, sourceErrors }) => {
@@ -10375,6 +10508,7 @@ class Vitest {
10375
10508
  await this.report("onTaskUpdate", checker.getTestPacks());
10376
10509
  await this.report("onCollected");
10377
10510
  });
10511
+ await checker.prepare();
10378
10512
  await checker.collectTests();
10379
10513
  await checker.start();
10380
10514
  }
@@ -10403,7 +10537,7 @@ class Vitest {
10403
10537
  await Promise.all(files.map((file) => this.cache.stats.updateStats(file)));
10404
10538
  await this.runFiles(files);
10405
10539
  if (this.coverageProvider) {
10406
- this.logger.log(picocolors.exports.blue(" % ") + picocolors.exports.dim("Coverage report from ") + picocolors.exports.yellow(this.coverageProvider.name));
10540
+ this.logger.log(c.blue(" % ") + c.dim("Coverage report from ") + c.yellow(this.coverageProvider.name));
10407
10541
  await this.coverageProvider.reportCoverage();
10408
10542
  }
10409
10543
  if (this.config.watch && !this.config.browser)
@@ -10430,13 +10564,13 @@ class Vitest {
10430
10564
  }
10431
10565
  async filterTestsBySource(tests) {
10432
10566
  if (this.config.changed && !this.config.related) {
10433
- const { VitestGit } = await import('./chunk-node-git.a90c0582.js');
10567
+ const { VitestGit } = await import('./chunk-node-git.543e964a.js');
10434
10568
  const vitestGit = new VitestGit(this.config.root);
10435
10569
  const related2 = await vitestGit.findChangedFiles({
10436
10570
  changedSince: this.config.changed
10437
10571
  });
10438
10572
  if (!related2) {
10439
- this.logger.error(picocolors.exports.red("Could not find Git root. Have you initialized git with `git init`?\n"));
10573
+ this.logger.error(c.red("Could not find Git root. Have you initialized git with `git init`?\n"));
10440
10574
  process.exit(1);
10441
10575
  }
10442
10576
  this.config.related = Array.from(new Set(related2));
@@ -10656,8 +10790,7 @@ class Vitest {
10656
10790
  );
10657
10791
  }));
10658
10792
  }
10659
- async globTestFiles(filters = []) {
10660
- const { include, exclude, includeSource } = this.config;
10793
+ async globFiles(filters, include, exclude) {
10661
10794
  const globOptions = {
10662
10795
  absolute: true,
10663
10796
  dot: true,
@@ -10669,10 +10802,13 @@ class Vitest {
10669
10802
  filters = filters.map((f) => toNamespacedPath(f));
10670
10803
  if (filters.length)
10671
10804
  testFiles = testFiles.filter((i) => filters.some((f) => i.includes(f)));
10805
+ return testFiles;
10806
+ }
10807
+ async globTestFiles(filters = []) {
10808
+ const { include, exclude, includeSource } = this.config;
10809
+ const testFiles = await this.globFiles(filters, include, exclude);
10672
10810
  if (includeSource) {
10673
- let files = await out(includeSource, globOptions);
10674
- if (filters.length)
10675
- files = files.filter((i) => filters.some((f) => i.includes(f)));
10811
+ const files = await this.globFiles(filters, includeSource, exclude);
10676
10812
  await Promise.all(files.map(async (file) => {
10677
10813
  try {
10678
10814
  const code = await promises.readFile(file, "utf-8");
@@ -10798,7 +10934,7 @@ const GlobalSetupPlugin = (ctx) => {
10798
10934
  }
10799
10935
  } catch (e) {
10800
10936
  ctx.logger.error(`
10801
- ${picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(" Error during global setup "))))}`);
10937
+ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
10802
10938
  await ctx.logger.printError(e);
10803
10939
  process.exit(1);
10804
10940
  }
@@ -10981,7 +11117,7 @@ function CSSEnablerPlugin(ctx) {
10981
11117
  })`;
10982
11118
  return { code };
10983
11119
  }
10984
- return { code: "" };
11120
+ return { code: 'export default ""' };
10985
11121
  }
10986
11122
  }
10987
11123
  ];
@@ -11124,7 +11260,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
11124
11260
  try {
11125
11261
  await ctx.setServer(options, server);
11126
11262
  if (options.api && options.watch)
11127
- (await import('./chunk-api-setup.47a09f0f.js')).setup(ctx);
11263
+ (await import('./chunk-api-setup.16ac28c0.js')).setup(ctx);
11128
11264
  } catch (err) {
11129
11265
  ctx.logger.printError(err, true);
11130
11266
  process.exit(1);
@@ -11173,8 +11309,8 @@ const keys = [
11173
11309
  function printShortcutsHelp() {
11174
11310
  stdout().write(
11175
11311
  `
11176
- ${picocolors.exports.bold(" Watch Usage")}
11177
- ${keys.map((i) => picocolors.exports.dim(" press ") + picocolors.exports.reset(picocolors.exports.bold(i[0])) + picocolors.exports.dim(` to ${i[1]}`)).join("\n")}
11312
+ ${c.bold(" Watch Usage")}
11313
+ ${keys.map((i) => c.dim(" press ") + c.reset(c.bold(i[0])) + c.dim(` to ${i[1]}`)).join("\n")}
11178
11314
  `
11179
11315
  );
11180
11316
  }