vitest 0.25.8 → 0.26.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 (33) hide show
  1. package/LICENSE.md +0 -142
  2. package/dist/browser.d.ts +6 -3
  3. package/dist/browser.js +9 -10
  4. package/dist/{chunk-api-setup.dc71e384.js → chunk-api-setup.08f3b356.js} +39 -42
  5. package/dist/{chunk-integrations-globals.4d261bb8.js → chunk-integrations-globals.cab94a09.js} +5 -5
  6. package/dist/{chunk-runtime-chain.f86e5250.js → chunk-runtime-chain.e655f6cc.js} +4 -5
  7. package/dist/{chunk-runtime-error.616e92ca.js → chunk-runtime-error.dfbbf9be.js} +5 -5
  8. package/dist/{chunk-runtime-mocker.99b910d0.js → chunk-runtime-mocker.35fabb8b.js} +65 -64
  9. package/dist/{chunk-runtime-rpc.42aebbb9.js → chunk-runtime-rpc.7959fc79.js} +1 -1
  10. package/dist/{chunk-runtime-setup.5398e2c4.js → chunk-runtime-setup.4c1b529e.js} +16 -29
  11. package/dist/{chunk-vite-node-externalize.b9495318.js → chunk-snapshot-manager.7d978f79.js} +36 -322
  12. package/dist/{chunk-typecheck-constants.ed987901.js → chunk-typecheck-constants.3f865d14.js} +5 -4
  13. package/dist/{chunk-runtime-test-state.3f86f48f.js → chunk-utils-import.ca62c9d7.js} +49 -18
  14. package/dist/{chunk-utils-source-map.29ff1088.js → chunk-utils-source-map.5bbb50cd.js} +6 -4
  15. package/dist/cli.js +12 -13
  16. package/dist/config.d.ts +4 -1
  17. package/dist/entry.js +9 -9
  18. package/dist/environments.d.ts +4 -1
  19. package/dist/{index-5aad25c1.d.ts → index-c3f83a58.d.ts} +1 -1
  20. package/dist/index.d.ts +28 -10
  21. package/dist/index.js +6 -6
  22. package/dist/loader.js +7 -6
  23. package/dist/node.d.ts +18 -18
  24. package/dist/node.js +14 -14
  25. package/dist/suite.js +4 -4
  26. package/dist/{types-71ccd11d.d.ts → types-56bcd6c3.d.ts} +16 -273
  27. package/dist/vendor-index.783e7f3e.js +71 -0
  28. package/dist/vendor-index.96e022fd.js +211 -0
  29. package/dist/worker.js +12 -14
  30. package/package.json +4 -4
  31. package/dist/chunk-vite-node-source-map.b4ea5792.js +0 -446
  32. package/dist/chunk-vite-node-utils.0e4a6a88.js +0 -1385
  33. package/dist/vendor-source-map-support.1ce17397.js +0 -707
