vitest 0.8.4 → 0.8.5

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.
@@ -1,4 +1,4 @@
1
- import { e as notNullish, d as c } from './chunk-utils-base.8408f73a.js';
1
+ import { s as slash, e as notNullish, c } from './chunk-utils-base.aff0a195.js';
2
2
 
3
3
  const setTimeout$1 = globalThis.setTimeout;
4
4
  const setInterval = globalThis.setInterval;
@@ -3360,7 +3360,7 @@ function parseStacktrace(e, full = false) {
3360
3360
  const match = line.match(stackFnCallRE) || line.match(stackBarePathRE);
3361
3361
  if (!match)
3362
3362
  return null;
3363
- let file = match[2];
3363
+ let file = slash(match[2]);
3364
3364
  if (file.startsWith("file://"))
3365
3365
  file = file.slice(7);
3366
3366
  if (!full && stackIgnorePatterns.some((p) => file.includes(p)))
@@ -4589,9 +4589,10 @@ function cliTruncate(text, columns, options) {
4589
4589
  function formatLine(line, outputTruncateLength) {
4590
4590
  return cliTruncate(line, (outputTruncateLength ?? (process.stdout.columns || 80)) - 4);
4591
4591
  }
4592
- function unifiedDiff(actual, expected, outputTruncateLength) {
4592
+ function unifiedDiff(actual, expected, options = {}) {
4593
4593
  if (actual === expected)
4594
4594
  return "";
4595
+ const { outputTruncateLength, showLegend = true } = options;
4595
4596
  const indent = " ";
4596
4597
  const diffLimit = 15;
4597
4598
  const counts = {
@@ -4638,13 +4639,15 @@ function unifiedDiff(actual, expected, outputTruncateLength) {
4638
4639
  return "--";
4639
4640
  return ` ${line}`;
4640
4641
  });
4641
- if (isCompact) {
4642
- formatted = [
4643
- `${c.green("- Expected")} ${formatted[0]}`,
4644
- `${c.red("+ Received")} ${formatted[1]}`
4645
- ];
4646
- } else {
4647
- formatted.unshift(c.green(`- Expected - ${counts["-"]}`), c.red(`+ Received + ${counts["+"]}`), "");
4642
+ if (showLegend) {
4643
+ if (isCompact) {
4644
+ formatted = [
4645
+ `${c.green("- Expected")} ${formatted[0]}`,
4646
+ `${c.red("+ Received")} ${formatted[1]}`
4647
+ ];
4648
+ } else {
4649
+ formatted.unshift(c.green(`- Expected - ${counts["-"]}`), c.red(`+ Received + ${counts["+"]}`), "");
4650
+ }
4648
4651
  }
4649
4652
  return formatted.map((i) => indent + i).join("\n");
4650
4653
  }
@@ -5,17 +5,17 @@ import process$2 from 'process';
5
5
  import { o as onExit, m as mergeStream, g as getStream, c as crossSpawn, a as onetime$1 } from './vendor-index.87b2fc14.js';
6
6
  import url, { fileURLToPath, pathToFileURL } from 'url';
7
7
  import require$$0, { constants as constants$8, hostname, cpus } from 'os';
8
- import { j as join, d as c, s as slash$2, f as isAbsolute, r as relative, h as dirname, k as basename, l as getFullName, m as hasFailed, o as hasFailedSnapshot, p as getSuites, q as getTests, u as resolve, t as toArray, n as noop$1, v as deepMerge, w as toNamespacedPath, g as getCallLastIndex, e as notNullish, x as ensurePackageInstalled } from './chunk-utils-base.8408f73a.js';
8
+ import { j as join, f as basename, h as dirname, c, s as slash$2, k as isAbsolute, r as relative, l as getFullName, m as hasFailed, o as hasFailedSnapshot, p as getSuites, q as getTests, u as resolve, t as toArray, n as noop$1, v as deepMerge, w as toNamespacedPath, g as getCallLastIndex, e as notNullish, x as ensurePackageInstalled } from './chunk-utils-base.aff0a195.js';
9
9
  import { createServer, mergeConfig } from 'vite';
10
10
  import fs$8, { promises, existsSync } from 'fs';
11
- import { d as distDir, a as defaultPort, c as configFiles } from './chunk-constants.6062c404.js';
11
+ import { d as distDir, a as defaultPort, c as configFiles } from './chunk-constants.76cf224a.js';
12
12
  import require$$0$1 from 'util';
13
13
  import require$$0$2 from 'stream';
14
14
  import require$$2 from 'events';
15
- import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.3c7ce184.js';
16
- import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.e5535971.js';
15
+ import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.a6890356.js';
16
+ import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.e85b72aa.js';
17
17
  import { performance } from 'perf_hooks';
18
- import { b as stripAnsi, d as stringWidth, e as ansiStyles, f as sliceAnsi, h as setInterval, i as clearInterval, j as cliTruncate, s as setTimeout$1, a as parseStacktrace, k as interpretSourcePos, u as unifiedDiff, p as posToNumber, l as lineSplitRE, c as clearTimeout$1 } from './chunk-utils-timers.7bdeea22.js';
18
+ import { b as stripAnsi, d as stringWidth, e as ansiStyles, f as sliceAnsi, h as setInterval, i as clearInterval, j as cliTruncate, s as setTimeout$1, a as parseStacktrace, k as interpretSourcePos, u as unifiedDiff, p as posToNumber, l as lineSplitRE, c as clearTimeout$1 } from './chunk-utils-timers.5657f2a4.js';
19
19
  import { a as commonjsGlobal } from './vendor-_commonjsHelpers.34b404ce.js';
20
20
  import assert$1 from 'assert';
21
21
  import { MessageChannel } from 'worker_threads';
@@ -24,7 +24,7 @@ import MagicString from './chunk-magic-string.d5e0e473.js';
24
24
  import require$$0$3 from 'readline';
25
25
  import { p as prompts } from './vendor-index.ee829ed6.js';
26
26
 
27
- var version = "0.8.4";
27
+ var version = "0.8.5";
28
28
 
29
29
  function stripFinalNewline(input) {
30
30
  const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
@@ -10432,21 +10432,21 @@ function patchWindowsImportPath(path) {
10432
10432
  return path;
10433
10433
  }
10434
10434
 
10435
- var __defProp$4 = Object.defineProperty;
10435
+ var __defProp$5 = Object.defineProperty;
10436
10436
  var __defProps$4 = Object.defineProperties;
10437
10437
  var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
10438
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
10439
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
10440
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
10441
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10442
- var __spreadValues$4 = (a, b) => {
10438
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
10439
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
10440
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
10441
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10442
+ var __spreadValues$5 = (a, b) => {
10443
10443
  for (var prop in b || (b = {}))
10444
- if (__hasOwnProp$4.call(b, prop))
10445
- __defNormalProp$4(a, prop, b[prop]);
10446
- if (__getOwnPropSymbols$4)
10447
- for (var prop of __getOwnPropSymbols$4(b)) {
10448
- if (__propIsEnum$4.call(b, prop))
10449
- __defNormalProp$4(a, prop, b[prop]);
10444
+ if (__hasOwnProp$5.call(b, prop))
10445
+ __defNormalProp$5(a, prop, b[prop]);
10446
+ if (__getOwnPropSymbols$5)
10447
+ for (var prop of __getOwnPropSymbols$5(b)) {
10448
+ if (__propIsEnum$5.call(b, prop))
10449
+ __defNormalProp$5(a, prop, b[prop]);
10450
10450
  }
10451
10451
  return a;
10452
10452
  };
@@ -10471,7 +10471,7 @@ class ViteNodeServer {
10471
10471
  async fetchModule(id) {
10472
10472
  if (!this.fetchPromiseMap.has(id)) {
10473
10473
  this.fetchPromiseMap.set(id, this._fetchModule(id).then((r) => {
10474
- return this.options.sourcemap !== true ? __spreadProps$4(__spreadValues$4({}, r), { map: void 0 }) : r;
10474
+ return this.options.sourcemap !== true ? __spreadProps$4(__spreadValues$5({}, r), { map: void 0 }) : r;
10475
10475
  }).finally(() => {
10476
10476
  this.fetchPromiseMap.delete(id);
10477
10477
  }));
@@ -10535,17 +10535,24 @@ class ViteNodeServer {
10535
10535
  }
10536
10536
 
10537
10537
  class SnapshotManager {
10538
- constructor(config) {
10539
- this.config = config;
10538
+ constructor(options) {
10539
+ this.options = options;
10540
10540
  this.summary = void 0;
10541
+ this.extension = ".snap";
10541
10542
  this.clear();
10542
10543
  }
10543
10544
  clear() {
10544
- this.summary = emptySummary(this.config.snapshotOptions);
10545
+ this.summary = emptySummary(this.options);
10545
10546
  }
10546
10547
  add(result) {
10547
10548
  addSnapshotResult(this.summary, result);
10548
10549
  }
10550
+ resolvePath(testPath) {
10551
+ const resolver = this.options.resolveSnapshotPath || (() => {
10552
+ return join(join(dirname(testPath), "__snapshots__"), `${basename(testPath)}${this.extension}`);
10553
+ });
10554
+ return resolver(testPath, this.extension);
10555
+ }
10549
10556
  }
10550
10557
  function emptySummary(options) {
10551
10558
  const summary = {
@@ -12109,21 +12116,21 @@ class TapReporter {
12109
12116
  }
12110
12117
  }
12111
12118
 
12112
- var __defProp$3 = Object.defineProperty;
12119
+ var __defProp$4 = Object.defineProperty;
12113
12120
  var __defProps$3 = Object.defineProperties;
12114
12121
  var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
12115
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
12116
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
12117
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
12118
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12119
- var __spreadValues$3 = (a, b) => {
12122
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
12123
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
12124
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
12125
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12126
+ var __spreadValues$4 = (a, b) => {
12120
12127
  for (var prop in b || (b = {}))
12121
- if (__hasOwnProp$3.call(b, prop))
12122
- __defNormalProp$3(a, prop, b[prop]);
12123
- if (__getOwnPropSymbols$3)
12124
- for (var prop of __getOwnPropSymbols$3(b)) {
12125
- if (__propIsEnum$3.call(b, prop))
12126
- __defNormalProp$3(a, prop, b[prop]);
12128
+ if (__hasOwnProp$4.call(b, prop))
12129
+ __defNormalProp$4(a, prop, b[prop]);
12130
+ if (__getOwnPropSymbols$4)
12131
+ for (var prop of __getOwnPropSymbols$4(b)) {
12132
+ if (__propIsEnum$4.call(b, prop))
12133
+ __defNormalProp$4(a, prop, b[prop]);
12127
12134
  }
12128
12135
  return a;
12129
12136
  };
@@ -12133,7 +12140,7 @@ function flattenTasks$1(task, baseName = "") {
12133
12140
  if (task.type === "suite") {
12134
12141
  return task.tasks.flatMap((child) => flattenTasks$1(child, `${base}${task.name}`));
12135
12142
  } else {
12136
- return [__spreadProps$3(__spreadValues$3({}, task), {
12143
+ return [__spreadProps$3(__spreadValues$4({}, task), {
12137
12144
  name: `${base}${task.name}`
12138
12145
  })];
12139
12146
  }
@@ -12241,7 +12248,7 @@ class JUnitReporter {
12241
12248
  failures: 0,
12242
12249
  skipped: 0
12243
12250
  });
12244
- return __spreadProps$3(__spreadValues$3({}, file), {
12251
+ return __spreadProps$3(__spreadValues$4({}, file), {
12245
12252
  tasks,
12246
12253
  stats
12247
12254
  });
@@ -12267,21 +12274,21 @@ class JUnitReporter {
12267
12274
  }
12268
12275
  }
12269
12276
 
12270
- var __defProp$2 = Object.defineProperty;
12277
+ var __defProp$3 = Object.defineProperty;
12271
12278
  var __defProps$2 = Object.defineProperties;
12272
12279
  var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
12273
- var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
12274
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
12275
- var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
12276
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12277
- var __spreadValues$2 = (a, b) => {
12280
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
12281
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
12282
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
12283
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12284
+ var __spreadValues$3 = (a, b) => {
12278
12285
  for (var prop in b || (b = {}))
12279
- if (__hasOwnProp$2.call(b, prop))
12280
- __defNormalProp$2(a, prop, b[prop]);
12281
- if (__getOwnPropSymbols$2)
12282
- for (var prop of __getOwnPropSymbols$2(b)) {
12283
- if (__propIsEnum$2.call(b, prop))
12284
- __defNormalProp$2(a, prop, b[prop]);
12286
+ if (__hasOwnProp$3.call(b, prop))
12287
+ __defNormalProp$3(a, prop, b[prop]);
12288
+ if (__getOwnPropSymbols$3)
12289
+ for (var prop of __getOwnPropSymbols$3(b)) {
12290
+ if (__propIsEnum$3.call(b, prop))
12291
+ __defNormalProp$3(a, prop, b[prop]);
12285
12292
  }
12286
12293
  return a;
12287
12294
  };
@@ -12291,7 +12298,7 @@ function flattenTasks(task, baseName = "") {
12291
12298
  if (task.type === "suite" && task.tasks.length > 0) {
12292
12299
  return task.tasks.flatMap((child) => flattenTasks(child, `${base}${task.name}`));
12293
12300
  } else {
12294
- return [__spreadProps$2(__spreadValues$2({}, task), {
12301
+ return [__spreadProps$2(__spreadValues$3({}, task), {
12295
12302
  name: `${base}${task.name}`
12296
12303
  })];
12297
12304
  }
@@ -12397,6 +12404,9 @@ function createChannel(ctx) {
12397
12404
  snapshotSaved(snapshot) {
12398
12405
  ctx.snapshot.add(snapshot);
12399
12406
  },
12407
+ resolveSnapshotPath(testPath) {
12408
+ return ctx.snapshot.resolvePath(testPath);
12409
+ },
12400
12410
  async getSourceMap(id, force) {
12401
12411
  if (force) {
12402
12412
  const mod = ctx.server.moduleGraph.getModuleById(id);
@@ -12490,21 +12500,21 @@ class StateManager {
12490
12500
  }
12491
12501
  }
12492
12502
 
12493
- var __defProp$1 = Object.defineProperty;
12503
+ var __defProp$2 = Object.defineProperty;
12494
12504
  var __defProps$1 = Object.defineProperties;
12495
12505
  var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
12496
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
12497
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
12498
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
12499
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12500
- var __spreadValues$1 = (a, b) => {
12506
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
12507
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
12508
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
12509
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12510
+ var __spreadValues$2 = (a, b) => {
12501
12511
  for (var prop in b || (b = {}))
12502
- if (__hasOwnProp$1.call(b, prop))
12503
- __defNormalProp$1(a, prop, b[prop]);
12504
- if (__getOwnPropSymbols$1)
12505
- for (var prop of __getOwnPropSymbols$1(b)) {
12506
- if (__propIsEnum$1.call(b, prop))
12507
- __defNormalProp$1(a, prop, b[prop]);
12512
+ if (__hasOwnProp$2.call(b, prop))
12513
+ __defNormalProp$2(a, prop, b[prop]);
12514
+ if (__getOwnPropSymbols$2)
12515
+ for (var prop of __getOwnPropSymbols$2(b)) {
12516
+ if (__propIsEnum$2.call(b, prop))
12517
+ __defNormalProp$2(a, prop, b[prop]);
12508
12518
  }
12509
12519
  return a;
12510
12520
  };
@@ -12534,7 +12544,7 @@ function resolveApiConfig(options) {
12534
12544
  if (options.api.host)
12535
12545
  api.host = options.api.host;
12536
12546
  } else {
12537
- api = __spreadValues$1({}, options.api);
12547
+ api = __spreadValues$2({}, options.api);
12538
12548
  }
12539
12549
  }
12540
12550
  if (api) {
@@ -12551,7 +12561,7 @@ function resolveConfig(options, viteConfig) {
12551
12561
  }
12552
12562
  options.environment = "happy-dom";
12553
12563
  }
12554
- const resolved = __spreadProps$1(__spreadValues$1(__spreadValues$1({}, configDefaults), options), {
12564
+ const resolved = __spreadProps$1(__spreadValues$2(__spreadValues$2({}, configDefaults), options), {
12555
12565
  root: viteConfig.root
12556
12566
  });
12557
12567
  if (viteConfig.base !== "/")
@@ -12565,8 +12575,11 @@ function resolveConfig(options, viteConfig) {
12565
12575
  const UPDATE_SNAPSHOT = resolved.update || process.env.UPDATE_SNAPSHOT;
12566
12576
  resolved.snapshotOptions = {
12567
12577
  snapshotFormat: resolved.snapshotFormat || {},
12568
- updateSnapshot: CI && !UPDATE_SNAPSHOT ? "none" : UPDATE_SNAPSHOT ? "all" : "new"
12578
+ updateSnapshot: CI && !UPDATE_SNAPSHOT ? "none" : UPDATE_SNAPSHOT ? "all" : "new",
12579
+ resolveSnapshotPath: options.resolveSnapshotPath
12569
12580
  };
12581
+ if (options.resolveSnapshotPath)
12582
+ delete resolved.resolveSnapshotPath;
12570
12583
  if (process.env.VITEST_MAX_THREADS)
12571
12584
  resolved.maxThreads = parseInt(process.env.VITEST_MAX_THREADS);
12572
12585
  if (process.env.VITEST_MIN_THREADS)
@@ -12643,7 +12656,7 @@ As a temporary workaround you can try to inline the package by updating your con
12643
12656
  `)));
12644
12657
  }
12645
12658
  function displayDiff(actual, expected, console, outputTruncateLength) {
12646
- console.error(c.gray(unifiedDiff(actual, expected, outputTruncateLength)) + "\n");
12659
+ console.error(c.gray(unifiedDiff(actual, expected, { outputTruncateLength })) + "\n");
12647
12660
  }
12648
12661
  function printErrorMessage(error, console) {
12649
12662
  const errorName = error.name || error.nameStr || "Unknown Error";
@@ -12763,6 +12776,22 @@ class VitestGit {
12763
12776
  }
12764
12777
  }
12765
12778
 
12779
+ var __defProp$1 = Object.defineProperty;
12780
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
12781
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
12782
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
12783
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12784
+ var __spreadValues$1 = (a, b) => {
12785
+ for (var prop in b || (b = {}))
12786
+ if (__hasOwnProp$1.call(b, prop))
12787
+ __defNormalProp$1(a, prop, b[prop]);
12788
+ if (__getOwnPropSymbols$1)
12789
+ for (var prop of __getOwnPropSymbols$1(b)) {
12790
+ if (__propIsEnum$1.call(b, prop))
12791
+ __defNormalProp$1(a, prop, b[prop]);
12792
+ }
12793
+ return a;
12794
+ };
12766
12795
  const WATCHER_DEBOUNCE = 100;
12767
12796
  const CLOSE_TIMEOUT = 1e3;
12768
12797
  class Vitest {
@@ -12794,7 +12823,7 @@ class Vitest {
12794
12823
  this.server = server;
12795
12824
  this.config = resolved;
12796
12825
  this.state = new StateManager();
12797
- this.snapshot = new SnapshotManager(resolved);
12826
+ this.snapshot = new SnapshotManager(__spreadValues$1({}, resolved.snapshotOptions));
12798
12827
  this.reporters = resolved.reporters.map((i) => {
12799
12828
  if (typeof i === "string") {
12800
12829
  const Reporter = ReportersMap[i];
@@ -12814,6 +12843,8 @@ class Vitest {
12814
12843
  }
12815
12844
  getConfig() {
12816
12845
  const hasCustomReporter = toArray(this.config.reporters).some((reporter) => typeof reporter !== "string");
12846
+ if (this.config.snapshotOptions.resolveSnapshotPath)
12847
+ this.config.snapshotOptions.resolveSnapshotPath = void 0;
12817
12848
  if (!hasCustomReporter && !this.configOverride)
12818
12849
  return this.config;
12819
12850
  const config = deepMerge({}, this.config);
@@ -12893,7 +12924,7 @@ Run with \`--passWithNoTests\`to exit with code 0
12893
12924
  }));
12894
12925
  const runningTests = [];
12895
12926
  for (const [filepath, deps] of testDeps) {
12896
- if (deps.size && related.some((path) => deps.has(path)))
12927
+ if (deps.size && related.some((path) => path === filepath || deps.has(path)))
12897
12928
  runningTests.push(filepath);
12898
12929
  }
12899
12930
  return runningTests;
@@ -13231,6 +13262,12 @@ function hoistMocks(code) {
13231
13262
  }
13232
13263
  return m;
13233
13264
  }
13265
+ const API_NOT_FOUND_ERROR = `There are some problems in resolving the mocks API.
13266
+ You may encounter this issue when importing the mocks API from another module other than 'vitest'.
13267
+
13268
+ To fix this issue you can either:
13269
+ - import the mocks API directly from 'vitest'
13270
+ - enable the 'globals' options`;
13234
13271
  const MocksPlugin = () => {
13235
13272
  return {
13236
13273
  name: "vitest:mock-plugin",
@@ -13239,11 +13276,17 @@ const MocksPlugin = () => {
13239
13276
  const m = hoistMocks(code);
13240
13277
  if (m) {
13241
13278
  const vitestImports = code.matchAll(vitestRegexp);
13279
+ let found = false;
13242
13280
  for (const match of vitestImports) {
13243
13281
  const indexStart = match.index;
13244
13282
  const indexEnd = match[0].length + indexStart;
13245
13283
  m.remove(indexStart, indexEnd);
13246
13284
  m.prepend(`${match[0]}
13285
+ `);
13286
+ found = true;
13287
+ }
13288
+ if (!found) {
13289
+ m.prepend(`try { vi } catch (_) { try { vitest } catch (__){ throw new Error(${JSON.stringify(API_NOT_FOUND_ERROR)}) } }
13247
13290
  `);
13248
13291
  }
13249
13292
  return {
@@ -13385,7 +13428,10 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
13385
13428
  open: preOptions.ui && preOptions.open ? preOptions.uiBase ?? "/__vitest__/" : void 0,
13386
13429
  preTransformRequests: false
13387
13430
  }),
13388
- cacheDir: void 0
13431
+ cacheDir: void 0,
13432
+ optimizeDeps: {
13433
+ entries: []
13434
+ }
13389
13435
  };
13390
13436
  },
13391
13437
  async configResolved(viteConfig) {
@@ -13408,7 +13454,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
13408
13454
  await ctx.setServer(options, server);
13409
13455
  haveStarted = true;
13410
13456
  if (options.api && options.watch)
13411
- (await import('./chunk-api-setup.175eacf7.js')).setup(ctx);
13457
+ (await import('./chunk-api-setup.da2f55ae.js')).setup(ctx);
13412
13458
  if (!options.watch)
13413
13459
  await server.watcher.close();
13414
13460
  }
@@ -1,7 +1,7 @@
1
1
  import { builtinModules, createRequire } from 'module';
2
2
  import { pathToFileURL, fileURLToPath as fileURLToPath$2, URL as URL$1 } from 'url';
3
3
  import vm from 'vm';
4
- import { f as isAbsolute$2, u as resolve, j as join$2, y as extname$2, h as dirname$2 } from './chunk-utils-base.8408f73a.js';
4
+ import { k as isAbsolute$2, u as resolve, j as join$2, y as extname$2, h as dirname$2 } from './chunk-utils-base.aff0a195.js';
5
5
  import path from 'path';
6
6
  import fs, { realpathSync, statSync, Stats, promises, existsSync } from 'fs';
7
7
  import assert from 'assert';
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'events';
2
- import { d as c } from './chunk-utils-base.8408f73a.js';
3
- import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.8c747551.js';
2
+ import { c } from './chunk-utils-base.aff0a195.js';
3
+ import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.e472da7d.js';
4
4
  import 'path';
5
5
  import 'tty';
6
6
  import 'local-pkg';
@@ -16,13 +16,13 @@ import 'util';
16
16
  import 'url';
17
17
  import 'os';
18
18
  import 'vite';
19
- import './chunk-constants.6062c404.js';
20
- import './chunk-vite-node-utils.3c7ce184.js';
19
+ import './chunk-constants.76cf224a.js';
20
+ import './chunk-vite-node-utils.a6890356.js';
21
21
  import 'module';
22
22
  import 'vm';
23
- import './chunk-defaults.e5535971.js';
23
+ import './chunk-defaults.e85b72aa.js';
24
24
  import 'perf_hooks';
25
- import './chunk-utils-timers.7bdeea22.js';
25
+ import './chunk-utils-timers.5657f2a4.js';
26
26
  import 'worker_threads';
27
27
  import 'tinypool';
28
28
  import './chunk-magic-string.d5e0e473.js';
package/dist/config.cjs CHANGED
@@ -27,7 +27,7 @@ const coverageConfigDefaults = {
27
27
  allowExternal: false,
28
28
  extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
29
29
  };
30
- const configDefaults = Object.freeze({
30
+ const config = {
31
31
  allowOnly: !process.env.CI,
32
32
  watch: !process.env.CI,
33
33
  globals: false,
@@ -50,7 +50,8 @@ const configDefaults = Object.freeze({
50
50
  uiBase: "/__vitest__/",
51
51
  open: true,
52
52
  coverage: coverageConfigDefaults
53
- });
53
+ };
54
+ const configDefaults = Object.freeze(config);
54
55
 
55
56
  function defineConfig(config) {
56
57
  return config;
package/dist/config.d.ts CHANGED
@@ -1,7 +1,31 @@
1
1
  import { UserConfig as UserConfig$2 } from 'vite';
2
- import { UserConfig as UserConfig$1 } from 'vitest';
2
+ import { UserConfig as UserConfig$1, ResolvedC8Options } from 'vitest';
3
3
 
4
- declare const configDefaults: UserConfig$1;
4
+ declare const config: {
5
+ allowOnly: boolean;
6
+ watch: boolean;
7
+ globals: boolean;
8
+ environment: "node";
9
+ threads: boolean;
10
+ clearMocks: boolean;
11
+ restoreMocks: boolean;
12
+ mockReset: boolean;
13
+ include: string[];
14
+ exclude: string[];
15
+ testTimeout: number;
16
+ hookTimeout: number;
17
+ isolate: boolean;
18
+ watchIgnore: RegExp[];
19
+ update: boolean;
20
+ reporters: never[];
21
+ silent: boolean;
22
+ api: boolean;
23
+ ui: boolean;
24
+ uiBase: string;
25
+ open: boolean;
26
+ coverage: ResolvedC8Options;
27
+ };
28
+ declare const configDefaults: Required<Pick<UserConfig$1, keyof typeof config>>;
5
29
 
6
30
  interface UserConfig extends UserConfig$2 {
7
31
  test?: UserConfig$2['test'];
package/dist/config.js CHANGED
@@ -23,7 +23,7 @@ const coverageConfigDefaults = {
23
23
  allowExternal: false,
24
24
  extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
25
25
  };
26
- const configDefaults = Object.freeze({
26
+ const config = {
27
27
  allowOnly: !process.env.CI,
28
28
  watch: !process.env.CI,
29
29
  globals: false,
@@ -46,7 +46,8 @@ const configDefaults = Object.freeze({
46
46
  uiBase: "/__vitest__/",
47
47
  open: true,
48
48
  coverage: coverageConfigDefaults
49
- });
49
+ };
50
+ const configDefaults = Object.freeze(config);
50
51
 
51
52
  function defineConfig(config) {
52
53
  return config;