@@ -1,7 +1,7 @@
1
- import { b as resolve, p as picocolors, j as join, c as basename, d as dirname, r as relative, e as distDir, f as rootDir, 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.03f840f2.js';
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.03f840f2.js';
2
2
  import { p as pLimit, s as someTasksAreOnly, i as interpretTaskModes, g as getCoverageProvider, C as CoverageProviderMap } from './chunk-integrations-coverage.befed097.js';
3
3
  import { g as getEnvPackageName } from './chunk-env-node.67948209.js';
4
- import { T as TYPECHECK_SUITE, y as ensurePackageInstalled, A as AggregateErrorPonyfill, s as slash$2, k as relativePath, z as getTests, e as getFullName, u as hasFailed, B as hasFailedSnapshot, C as getTypecheckTests, D as getSuites, E as isTypecheckTest, j as notNullish, l as shuffle, t as toArray$1, n as noop$1, F as deepMerge, b as getCallLastIndex, G as removeUndefinedValues, H as isWindows, I as stdout } from './chunk-typecheck-constants.ed987901.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.3f865d14.js';
5
5
  import { loadConfigFromFile, normalizePath, createServer, mergeConfig } from 'vite';
6
6
  import path$a from 'path';
7
7
  import url, { fileURLToPath } from 'url';
@@ -12,10 +12,8 @@ import util$2 from 'util';
12
12
  import require$$0$1 from 'stream';
13
13
  import require$$2 from 'events';
14
14
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
15
- import { w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-source-map.b4ea5792.js';
16
- import { performance } from 'perf_hooks';
17
- import createDebug from 'debug';
18
- import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, n as normalizeModuleId, b as toFilePath } from './chunk-vite-node-utils.0e4a6a88.js';
15
+ import { ViteNodeRunner } from 'vite-node/client';
16
+ import { ViteNodeServer } from 'vite-node/server';
19
17
  import { writeFile, rm } from 'fs/promises';
20
18
  import { e as execa } from './vendor-index.737c3cff.js';
21
19
  import { SourceMapConsumer } from 'source-map';
@@ -24,10 +22,13 @@ import { parse as parse$4 } from 'acorn';
24
22
  import { ancestor } from 'acorn-walk';
25
23
  import { MessageChannel } from 'worker_threads';
26
24
  import { Tinypool } from 'tinypool';
25
+ import { c as createBirpc } from './vendor-index.783e7f3e.js';
26
+ import { performance } from 'perf_hooks';
27
27
  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.793fd179.js';
28
- import { p as parseStacktrace, a as posToNumber, l as lineSplitRE } from './chunk-utils-source-map.29ff1088.js';
28
+ import { p as parseStacktrace, a as posToNumber, l as lineSplitRE } from './chunk-utils-source-map.5bbb50cd.js';
29
29
  import { resolveModule } from 'local-pkg';
30
30
  import { createHash } from 'crypto';
31
+ import { slash as slash$2 } from 'vite-node/utils';
31
32
  import { o as onetime } from './vendor-index.9c919048.js';
32
33
  import { s as signalExit } from './vendor-index.e1d4cf84.js';
33
34
  import MagicString from './chunk-magic-string.3a794426.js';
@@ -35,7 +36,7 @@ import { stripLiteral } from 'strip-literal';
35
36
  import require$$0$2 from 'readline';
36
37
  import { p as prompts } from './vendor-index.9f20a9be.js';
37
38
 
38
- var version$1 = "0.25.8";
39
+ var version$1 = "0.26.0";
39
40
 
40
41
  class EndError extends Error {
41
42
  constructor(value) {
@@ -6780,297 +6781,6 @@ function assertPatternsInput(input) {
6780
6781
  }
6781
6782
  var out = FastGlob;
6782
6783
 
6783
- const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
6784
- const ESM_FOLDER_RE = /\/(es|esm)\/(.*\.js)$/;
6785
- const defaultInline = [
6786
- /virtual:/,
6787
- /\.[mc]?ts$/
6788
- ];
6789
- const depsExternal = [
6790
- /\.cjs\.js$/,
6791
- /\.mjs$/
6792
- ];
6793
- function guessCJSversion(id) {
6794
- if (id.match(ESM_EXT_RE)) {
6795
- for (const i of [
6796
- id.replace(ESM_EXT_RE, ".mjs"),
6797
- id.replace(ESM_EXT_RE, ".umd.js"),
6798
- id.replace(ESM_EXT_RE, ".cjs.js"),
6799
- id.replace(ESM_EXT_RE, ".js")
6800
- ]) {
6801
- if (existsSync(i))
6802
- return i;
6803
- }
6804
- }
6805
- if (id.match(ESM_FOLDER_RE)) {
6806
- for (const i of [
6807
- id.replace(ESM_FOLDER_RE, "/umd/$1"),
6808
- id.replace(ESM_FOLDER_RE, "/cjs/$1"),
6809
- id.replace(ESM_FOLDER_RE, "/lib/$1"),
6810
- id.replace(ESM_FOLDER_RE, "/$1")
6811
- ]) {
6812
- if (existsSync(i))
6813
- return i;
6814
- }
6815
- }
6816
- }
6817
- const _defaultExternalizeCache = /* @__PURE__ */ new Map();
6818
- async function shouldExternalize(id, options, cache = _defaultExternalizeCache) {
6819
- if (!cache.has(id))
6820
- cache.set(id, _shouldExternalize(id, options));
6821
- return cache.get(id);
6822
- }
6823
- async function _shouldExternalize(id, options) {
6824
- if (isNodeBuiltin(id))
6825
- return id;
6826
- if (id.startsWith("data:"))
6827
- return id;
6828
- id = patchWindowsImportPath(id);
6829
- if (matchExternalizePattern(id, options == null ? void 0 : options.inline))
6830
- return false;
6831
- if (matchExternalizePattern(id, options == null ? void 0 : options.external))
6832
- return id;
6833
- const isNodeModule = id.includes("/node_modules/");
6834
- const guessCJS = isNodeModule && (options == null ? void 0 : options.fallbackCJS);
6835
- id = guessCJS ? guessCJSversion(id) || id : id;
6836
- if (matchExternalizePattern(id, defaultInline))
6837
- return false;
6838
- if (matchExternalizePattern(id, depsExternal))
6839
- return id;
6840
- const isDist = id.includes("/dist/");
6841
- if ((isNodeModule || isDist) && await isValidNodeImport(id))
6842
- return id;
6843
- return false;
6844
- }
6845
- function matchExternalizePattern(id, patterns) {
6846
- if (patterns == null)
6847
- return false;
6848
- if (patterns === true)
6849
- return true;
6850
- for (const ex of patterns) {
6851
- if (typeof ex === "string") {
6852
- if (id.includes(`/node_modules/${ex}/`))
6853
- return true;
6854
- } else {
6855
- if (ex.test(id))
6856
- return true;
6857
- }
6858
- }
6859
- return false;
6860
- }
6861
- function patchWindowsImportPath(path) {
6862
- if (path.match(/^\w:\\/))
6863
- return `file:///${slash$1(path)}`;
6864
- else if (path.match(/^\w:\//))
6865
- return `file:///${path}`;
6866
- else
6867
- return path;
6868
- }
6869
-
6870
- function hashCode(s) {
6871
- return s.split("").reduce((a, b) => {
6872
- a = (a << 5) - a + b.charCodeAt(0);
6873
- return a & a;
6874
- }, 0);
6875
- }
6876
- class Debugger {
6877
- constructor(root, options) {
6878
- this.options = options;
6879
- this.externalizeMap = /* @__PURE__ */ new Map();
6880
- if (options.dumpModules)
6881
- this.dumpDir = resolve(root, options.dumpModules === true ? ".vite-node/dump" : options.dumpModules);
6882
- if (this.dumpDir) {
6883
- if (options.loadDumppedModules)
6884
- console.info(picocolors.exports.gray(`[vite-node] [debug] load modules from ${this.dumpDir}`));
6885
- else
6886
- console.info(picocolors.exports.gray(`[vite-node] [debug] dump modules to ${this.dumpDir}`));
6887
- }
6888
- this.initPromise = this.clearDump();
6889
- }
6890
- async clearDump() {
6891
- if (!this.dumpDir)
6892
- return;
6893
- if (!this.options.loadDumppedModules && existsSync(this.dumpDir))
6894
- await promises.rm(this.dumpDir, { recursive: true, force: true });
6895
- await promises.mkdir(this.dumpDir, { recursive: true });
6896
- }
6897
- encodeId(id) {
6898
- return `${id.replace(/[^\w@_-]/g, "_").replace(/_+/g, "_")}-${hashCode(id)}.js`;
6899
- }
6900
- async recordExternalize(id, path) {
6901
- if (!this.dumpDir)
6902
- return;
6903
- this.externalizeMap.set(id, path);
6904
- await this.writeInfo();
6905
- }
6906
- async dumpFile(id, result) {
6907
- if (!result || !this.dumpDir)
6908
- return;
6909
- await this.initPromise;
6910
- const name = this.encodeId(id);
6911
- return await promises.writeFile(join(this.dumpDir, name), `// ${id.replace(/\0/g, "\\0")}
6912
- ${result.code}`, "utf-8");
6913
- }
6914
- async loadDump(id) {
6915
- if (!this.dumpDir)
6916
- return null;
6917
- await this.initPromise;
6918
- const name = this.encodeId(id);
6919
- const path = join(this.dumpDir, name);
6920
- if (!existsSync(path))
6921
- return null;
6922
- const code = await promises.readFile(path, "utf-8");
6923
- return {
6924
- code: code.replace(/^\/\/.*?\n/, ""),
6925
- map: void 0
6926
- };
6927
- }
6928
- async writeInfo() {
6929
- if (!this.dumpDir)
6930
- return;
6931
- const info = JSON.stringify({
6932
- time: new Date().toLocaleString(),
6933
- externalize: Object.fromEntries(this.externalizeMap.entries())
6934
- }, null, 2);
6935
- return promises.writeFile(join(this.dumpDir, "info.json"), info, "utf-8");
6936
- }
6937
- }
6938
-
6939
- const debugRequest = createDebug("vite-node:server:request");
6940
- class ViteNodeServer {
6941
- constructor(server, options = {}) {
6942
- this.server = server;
6943
- this.options = options;
6944
- this.fetchPromiseMap = /* @__PURE__ */ new Map();
6945
- this.transformPromiseMap = /* @__PURE__ */ new Map();
6946
- this.fetchCache = /* @__PURE__ */ new Map();
6947
- this.externalizeCache = /* @__PURE__ */ new Map();
6948
- var _a, _b;
6949
- const ssrOptions = server.config.ssr;
6950
- if (ssrOptions) {
6951
- options.deps ?? (options.deps = {});
6952
- if (ssrOptions.noExternal === true) {
6953
- (_a = options.deps).inline ?? (_a.inline = true);
6954
- } else if (options.deps.inline !== true) {
6955
- (_b = options.deps).inline ?? (_b.inline = []);
6956
- options.deps.inline.push(...toArray(ssrOptions.noExternal));
6957
- }
6958
- }
6959
- if (process.env.VITE_NODE_DEBUG_DUMP) {
6960
- options.debug = Object.assign({
6961
- dumpModules: !!process.env.VITE_NODE_DEBUG_DUMP,
6962
- loadDumppedModules: process.env.VITE_NODE_DEBUG_DUMP === "load"
6963
- }, options.debug ?? {});
6964
- }
6965
- if (options.debug)
6966
- this.debugger = new Debugger(server.config.root, options.debug);
6967
- }
6968
- shouldExternalize(id) {
6969
- return shouldExternalize(id, this.options.deps, this.externalizeCache);
6970
- }
6971
- async resolveId(id, importer) {
6972
- if (importer && !importer.startsWith(this.server.config.root))
6973
- importer = resolve(this.server.config.root, importer);
6974
- const mode = importer && this.getTransformMode(importer) || "ssr";
6975
- return this.server.pluginContainer.resolveId(id, importer, { ssr: mode === "ssr" });
6976
- }
6977
- getSourceMap(source) {
6978
- var _a, _b;
6979
- const fetchResult = (_a = this.fetchCache.get(source)) == null ? void 0 : _a.result;
6980
- if (fetchResult == null ? void 0 : fetchResult.map)
6981
- return fetchResult.map;
6982
- const ssrTransformResult = (_b = this.server.moduleGraph.getModuleById(source)) == null ? void 0 : _b.ssrTransformResult;
6983
- return (ssrTransformResult == null ? void 0 : ssrTransformResult.map) || null;
6984
- }
6985
- async fetchModule(id) {
6986
- id = normalizeModuleId(id);
6987
- if (!this.fetchPromiseMap.has(id)) {
6988
- this.fetchPromiseMap.set(
6989
- id,
6990
- this._fetchModule(id).then((r) => {
6991
- return this.options.sourcemap !== true ? { ...r, map: void 0 } : r;
6992
- }).finally(() => {
6993
- this.fetchPromiseMap.delete(id);
6994
- })
6995
- );
6996
- }
6997
- return this.fetchPromiseMap.get(id);
6998
- }
6999
- async transformRequest(id) {
7000
- if (!this.transformPromiseMap.has(id)) {
7001
- this.transformPromiseMap.set(
7002
- id,
7003
- this._transformRequest(id).finally(() => {
7004
- this.transformPromiseMap.delete(id);
7005
- })
7006
- );
7007
- }
7008
- return this.transformPromiseMap.get(id);
7009
- }
7010
- getTransformMode(id) {
7011
- var _a, _b, _c, _d;
7012
- const withoutQuery = id.split("?")[0];
7013
- if ((_b = (_a = this.options.transformMode) == null ? void 0 : _a.web) == null ? void 0 : _b.some((r) => withoutQuery.match(r)))
7014
- return "web";
7015
- if ((_d = (_c = this.options.transformMode) == null ? void 0 : _c.ssr) == null ? void 0 : _d.some((r) => withoutQuery.match(r)))
7016
- return "ssr";
7017
- if (withoutQuery.match(/\.([cm]?[jt]sx?|json)$/))
7018
- return "ssr";
7019
- return "web";
7020
- }
7021
- async _fetchModule(id) {
7022
- var _a;
7023
- let result;
7024
- const filePath = toFilePath(id, this.server.config.root);
7025
- const module = this.server.moduleGraph.getModuleById(id);
7026
- const timestamp = module ? module.lastHMRTimestamp : null;
7027
- const cache = this.fetchCache.get(filePath);
7028
- if (timestamp !== null && cache && cache.timestamp >= timestamp)
7029
- return cache.result;
7030
- const time = Date.now();
7031
- const externalize = await this.shouldExternalize(filePath);
7032
- let duration;
7033
- if (externalize) {
7034
- result = { externalize };
7035
- (_a = this.debugger) == null ? void 0 : _a.recordExternalize(id, externalize);
7036
- } else {
7037
- const start = performance.now();
7038
- const r = await this._transformRequest(id);
7039
- duration = performance.now() - start;
7040
- result = { code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
7041
- }
7042
- this.fetchCache.set(filePath, {
7043
- duration,
7044
- timestamp: time,
7045
- result
7046
- });
7047
- return result;
7048
- }
7049
- async _transformRequest(id) {
7050
- var _a, _b, _c, _d;
7051
- debugRequest(id);
7052
- let result = null;
7053
- if ((_a = this.options.debug) == null ? void 0 : _a.loadDumppedModules) {
7054
- result = await ((_b = this.debugger) == null ? void 0 : _b.loadDump(id)) ?? null;
7055
- if (result)
7056
- return result;
7057
- }
7058
- if (this.getTransformMode(id) === "web") {
7059
- result = await this.server.transformRequest(id);
7060
- if (result)
7061
- result = await this.server.ssrTransform(result.code, result.map, id);
7062
- } else {
7063
- result = await this.server.transformRequest(id, { ssr: true });
7064
- }
7065
- const sourcemap = this.options.sourcemap ?? "inline";
7066
- if (sourcemap === "inline" && result && !id.includes("node_modules"))
7067
- withInlineSourcemap(result);
7068
- if ((_c = this.options.debug) == null ? void 0 : _c.dumpModules)
7069
- await ((_d = this.debugger) == null ? void 0 : _d.dumpFile(id, result));
7070
- return result;
7071
- }
7072
- }
7073
-
7074
6784
  class SnapshotManager {
7075
6785
  constructor(options) {
7076
6786
  this.options = options;
@@ -7745,7 +7455,7 @@ function formatTestPath(root, path) {
7745
7455
  const dir = dirname(path);
7746
7456
  const ext = ((_a = path.match(/(\.(spec|test)\.[cm]?[tj]sx?)$/)) == null ? void 0 : _a[0]) || "";
7747
7457
  const base = basename(path, ext);
7748
- return slash$2(picocolors.exports.dim(`${dir}/`) + picocolors.exports.bold(base)) + picocolors.exports.dim(ext);
7458
+ return slash$1(picocolors.exports.dim(`${dir}/`) + picocolors.exports.bold(base)) + picocolors.exports.dim(ext);
7749
7459
  }
7750
7460
  function renderSnapshotSummary(rootDir, snapshots) {
7751
7461
  const summary = [];
@@ -9192,7 +8902,11 @@ async function loadCustomReporterModule(path, runner) {
9192
8902
  function createReporters(reporterReferences, runner) {
9193
8903
  const promisedReporters = reporterReferences.map(async (referenceOrInstance) => {
9194
8904
  if (typeof referenceOrInstance === "string") {
9195
- if (referenceOrInstance in ReportersMap) {
8905
+ if (referenceOrInstance === "html") {
8906
+ await ensurePackageInstalled("@vitest/ui", runner.root);
8907
+ const CustomReporter = await loadCustomReporterModule("@vitest/ui/reporter", runner);
8908
+ return new CustomReporter();
8909
+ } else if (referenceOrInstance in ReportersMap) {
9196
8910
  const BuiltinReporter = ReportersMap[referenceOrInstance];
9197
8911
  return new BuiltinReporter();
9198
8912
  } else {
@@ -9499,7 +9213,7 @@ class VitestCache {
9499
9213
  return this.stats.getStats(id);
9500
9214
  }
9501
9215
  static resolveCacheDir(root, dir) {
9502
- return resolve(root, slash$2(dir || "node_modules/.vitest"));
9216
+ return resolve(root, slash$1(dir || "node_modules/.vitest"));
9503
9217
  }
9504
9218
  static async clearCache(options) {
9505
9219
  var _a;
@@ -9530,7 +9244,7 @@ class BaseSequencer {
9530
9244
  const shardStart = shardSize * (index - 1);
9531
9245
  const shardEnd = shardSize * index;
9532
9246
  return [...files].map((file) => {
9533
- const fullPath = resolve(slash$1(config.root), slash$1(file));
9247
+ const fullPath = resolve(slash$2(config.root), slash$2(file));
9534
9248
  const specPath = fullPath == null ? void 0 : fullPath.slice(config.root.length);
9535
9249
  return {
9536
9250
  file,
@@ -9669,8 +9383,8 @@ function resolveConfig(mode, options, viteConfig) {
9669
9383
  resolved.exclude = resolved.benchmark.exclude;
9670
9384
  resolved.includeSource = resolved.benchmark.includeSource;
9671
9385
  const reporters = Array.from(/* @__PURE__ */ new Set([
9672
- ...toArray$1(resolved.benchmark.reporters),
9673
- ...toArray$1(options.reporter)
9386
+ ...toArray(resolved.benchmark.reporters),
9387
+ ...toArray(options.reporter)
9674
9388
  ])).filter(Boolean);
9675
9389
  if (reporters.length)
9676
9390
  resolved.benchmark.reporters = reporters;
@@ -9679,18 +9393,18 @@ function resolveConfig(mode, options, viteConfig) {
9679
9393
  if (options.outputFile)
9680
9394
  resolved.benchmark.outputFile = options.outputFile;
9681
9395
  }
9682
- resolved.setupFiles = toArray$1(resolved.setupFiles || []).map(
9396
+ resolved.setupFiles = toArray(resolved.setupFiles || []).map(
9683
9397
  (file) => normalize(
9684
9398
  resolveModule(file, { paths: [resolved.root] }) ?? resolve(resolved.root, file)
9685
9399
  )
9686
9400
  );
9687
9401
  resolved.api = resolveApiConfig(options);
9688
9402
  if (options.related)
9689
- resolved.related = toArray$1(options.related).map((file) => resolve(resolved.root, file));
9403
+ resolved.related = toArray(options.related).map((file) => resolve(resolved.root, file));
9690
9404
  if (mode !== "benchmark") {
9691
9405
  resolved.reporters = Array.from(/* @__PURE__ */ new Set([
9692
- ...toArray$1(resolved.reporters),
9693
- ...toArray$1(resolved.reporter)
9406
+ ...toArray(resolved.reporters),
9407
+ ...toArray(resolved.reporter)
9694
9408
  ])).filter(Boolean);
9695
9409
  }
9696
9410
  if (!resolved.reporters.length)
@@ -10207,7 +9921,7 @@ createLogUpdate(process$1.stdout);
10207
9921
 
10208
9922
  createLogUpdate(process$1.stderr);
10209
9923
 
10210
- var version = "0.25.8";
9924
+ var version = "0.26.0";
10211
9925
 
10212
9926
  function fileFromParsedStack(stack) {
10213
9927
  var _a, _b;
@@ -10565,7 +10279,7 @@ class Vitest {
10565
10279
  }
10566
10280
  });
10567
10281
  }
10568
- this.reporters = resolved.mode === "benchmark" ? await createBenchmarkReporters(toArray$1((_c = resolved.benchmark) == null ? void 0 : _c.reporters), this.runner) : await createReporters(resolved.reporters, this.runner);
10282
+ this.reporters = resolved.mode === "benchmark" ? await createBenchmarkReporters(toArray((_c = resolved.benchmark) == null ? void 0 : _c.reporters), this.runner) : await createReporters(resolved.reporters, this.runner);
10569
10283
  this.runningPromise = void 0;
10570
10284
  this.cache.results.setConfig(resolved.root, resolved.cache);
10571
10285
  try {
@@ -10752,13 +10466,13 @@ class Vitest {
10752
10466
  const files = this.state.getFiles();
10753
10467
  if (hasFailed(files))
10754
10468
  process.exitCode = 1;
10755
- if (!this.config.browser)
10756
- await this.report("onFinished", files, this.state.getUnhandledErrors());
10757
10469
  this.cache.results.updateResults(files);
10758
10470
  await this.cache.results.writeToCache();
10759
- })().finally(() => {
10760
- this.runningPromise = void 0;
10471
+ })().finally(async () => {
10761
10472
  this.state.finishCollectingPaths();
10473
+ if (!this.config.browser)
10474
+ await this.report("onFinished", this.state.getFiles(), this.state.getUnhandledErrors());
10475
+ this.runningPromise = void 0;
10762
10476
  });
10763
10477
  return await this.runningPromise;
10764
10478
  }
@@ -10831,13 +10545,13 @@ class Vitest {
10831
10545
  }
10832
10546
  registerWatcher() {
10833
10547
  const onChange = (id) => {
10834
- id = slash$2(id);
10548
+ id = slash$1(id);
10835
10549
  const needsRerun = this.handleFileChanged(id);
10836
10550
  if (needsRerun)
10837
10551
  this.scheduleRerun(id);
10838
10552
  };
10839
10553
  const onUnlink = (id) => {
10840
- id = slash$2(id);
10554
+ id = slash$1(id);
10841
10555
  this.invalidates.add(id);
10842
10556
  if (this.state.filesMap.has(id)) {
10843
10557
  this.state.filesMap.delete(id);
@@ -10848,7 +10562,7 @@ class Vitest {
10848
10562
  }
10849
10563
  };
10850
10564
  const onAdd = async (id) => {
10851
- id = slash$2(id);
10565
+ id = slash$1(id);
10852
10566
  if (await this.isTargetFile(id)) {
10853
10567
  this.changedTests.add(id);
10854
10568
  await this.cache.stats.updateStats(id);
@@ -11021,7 +10735,7 @@ async function loadGlobalSetupFiles(ctx) {
11021
10735
  var _a;
11022
10736
  const server = ctx.server;
11023
10737
  const runner = ctx.runner;
11024
- const globalSetupFiles = toArray$1((_a = server.config.test) == null ? void 0 : _a.globalSetup);
10738
+ const globalSetupFiles = toArray((_a = server.config.test) == null ? void 0 : _a.globalSetup);
11025
10739
  return Promise.all(globalSetupFiles.map((file) => loadGlobalSetupFile(file, runner)));
11026
10740
  }
11027
10741
  async function loadGlobalSetupFile(file, runner) {
@@ -11215,9 +10929,9 @@ function CSSEnablerPlugin(ctx) {
11215
10929
  const { css } = ctx.config;
11216
10930
  if (typeof css === "boolean")
11217
10931
  return css;
11218
- if (toArray$1(css.exclude).some((re) => re.test(id)))
10932
+ if (toArray(css.exclude).some((re) => re.test(id)))
11219
10933
  return false;
11220
- if (toArray$1(css.include).some((re) => re.test(id)))
10934
+ if (toArray(css.include).some((re) => re.test(id)))
11221
10935
  return true;
11222
10936
  return false;
11223
10937
  };
@@ -11392,7 +11106,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
11392
11106
  try {
11393
11107
  await ctx.setServer(options, server);
11394
11108
  if (options.api && options.watch)
11395
- (await import('./chunk-api-setup.dc71e384.js')).setup(ctx);
11109
+ (await import('./chunk-api-setup.08f3b356.js')).setup(ctx);
11396
11110
  } catch (err) {
11397
11111
  ctx.logger.printError(err, true);
11398
11112
  process.exit(1);
@@ -81,9 +81,6 @@ function notNullish(v) {
81
81
  function slash(str) {
82
82
  return str.replace(/\\/g, "/");
83
83
  }
84
- function mergeSlashes(str) {
85
- return str.replace(/\/\//g, "/");
86
- }
87
84
  const noop = () => {
88
85
  };
89
86
  function getType(value) {
@@ -229,6 +226,9 @@ function getNames(task) {
229
226
  function getWorkerState() {
230
227
  return globalThis.__vitest_worker__;
231
228
  }
229
+ function getCurrentEnvironment() {
230
+ return globalThis.__vitest_environment__;
231
+ }
232
232
 
233
233
  const isWindows = isNode && process.platform === "win32";
234
234
  const getRunMode = () => getWorkerState().config.mode;
@@ -253,6 +253,7 @@ function partitionSuiteChildren(suite) {
253
253
  function resetModules(modules, resetMocks = false) {
254
254
  const skipPaths = [
255
255
  /\/vitest\/dist\//,
256
+ /\/vite-node\/dist\//,
256
257
  /vitest-virtual-\w+\/dist/,
257
258
  /@vitest\/dist/,
258
259
  ...!resetMocks ? [/^mock:/] : []
@@ -355,4 +356,4 @@ function objectAttr(source, path, defaultValue = void 0) {
355
356
  return result;
356
357
  }
357
358
 
358
- export { AggregateErrorPonyfill as A, hasFailedSnapshot as B, getTypecheckTests as C, getSuites as D, isTypecheckTest as E, deepMerge as F, removeUndefinedValues as G, isWindows as H, stdout as I, mergeSlashes as J, getAllMockableProperties as K, RealDate as R, TYPECHECK_SUITE as T, resetModules as a, getCallLastIndex as b, getNames as c, assertTypes as d, getFullName as e, isRunningInTest as f, getWorkerState as g, isRunningInBenchmark as h, isObject as i, notNullish as j, relativePath as k, shuffle as l, mockDate as m, noop as n, objectAttr as o, partitionSuiteChildren as p, hasTests as q, resetDate as r, slash as s, toArray as t, hasFailed as u, createDefer as v, deepClone as w, getType as x, ensurePackageInstalled as y, getTests as z };
359
+ export { AggregateErrorPonyfill as A, getTests as B, hasFailedSnapshot as C, getTypecheckTests as D, getSuites as E, isTypecheckTest as F, deepMerge as G, removeUndefinedValues as H, isWindows as I, stdout as J, getAllMockableProperties as K, RealDate as R, TYPECHECK_SUITE as T, resetModules as a, getCallLastIndex as b, getNames as c, assertTypes as d, getCurrentEnvironment as e, getFullName as f, getWorkerState as g, isRunningInTest as h, isObject as i, isRunningInBenchmark as j, notNullish as k, relativePath as l, mockDate as m, noop as n, objectAttr as o, partitionSuiteChildren as p, shuffle as q, resetDate as r, slash as s, toArray as t, hasTests as u, hasFailed as v, createDefer as w, deepClone as x, getType as y, ensurePackageInstalled as z };
@@ -1,6 +1,6 @@
1
- import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, b as bench, c as createExpect, e as globalExpect } from './chunk-runtime-chain.f86e5250.js';
2
- import { g as getWorkerState, R as RealDate, r as resetDate, m as mockDate, a as resetModules } from './chunk-typecheck-constants.ed987901.js';
3
- import { p as parseStacktrace } from './chunk-utils-source-map.29ff1088.js';
1
+ import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, b as bench, c as createExpect, e as globalExpect } from './chunk-runtime-chain.e655f6cc.js';
2
+ import { g as getWorkerState, R as RealDate, r as resetDate, m as mockDate, a as resetModules } from './chunk-typecheck-constants.3f865d14.js';
3
+ import { p as parseStacktrace } from './chunk-utils-source-map.5bbb50cd.js';
4
4
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
5
5
  import util from 'util';
6
6
  import { spyOn, fn, isMockFunction, spies } from './spy.js';
@@ -8,6 +8,20 @@ import { s as safeSetTimeout } from './chunk-utils-timers.793fd179.js';
8
8
  import * as chai from 'chai';
9
9
  import { assert, should } from 'chai';
10
10
 
11
+ async function waitForImportsToResolve(tries = 0) {
12
+ await new Promise((resolve) => safeSetTimeout(resolve, 0));
13
+ const state = getWorkerState();
14
+ const promises = [];
15
+ for (const mod of state.moduleCache.values()) {
16
+ if (mod.promise && !mod.evaluated)
17
+ promises.push(mod.promise);
18
+ }
19
+ if (!promises.length && tries >= 3)
20
+ return;
21
+ await Promise.allSettled(promises);
22
+ await new Promise((resolve) => safeSetTimeout(resolve, 1)).then(() => Promise.resolve()).then(() => waitForImportsToResolve(tries + 1));
23
+ }
24
+
11
25
  let _test;
12
26
  function setCurrentTest(test) {
13
27
  _test = test;
@@ -2720,6 +2734,8 @@ class VitestUtils {
2720
2734
  constructor() {
2721
2735
  this.spyOn = spyOn;
2722
2736
  this.fn = fn;
2737
+ this._stubsGlobal = /* @__PURE__ */ new Map();
2738
+ this._stubsEnv = /* @__PURE__ */ new Map();
2723
2739
  this._config = null;
2724
2740
  this._mocker = typeof __vitest_mocker__ !== "undefined" ? __vitest_mocker__ : null;
2725
2741
  this._mockedDate = null;
@@ -2829,11 +2845,35 @@ class VitestUtils {
2829
2845
  return this;
2830
2846
  }
2831
2847
  stubGlobal(name, value) {
2832
- if (globalThis.window) {
2833
- globalThis.window[name] = value;
2834
- } else {
2835
- globalThis[name] = value;
2836
- }
2848
+ if (!this._stubsGlobal.has(name))
2849
+ this._stubsGlobal.set(name, Object.getOwnPropertyDescriptor(globalThis, name));
2850
+ globalThis[name] = value;
2851
+ return this;
2852
+ }
2853
+ stubEnv(name, value) {
2854
+ if (!this._stubsEnv.has(name))
2855
+ this._stubsEnv.set(name, process.env[name]);
2856
+ process.env[name] = value;
2857
+ return this;
2858
+ }
2859
+ unstubAllGlobals() {
2860
+ this._stubsGlobal.forEach((original, name) => {
2861
+ if (!original)
2862
+ Reflect.deleteProperty(globalThis, name);
2863
+ else
2864
+ Object.defineProperty(globalThis, name, original);
2865
+ });
2866
+ this._stubsGlobal.clear();
2867
+ return this;
2868
+ }
2869
+ unstubAllEnvs() {
2870
+ this._stubsEnv.forEach((original, name) => {
2871
+ if (original === void 0)
2872
+ delete process.env[name];
2873
+ else
2874
+ process.env[name] = original;
2875
+ });
2876
+ this._stubsEnv.clear();
2837
2877
  return this;
2838
2878
  }
2839
2879
  resetModules() {
@@ -2842,16 +2882,7 @@ class VitestUtils {
2842
2882
  return this;
2843
2883
  }
2844
2884
  async dynamicImportSettled() {
2845
- const state = getWorkerState();
2846
- const promises = [];
2847
- for (const mod of state.moduleCache.values()) {
2848
- if (mod.promise && !mod.evaluated)
2849
- promises.push(mod.promise);
2850
- }
2851
- if (!promises.length)
2852
- return;
2853
- await Promise.allSettled(promises);
2854
- await new Promise((resolve) => safeSetTimeout(resolve, 1)).then(() => Promise.resolve()).then(() => this.dynamicImportSettled());
2885
+ return waitForImportsToResolve();
2855
2886
  }
2856
2887
  setConfig(config) {
2857
2888
  const state = getWorkerState();
@@ -1,12 +1,13 @@
1
- import { s as slash, j as notNullish } from './chunk-typecheck-constants.ed987901.js';
1
+ import { b as resolve } from './chunk-utils-env.03f840f2.js';
2
+ import { k as notNullish } from './chunk-typecheck-constants.3f865d14.js';
2
3
 
3
4
  const lineSplitRE = /\r?\n/;
4
5
  const stackIgnorePatterns = [
5
6
  "node:internal",
6
7
  "/vitest/dist/",
7
- "/vite-node/dist",
8
- "/vite-node/src",
9
8
  "/vitest/src/",
9
+ "/vite-node/dist/",
10
+ "/vite-node/src/",
10
11
  "/node_modules/chai/",
11
12
  "/node_modules/tinypool/",
12
13
  "/node_modules/tinyspy/"
@@ -42,11 +43,12 @@ function parseStacktrace(e, full = false) {
42
43
  method = method.slice(6);
43
44
  if (file.startsWith("file://"))
44
45
  file = file.slice(7);
46
+ file = resolve(file);
45
47
  if (!full && stackIgnorePatterns.some((p) => file && file.includes(p)))
46
48
  return null;
47
49
  return {
48
50
  method,
49
- file: slash(file),
51
+ file,
50
52
  line: parseInt(lineNumber),
51
53
  column: parseInt(columnNumber)
52
54
  };