vitest 0.25.3 → 0.25.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.
Files changed (33) hide show
  1. package/dist/browser.d.ts +3 -3
  2. package/dist/browser.js +10 -9
  3. package/dist/{chunk-api-setup.c9f38753.js → chunk-api-setup.995f6ab7.js} +4 -2
  4. package/dist/{chunk-integrations-globals.1e636d22.js → chunk-integrations-globals.57158eb5.js} +7 -7
  5. package/dist/{chunk-runtime-chain.f993b1dc.js → chunk-runtime-chain.dd978482.js} +8 -7
  6. package/dist/{chunk-runtime-error.6287172c.js → chunk-runtime-error.616e92ca.js} +2 -2
  7. package/dist/{chunk-runtime-mocker.c4d85347.js → chunk-runtime-mocker.34e72575.js} +34 -18
  8. package/dist/{chunk-runtime-rpc.1e7530d3.js → chunk-runtime-rpc.42aebbb9.js} +2 -2
  9. package/dist/chunk-runtime-setup.bd2deed4.js +659 -0
  10. package/dist/{chunk-runtime-test-state.de4d6ff8.js → chunk-runtime-test-state.0037e2e0.js} +8 -6
  11. package/dist/{chunk-typecheck-constants.4891f22f.js → chunk-typecheck-constants.ed987901.js} +12 -2
  12. package/dist/{chunk-utils-source-map.c6dfbbc1.js → chunk-utils-source-map.29ff1088.js} +3 -1
  13. package/dist/{chunk-utils-timers.06f993db.js → chunk-utils-timers.793fd179.js} +2 -0
  14. package/dist/{chunk-vite-node-externalize.c57d0ad1.js → chunk-vite-node-externalize.ca4784be.js} +74 -33
  15. package/dist/{chunk-vite-node-client.58cb6bfa.js → chunk-vite-node-source-map.d0aa773d.js} +56 -18
  16. package/dist/{chunk-vite-node-utils.f6d73fbe.js → chunk-vite-node-utils.9047cb87.js} +4 -14
  17. package/dist/cli.js +8 -7
  18. package/dist/config.cjs +2 -1
  19. package/dist/config.d.ts +2 -1
  20. package/dist/config.js +2 -1
  21. package/dist/entry.js +9 -8
  22. package/dist/environments.d.ts +1 -1
  23. package/dist/{index-9f5bc072.d.ts → index-2f15c9a8.d.ts} +1 -1
  24. package/dist/index.d.ts +5 -5
  25. package/dist/index.js +7 -7
  26. package/dist/loader.js +2 -2
  27. package/dist/node.d.ts +5 -4
  28. package/dist/node.js +9 -8
  29. package/dist/suite.js +6 -6
  30. package/dist/{types-de0e0997.d.ts → types-79a05dee.d.ts} +72 -24
  31. package/dist/{chunk-runtime-setup.667a5719.js → vendor-source-map-support.1ce17397.js} +1 -657
  32. package/dist/worker.js +9 -7
  33. package/package.json +4 -4
@@ -230,7 +230,7 @@ function getWorkerState() {
230
230
  return globalThis.__vitest_worker__;
231
231
  }
232
232
 
233
- isNode && process.platform === "win32";
233
+ const isWindows = isNode && process.platform === "win32";
234
234
  const getRunMode = () => getWorkerState().config.mode;
235
235
  const isRunningInTest = () => getRunMode() === "test";
236
236
  const isRunningInBenchmark = () => getRunMode() === "benchmark";
@@ -344,5 +344,15 @@ function createDefer() {
344
344
  p.reject = reject;
345
345
  return p;
346
346
  }
347
+ function objectAttr(source, path, defaultValue = void 0) {
348
+ const paths = path.replace(/\[(\d+)\]/g, ".$1").split(".");
349
+ let result = source;
350
+ for (const p of paths) {
351
+ result = Object(result)[p];
352
+ if (result === void 0)
353
+ return defaultValue;
354
+ }
355
+ return result;
356
+ }
347
357
 
348
- export { AggregateErrorPonyfill as A, getTypecheckTests as B, getSuites as C, isTypecheckTest as D, deepMerge as E, removeUndefinedValues as F, stdout as G, mergeSlashes as H, getAllMockableProperties as I, 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, hasTests as o, partitionSuiteChildren as p, hasFailed as q, resetDate as r, slash as s, toArray as t, createDefer as u, deepClone as v, getType as w, ensurePackageInstalled as x, getTests as y, hasFailedSnapshot as z };
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 };
@@ -1,9 +1,11 @@
1
- import { s as slash, j as notNullish } from './chunk-typecheck-constants.4891f22f.js';
1
+ import { s as slash, j as notNullish } from './chunk-typecheck-constants.ed987901.js';
2
2
 
3
3
  const lineSplitRE = /\r?\n/;
4
4
  const stackIgnorePatterns = [
5
5
  "node:internal",
6
6
  "/vitest/dist/",
7
+ "/vite-node/dist",
8
+ "/vite-node/src",
7
9
  "/vitest/src/",
8
10
  "/node_modules/chai/",
9
11
  "/node_modules/tinypool/",
@@ -4000,6 +4000,7 @@ function stringify(object, maxDepth = 10, options) {
4000
4000
  try {
4001
4001
  result = format_1(object, {
4002
4002
  maxDepth,
4003
+ escapeString: false,
4003
4004
  plugins: PLUGINS,
4004
4005
  ...options
4005
4006
  });
@@ -4007,6 +4008,7 @@ function stringify(object, maxDepth = 10, options) {
4007
4008
  result = format_1(object, {
4008
4009
  callToJSON: false,
4009
4010
  maxDepth,
4011
+ escapeString: false,
4010
4012
  plugins: PLUGINS,
4011
4013
  ...options
4012
4014
  });
@@ -1,7 +1,7 @@
1
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';
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, x as ensurePackageInstalled, A as AggregateErrorPonyfill, s as slash$2, k as relativePath, y as getTests, e as getFullName, q as hasFailed, z as hasFailedSnapshot, B as getTypecheckTests, C as getSuites, D as isTypecheckTest, j as notNullish, l as shuffle, t as toArray$1, n as noop$1, E as deepMerge, b as getCallLastIndex, F as removeUndefinedValues, G as stdout } from './chunk-typecheck-constants.4891f22f.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';
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,10 @@ 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 { c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-client.58cb6bfa.js';
15
+ import { w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-source-map.d0aa773d.js';
16
16
  import { performance } from 'perf_hooks';
17
17
  import createDebug from 'debug';
18
- import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap } from './chunk-vite-node-utils.f6d73fbe.js';
18
+ import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, n as normalizeModuleId, b as toFilePath, c as cleanUrl } from './chunk-vite-node-utils.9047cb87.js';
19
19
  import { writeFile, rm } from 'fs/promises';
20
20
  import { e as execa } from './vendor-index.737c3cff.js';
21
21
  import { SourceMapConsumer } from 'source-map';
@@ -24,8 +24,8 @@ import { parse as parse$4 } from 'acorn';
24
24
  import { ancestor } from 'acorn-walk';
25
25
  import { MessageChannel } from 'worker_threads';
26
26
  import { Tinypool } from 'tinypool';
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.06f993db.js';
28
- import { p as parseStacktrace, a as posToNumber, l as lineSplitRE } from './chunk-utils-source-map.c6dfbbc1.js';
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';
29
29
  import { resolveModule } from 'local-pkg';
30
30
  import { createHash } from 'crypto';
31
31
  import { o as onetime } from './vendor-index.9c919048.js';
@@ -35,7 +35,7 @@ import { stripLiteral } from 'strip-literal';
35
35
  import require$$0$2 from 'readline';
36
36
  import { p as prompts } from './vendor-index.9f20a9be.js';
37
37
 
38
- var version$1 = "0.25.3";
38
+ var version$1 = "0.25.5";
39
39
 
40
40
  class EndError extends Error {
41
41
  constructor(value) {
@@ -6937,7 +6937,6 @@ ${result.code}`, "utf-8");
6937
6937
  }
6938
6938
 
6939
6939
  const debugRequest = createDebug("vite-node:server:request");
6940
- const RealDate = Date;
6941
6940
  class ViteNodeServer {
6942
6941
  constructor(server, options = {}) {
6943
6942
  this.server = server;
@@ -6984,6 +6983,7 @@ class ViteNodeServer {
6984
6983
  return (ssrTransformResult == null ? void 0 : ssrTransformResult.map) || null;
6985
6984
  }
6986
6985
  async fetchModule(id) {
6986
+ id = normalizeModuleId(id);
6987
6987
  if (!this.fetchPromiseMap.has(id)) {
6988
6988
  this.fetchPromiseMap.set(
6989
6989
  id,
@@ -7023,24 +7023,33 @@ class ViteNodeServer {
7023
7023
  let result;
7024
7024
  const filePath = toFilePath(id, this.server.config.root);
7025
7025
  const module = this.server.moduleGraph.getModuleById(id);
7026
- const timestamp = (module == null ? void 0 : module.lastHMRTimestamp) || RealDate.now();
7026
+ const timestamp = module ? module.lastHMRTimestamp : null;
7027
7027
  const cache = this.fetchCache.get(filePath);
7028
- if (timestamp && cache && cache.timestamp >= timestamp)
7028
+ if (cache == null ? void 0 : cache.result.id)
7029
+ id = cache.result.id;
7030
+ if (timestamp !== null && cache && cache.timestamp >= timestamp)
7029
7031
  return cache.result;
7032
+ const time = Date.now();
7030
7033
  const externalize = await this.shouldExternalize(filePath);
7031
7034
  let duration;
7032
7035
  if (externalize) {
7033
7036
  result = { externalize };
7034
7037
  (_a = this.debugger) == null ? void 0 : _a.recordExternalize(id, externalize);
7035
7038
  } else {
7039
+ let file = module == null ? void 0 : module.file;
7040
+ if (!file) {
7041
+ const [, resolvedId] = await this.server.moduleGraph.resolveUrl(id, true);
7042
+ id = resolvedId;
7043
+ file = cleanUrl(resolvedId);
7044
+ }
7036
7045
  const start = performance.now();
7037
7046
  const r = await this._transformRequest(id);
7038
7047
  duration = performance.now() - start;
7039
- result = { code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
7048
+ result = { file, id, code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
7040
7049
  }
7041
7050
  this.fetchCache.set(filePath, {
7042
7051
  duration,
7043
- timestamp,
7052
+ timestamp: time,
7044
7053
  result
7045
7054
  });
7046
7055
  return result;
@@ -7860,7 +7869,6 @@ const WAIT_FOR_CHANGE_PASS = `
7860
7869
  ${picocolors.exports.bold(picocolors.exports.inverse(picocolors.exports.green(" PASS ")))}${picocolors.exports.green(" Waiting for file changes...")}`;
7861
7870
  const WAIT_FOR_CHANGE_FAIL = `
7862
7871
  ${picocolors.exports.bold(picocolors.exports.inverse(picocolors.exports.red(" FAIL ")))}${picocolors.exports.red(" Tests failed. Watching for file changes...")}`;
7863
- const DURATION_LONG$2 = 300;
7864
7872
  const LAST_RUN_LOG_TIMEOUT = 1500;
7865
7873
  class BaseReporter {
7866
7874
  constructor() {
@@ -7915,7 +7923,7 @@ class BaseReporter {
7915
7923
  state += ` ${picocolors.exports.dim("|")} ${picocolors.exports.yellow(`${skipped.length} skipped`)}`;
7916
7924
  let suffix = picocolors.exports.dim(" (") + state + picocolors.exports.dim(")");
7917
7925
  if (task.result.duration) {
7918
- const color = task.result.duration > DURATION_LONG$2 ? picocolors.exports.yellow : picocolors.exports.gray;
7926
+ const color = task.result.duration > this.ctx.config.slowTestThreshold ? picocolors.exports.yellow : picocolors.exports.gray;
7919
7927
  suffix += color(` ${Math.round(task.result.duration)}${picocolors.exports.dim("ms")}`);
7920
7928
  }
7921
7929
  if (this.ctx.config.logHeapUsage && task.result.heap != null)
@@ -8532,10 +8540,10 @@ class JsonReporter$1 {
8532
8540
  assertionResults,
8533
8541
  startTime,
8534
8542
  endTime,
8535
- status: tests2.every((t) => {
8536
- var _a2, _b2, _c;
8537
- return ((_a2 = t.result) == null ? void 0 : _a2.state) === "pass" || ((_b2 = t.result) == null ? void 0 : _b2.state) === "skip" || ((_c = t.result) == null ? void 0 : _c.state) === "todo";
8538
- }) ? "passed" : "failed",
8543
+ status: tests2.some((t) => {
8544
+ var _a2;
8545
+ return ((_a2 = t.result) == null ? void 0 : _a2.state) === "fail";
8546
+ }) ? "failed" : "passed",
8539
8547
  message: ((_b = (_a = file.result) == null ? void 0 : _a.error) == null ? void 0 : _b.message) ?? "",
8540
8548
  name: file.filepath
8541
8549
  });
@@ -8726,12 +8734,18 @@ function escapeXML(value) {
8726
8734
  true
8727
8735
  );
8728
8736
  }
8737
+ function executionTime(durationMS) {
8738
+ return (durationMS / 1e3).toLocaleString(void 0, { useGrouping: false, maximumFractionDigits: 10 });
8739
+ }
8729
8740
  function getDuration(task) {
8730
8741
  var _a;
8731
8742
  const duration = ((_a = task.result) == null ? void 0 : _a.duration) ?? 0;
8732
- return (duration / 1e3).toLocaleString(void 0, { useGrouping: false, maximumFractionDigits: 10 });
8743
+ return executionTime(duration);
8733
8744
  }
8734
8745
  class JUnitReporter {
8746
+ constructor() {
8747
+ this._timeStart = new Date();
8748
+ }
8735
8749
  async onInit(ctx) {
8736
8750
  this.ctx = ctx;
8737
8751
  const outputFile = getOutputFile(this.ctx.config, "junit");
@@ -8746,6 +8760,7 @@ class JUnitReporter {
8746
8760
  } else {
8747
8761
  this.baseLog = async (text) => this.ctx.logger.log(text);
8748
8762
  }
8763
+ this._timeStart = new Date();
8749
8764
  this.logger = new IndentedLogger(this.baseLog);
8750
8765
  }
8751
8766
  async writeElement(name, attrs, children) {
@@ -8817,13 +8832,13 @@ class JUnitReporter {
8817
8832
  await this.logger.log('<?xml version="1.0" encoding="UTF-8" ?>');
8818
8833
  const transformed = files.map((file) => {
8819
8834
  const tasks = file.tasks.flatMap((task) => flattenTasks$1(task));
8820
- const stats = tasks.reduce(
8821
- (stats2, task) => {
8835
+ const stats2 = tasks.reduce(
8836
+ (stats3, task) => {
8822
8837
  var _a, _b;
8823
8838
  return {
8824
- passed: stats2.passed + Number(((_a = task.result) == null ? void 0 : _a.state) === "pass"),
8825
- failures: stats2.failures + Number(((_b = task.result) == null ? void 0 : _b.state) === "fail"),
8826
- skipped: stats2.skipped + Number(task.mode === "skip" || task.mode === "todo")
8839
+ passed: stats3.passed + Number(((_a = task.result) == null ? void 0 : _a.state) === "pass"),
8840
+ failures: stats3.failures + Number(((_b = task.result) == null ? void 0 : _b.state) === "fail"),
8841
+ skipped: stats3.skipped + Number(task.mode === "skip" || task.mode === "todo")
8827
8842
  };
8828
8843
  },
8829
8844
  {
@@ -8835,10 +8850,21 @@ class JUnitReporter {
8835
8850
  return {
8836
8851
  ...file,
8837
8852
  tasks,
8838
- stats
8853
+ stats: stats2
8839
8854
  };
8840
8855
  });
8841
- await this.writeElement("testsuites", {}, async () => {
8856
+ const stats = transformed.reduce((stats2, file) => {
8857
+ stats2.tests += file.tasks.length;
8858
+ stats2.failures += file.stats.failures;
8859
+ return stats2;
8860
+ }, {
8861
+ name: process.env.VITEST_JUNIT_SUITE_NAME || "vitest tests",
8862
+ tests: 0,
8863
+ failures: 0,
8864
+ errors: 0,
8865
+ time: executionTime(new Date().getTime() - this._timeStart.getTime())
8866
+ });
8867
+ await this.writeElement("testsuites", stats, async () => {
8842
8868
  for (const file of transformed) {
8843
8869
  await this.writeElement("testsuite", {
8844
8870
  name: file.name,
@@ -9386,7 +9412,8 @@ const config = {
9386
9412
  checker: "tsc",
9387
9413
  include: ["**/*.{test,spec}-d.{ts,js}"],
9388
9414
  exclude: defaultExclude
9389
- }
9415
+ },
9416
+ slowTestThreshold: 300
9390
9417
  };
9391
9418
  const configDefaults = Object.freeze(config);
9392
9419
 
@@ -10188,7 +10215,7 @@ createLogUpdate(process$1.stdout);
10188
10215
 
10189
10216
  createLogUpdate(process$1.stderr);
10190
10217
 
10191
- var version = "0.25.3";
10218
+ var version = "0.25.5";
10192
10219
 
10193
10220
  function fileFromParsedStack(stack) {
10194
10221
  var _a, _b;
@@ -10550,8 +10577,7 @@ class Vitest {
10550
10577
  this.cache.results.setConfig(resolved.root, resolved.cache);
10551
10578
  try {
10552
10579
  await this.cache.results.readFromCache();
10553
- } catch (err) {
10554
- this.logger.error(`[vitest] Error, while trying to parse cache in ${this.cache.results.getCachePath()}:`, err);
10580
+ } catch {
10555
10581
  }
10556
10582
  }
10557
10583
  async initCoverageProvider() {
@@ -10593,10 +10619,13 @@ class Vitest {
10593
10619
  checker.onParseEnd(async ({ files, sourceErrors }) => {
10594
10620
  this.state.collectFiles(checker.getTestFiles());
10595
10621
  await this.report("onCollected");
10596
- if (!files.length)
10622
+ if (!files.length) {
10597
10623
  this.logger.printNoTestFound();
10598
- else
10624
+ } else {
10625
+ if (hasFailed(files))
10626
+ process.exitCode = 1;
10599
10627
  await this.report("onFinished", files);
10628
+ }
10600
10629
  if (sourceErrors.length && !this.config.typecheck.ignoreSourceErrors) {
10601
10630
  process.exitCode = 1;
10602
10631
  await this.logger.printSourceTypeErrors(sourceErrors);
@@ -10711,6 +10740,7 @@ class Vitest {
10711
10740
  return runningTests;
10712
10741
  }
10713
10742
  async runFiles(paths) {
10743
+ paths = Array.from(new Set(paths));
10714
10744
  await this.runningPromise;
10715
10745
  this.state.startCollectingPaths();
10716
10746
  this.runningPromise = (async () => {
@@ -10775,6 +10805,9 @@ class Vitest {
10775
10805
  }
10776
10806
  }
10777
10807
  async scheduleRerun(triggerId) {
10808
+ const mod = this.server.moduleGraph.getModuleById(triggerId);
10809
+ if (mod)
10810
+ mod.lastHMRTimestamp = Date.now();
10778
10811
  const currentCount = this.restartsCount;
10779
10812
  safeClearTimeout(this._rerunTimer);
10780
10813
  await this.runningPromise;
@@ -11056,7 +11089,7 @@ ${picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inve
11056
11089
  };
11057
11090
  };
11058
11091
 
11059
- const hoistRegexp = /^ *\b((?:vitest|vi)\s*.\s*(mock|unmock)\(["`'\s]+(.*[@\w_-]+)["`'\s]+)[),]{1};?/gm;
11092
+ const hoistRegexp = /^[ \t]*\b((?:vitest|vi)\s*.\s*(mock|unmock)\(["`'\s]+(.*[@\w_-]+)["`'\s]+)[),]{1};?/gm;
11060
11093
  const vitestRegexp = /import {[^}]*}.*(?=["'`]vitest["`']).*/gm;
11061
11094
  function hoistMocks(code) {
11062
11095
  let m;
@@ -11297,6 +11330,9 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
11297
11330
  else if (preOptions.browser)
11298
11331
  open = "/";
11299
11332
  const config = {
11333
+ esbuild: {
11334
+ sourcemap: "external"
11335
+ },
11300
11336
  resolve: {
11301
11337
  mainFields: [],
11302
11338
  alias: preOptions.alias,
@@ -11358,7 +11394,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
11358
11394
  try {
11359
11395
  await ctx.setServer(options, server);
11360
11396
  if (options.api && options.watch)
11361
- (await import('./chunk-api-setup.c9f38753.js')).setup(ctx);
11397
+ (await import('./chunk-api-setup.995f6ab7.js')).setup(ctx);
11362
11398
  } catch (err) {
11363
11399
  ctx.logger.printError(err, true);
11364
11400
  process.exit(1);
@@ -11417,6 +11453,11 @@ function registerConsoleShortcuts(ctx) {
11417
11453
  async function _keypressHandler(str, key) {
11418
11454
  if (str === "" || str === "\x1B" || key && key.ctrl && key.name === "c")
11419
11455
  return ctx.exit(true);
11456
+ if (!isWindows && key && key.ctrl && key.name === "z") {
11457
+ process.kill(process.ppid, "SIGTSTP");
11458
+ process.kill(process.pid, "SIGTSTP");
11459
+ return;
11460
+ }
11420
11461
  if (ctx.runningPromise)
11421
11462
  return;
11422
11463
  const name = key == null ? void 0 : key.name;
@@ -2,8 +2,38 @@ import { createRequire } from 'module';
2
2
  import { pathToFileURL, fileURLToPath } from 'url';
3
3
  import vm from 'vm';
4
4
  import { b as resolve, d as dirname, g as isAbsolute, l as extname } from './chunk-utils-env.03f840f2.js';
5
- import { s as slash, n as normalizeRequestId, b as toFilePath, c as isPrimitive, i as isNodeBuiltin, d as normalizeModuleId, m as mergeSlashes } from './chunk-vite-node-utils.f6d73fbe.js';
5
+ import { s as slash, d as normalizeRequestId, b as toFilePath, e as isPrimitive, i as isNodeBuiltin, n as normalizeModuleId, m as mergeSlashes } from './chunk-vite-node-utils.9047cb87.js';
6
6
  import createDebug from 'debug';
7
+ import './vendor-source-map-support.1ce17397.js';
8
+
9
+ let SOURCEMAPPING_URL = "sourceMa";
10
+ SOURCEMAPPING_URL += "ppingURL";
11
+ const VITE_NODE_SOURCEMAPPING_SOURCE = "//# sourceMappingSource=vite-node";
12
+ const VITE_NODE_SOURCEMAPPING_URL = `${SOURCEMAPPING_URL}=data:application/json;charset=utf-8`;
13
+ const VITE_NODE_SOURCEMAPPING_REGEXP = new RegExp(`//# ${VITE_NODE_SOURCEMAPPING_URL};base64,(.+)`);
14
+ async function withInlineSourcemap(result) {
15
+ const map = result.map;
16
+ let code = result.code;
17
+ if (!map || code.includes(VITE_NODE_SOURCEMAPPING_SOURCE))
18
+ return result;
19
+ const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,(.+)`, "g");
20
+ while (OTHER_SOURCE_MAP_REGEXP.test(code))
21
+ code = code.replace(OTHER_SOURCE_MAP_REGEXP, "");
22
+ const sourceMap = Buffer.from(JSON.stringify(map), "utf-8").toString("base64");
23
+ result.code = `${code.trimEnd()}
24
+
25
+ ${VITE_NODE_SOURCEMAPPING_SOURCE}
26
+ //# ${VITE_NODE_SOURCEMAPPING_URL};base64,${sourceMap}
27
+ `;
28
+ return result;
29
+ }
30
+ function extractSourceMap(code) {
31
+ var _a;
32
+ const mapString = (_a = code.match(VITE_NODE_SOURCEMAPPING_REGEXP)) == null ? void 0 : _a[1];
33
+ if (mapString)
34
+ return JSON.parse(Buffer.from(mapString, "base64").toString("utf-8"));
35
+ return null;
36
+ }
7
37
 
8
38
  const debugExecute = createDebug("vite-node:client:execute");
9
39
  const debugNative = createDebug("vite-node:client:native");
@@ -96,14 +126,11 @@ class ModuleCacheMap extends Map {
96
126
  return invalidated;
97
127
  }
98
128
  getSourceMap(id) {
99
- var _a, _b;
100
- const fsPath = this.normalizePath(id);
101
- const cache = this.get(fsPath);
129
+ const cache = this.get(id);
102
130
  if (cache.map)
103
131
  return cache.map;
104
- const mapString = (_b = (_a = cache == null ? void 0 : cache.code) == null ? void 0 : _a.match(/\/\/# sourceMappingURL=data:application\/json;charset=utf-8;base64,(.+)/)) == null ? void 0 : _b[1];
105
- if (mapString) {
106
- const map = JSON.parse(Buffer.from(mapString, "base64").toString("utf-8"));
132
+ const map = cache.code && extractSourceMap(cache.code);
133
+ if (map) {
107
134
  cache.map = map;
108
135
  return map;
109
136
  }
@@ -140,12 +167,15 @@ class ViteNodeRunner {
140
167
  if (mod.promise)
141
168
  return mod.promise;
142
169
  const promise = this.directRequest(id, fsPath, callstack);
143
- Object.assign(mod, { promise });
170
+ Object.assign(mod, { promise, evaluated: false });
171
+ promise.finally(() => {
172
+ mod.evaluated = true;
173
+ });
144
174
  return await promise;
145
175
  }
146
176
  async directRequest(id, fsPath, _callstack) {
147
177
  const callstack = [..._callstack, fsPath];
148
- const mod = this.moduleCache.get(fsPath);
178
+ let mod = this.moduleCache.get(fsPath);
149
179
  const request = async (dep) => {
150
180
  var _a;
151
181
  const depFsPath = toFilePath(normalizeRequestId(dep, this.options.base), this.root);
@@ -181,11 +211,22 @@ ${getStack()}`), 2e3);
181
211
  }
182
212
  return dep;
183
213
  };
184
- id = await resolveId(id, 2);
185
214
  const requestStubs = this.options.requestStubs || DEFAULT_REQUEST_STUBS;
186
215
  if (id in requestStubs)
187
216
  return requestStubs[id];
188
- let { code: transformed, externalize } = await this.options.fetchModule(id);
217
+ let { code: transformed, externalize, file } = await this.options.fetchModule(id);
218
+ if (file && !fsPath.includes("?") && fsPath !== file) {
219
+ if (this.moduleCache.has(file)) {
220
+ mod = this.moduleCache.get(file);
221
+ this.moduleCache.set(fsPath, mod);
222
+ if (mod.promise)
223
+ return mod.promise;
224
+ if (mod.exports)
225
+ return mod.exports;
226
+ } else {
227
+ this.moduleCache.set(file, mod);
228
+ }
229
+ }
189
230
  if (externalize) {
190
231
  debugNative(externalize);
191
232
  const exports2 = await this.interopedImport(externalize);
@@ -194,7 +235,7 @@ ${getStack()}`), 2e3);
194
235
  }
195
236
  if (transformed == null)
196
237
  throw new Error(`[vite-node] Failed to load ${id}`);
197
- const url = pathToFileURL(fsPath).href;
238
+ const url = pathToFileURL(file || fsPath).href;
198
239
  const meta = { url };
199
240
  const exports = /* @__PURE__ */ Object.create(null);
200
241
  Object.defineProperty(exports, Symbol.toStringTag, {
@@ -203,9 +244,6 @@ ${getStack()}`), 2e3);
203
244
  configurable: false
204
245
  });
205
246
  const cjsExports = new Proxy(exports, {
206
- get(_, p, receiver) {
207
- return Reflect.get(exports, p, receiver);
208
- },
209
247
  set(_, p, value) {
210
248
  if (!Reflect.has(exports, "default"))
211
249
  exports.default = {};
@@ -261,7 +299,7 @@ ${getStack()}`), 2e3);
261
299
  const code = `${codeDefinition}${transformed}
262
300
  }}`;
263
301
  const fn = vm.runInThisContext(code, {
264
- filename: fsPath,
302
+ filename: __filename,
265
303
  lineOffset: 0,
266
304
  columnOffset: -codeDefinition.length
267
305
  });
@@ -318,7 +356,7 @@ function defineExport(exports, key, value) {
318
356
  function exportAll(exports, sourceModule) {
319
357
  if (exports === sourceModule)
320
358
  return;
321
- if (typeof sourceModule !== "object" || Array.isArray(sourceModule) || !sourceModule)
359
+ if (isPrimitive(sourceModule) || Array.isArray(sourceModule))
322
360
  return;
323
361
  for (const key in sourceModule) {
324
362
  if (key !== "default") {
@@ -400,4 +438,4 @@ function nanoid(size = 21) {
400
438
  return id;
401
439
  }
402
440
 
403
- export { ModuleCacheMap as M, ViteNodeRunner as V, createBirpc as c };
441
+ export { ModuleCacheMap as M, ViteNodeRunner as V, createBirpc as c, withInlineSourcemap as w };
@@ -1342,6 +1342,9 @@ function normalizeRequestId(id, base) {
1342
1342
  id = `/${id.slice(base.length)}`;
1343
1343
  return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/^(node|file):/, "").replace(/^\/+/, "/").replace(/\?v=\w+/, "?").replace(/&v=\w+/, "").replace(/\?t=\w+/, "?").replace(/&t=\w+/, "").replace(/\?import/, "?").replace(/&import/, "").replace(/\?&/, "?").replace(/\?+$/, "");
1344
1344
  }
1345
+ const queryRE = /\?.*$/s;
1346
+ const hashRE = /#.*$/s;
1347
+ const cleanUrl = (url) => url.replace(hashRE, "").replace(queryRE, "");
1345
1348
  function normalizeModuleId(id) {
1346
1349
  return id.replace(/\\/g, "/").replace(/^\/@fs\//, "/").replace(/^file:\//, "/").replace(/^\/+/, "/");
1347
1350
  }
@@ -1374,19 +1377,6 @@ function toFilePath(id, root) {
1374
1377
  absolute = absolute.slice(1);
1375
1378
  return isWindows && absolute.startsWith("/") ? slash(fileURLToPath$1(pathToFileURL(absolute.slice(1)).href)) : absolute;
1376
1379
  }
1377
- let SOURCEMAPPING_URL = "sourceMa";
1378
- SOURCEMAPPING_URL += "ppingURL";
1379
- async function withInlineSourcemap(result) {
1380
- const { code, map } = result;
1381
- if (code.includes(`${SOURCEMAPPING_URL}=`))
1382
- return result;
1383
- if (map)
1384
- result.code = `${code}
1385
-
1386
- //# ${SOURCEMAPPING_URL}=data:application/json;charset=utf-8;base64,${Buffer.from(JSON.stringify(map), "utf-8").toString("base64")}
1387
- `;
1388
- return result;
1389
- }
1390
1380
  function toArray(array) {
1391
1381
  if (array === null || array === void 0)
1392
1382
  array = [];
@@ -1395,4 +1385,4 @@ function toArray(array) {
1395
1385
  return [array];
1396
1386
  }
1397
1387
 
1398
- export { isValidNodeImport as a, toFilePath as b, isPrimitive as c, normalizeModuleId as d, hasCJSSyntax as h, isNodeBuiltin as i, mergeSlashes as m, normalizeRequestId as n, pathFromRoot as p, slash as s, toArray as t, withInlineSourcemap as w };
1388
+ export { isValidNodeImport as a, toFilePath as b, cleanUrl as c, normalizeRequestId as d, isPrimitive as e, hasCJSSyntax as h, isNodeBuiltin as i, mergeSlashes as m, normalizeModuleId as n, pathFromRoot as p, slash as s, toArray as t };
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { p as picocolors, n as normalize } from './chunk-utils-env.03f840f2.js';
2
2
  import { EventEmitter } from 'events';
3
- import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.c57d0ad1.js';
3
+ import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.ca4784be.js';
4
4
  import 'tty';
5
5
  import 'url';
6
6
  import 'path';
@@ -8,7 +8,7 @@ import './chunk-integrations-coverage.befed097.js';
8
8
  import 'local-pkg';
9
9
  import './chunk-env-node.67948209.js';
10
10
  import 'console';
11
- import './chunk-typecheck-constants.4891f22f.js';
11
+ import './chunk-typecheck-constants.ed987901.js';
12
12
  import 'vite';
13
13
  import 'process';
14
14
  import 'fs';
@@ -16,25 +16,26 @@ import 'os';
16
16
  import 'util';
17
17
  import 'stream';
18
18
  import './vendor-_commonjsHelpers.addc3445.js';
19
- import './chunk-vite-node-client.58cb6bfa.js';
19
+ import './chunk-vite-node-source-map.d0aa773d.js';
20
20
  import 'module';
21
21
  import 'vm';
22
- import './chunk-vite-node-utils.f6d73fbe.js';
22
+ import './chunk-vite-node-utils.9047cb87.js';
23
23
  import 'acorn';
24
24
  import 'assert';
25
25
  import 'debug';
26
+ import './vendor-source-map-support.1ce17397.js';
27
+ import 'source-map';
26
28
  import 'perf_hooks';
27
29
  import 'fs/promises';
28
30
  import './vendor-index.737c3cff.js';
29
31
  import 'buffer';
30
32
  import 'child_process';
31
33
  import './vendor-index.e1d4cf84.js';
32
- import 'source-map';
33
34
  import 'acorn-walk';
34
35
  import 'worker_threads';
35
36
  import 'tinypool';
36
- import './chunk-utils-timers.06f993db.js';
37
- import './chunk-utils-source-map.c6dfbbc1.js';
37
+ import './chunk-utils-timers.793fd179.js';
38
+ import './chunk-utils-source-map.29ff1088.js';
38
39
  import 'crypto';
39
40
  import './vendor-index.9c919048.js';
40
41
  import './chunk-magic-string.ffe2b171.js';
package/dist/config.cjs CHANGED
@@ -81,7 +81,8 @@ const config = {
81
81
  checker: "tsc",
82
82
  include: ["**/*.{test,spec}-d.{ts,js}"],
83
83
  exclude: defaultExclude
84
- }
84
+ },
85
+ slowTestThreshold: 300
85
86
  };
86
87
  const configDefaults = Object.freeze(config);
87
88
 
package/dist/config.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { UserConfig as UserConfig$2, ConfigEnv } from 'vite';
2
2
  export { ConfigEnv } from 'vite';
3
- import { U as UserConfig$1, ao as ResolvedCoverageOptions, F as FakeTimerInstallOpts } from './types-de0e0997.js';
3
+ import { U as UserConfig$1, ao as ResolvedCoverageOptions, F as FakeTimerInstallOpts } from './types-79a05dee.js';
4
4
  import 'tinybench';
5
5
  import 'fs';
6
6
  import 'worker_threads';
@@ -43,6 +43,7 @@ declare const config: {
43
43
  include: string[];
44
44
  exclude: string[];
45
45
  };
46
+ slowTestThreshold: number;
46
47
  };
47
48
  declare const configDefaults: Required<Pick<UserConfig$1, keyof typeof config>>;
48
49
 
package/dist/config.js CHANGED
@@ -77,7 +77,8 @@ const config = {
77
77
  checker: "tsc",
78
78
  include: ["**/*.{test,spec}-d.{ts,js}"],
79
79
  exclude: defaultExclude
80
- }
80
+ },
81
+ slowTestThreshold: 300
81
82
  };
82
83
  const configDefaults = Object.freeze(config);
83
84
 
package/dist/entry.js CHANGED
@@ -1,26 +1,27 @@
1
1
  import { promises } from 'fs';
2
- import { g as getWorkerState, a as resetModules } from './chunk-typecheck-constants.4891f22f.js';
3
- import { v as vi } from './chunk-runtime-test-state.de4d6ff8.js';
2
+ import { g as getWorkerState, a as resetModules } from './chunk-typecheck-constants.ed987901.js';
3
+ import { v as vi } from './chunk-runtime-test-state.0037e2e0.js';
4
4
  import { a as envs } from './chunk-env-node.67948209.js';
5
- import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-setup.667a5719.js';
5
+ import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-setup.bd2deed4.js';
6
6
  import 'path';
7
7
  import './chunk-utils-env.03f840f2.js';
8
8
  import 'tty';
9
9
  import 'url';
10
10
  import 'local-pkg';
11
- import './chunk-runtime-chain.f993b1dc.js';
11
+ import './chunk-runtime-chain.dd978482.js';
12
12
  import 'util';
13
13
  import 'chai';
14
14
  import './vendor-_commonjsHelpers.addc3445.js';
15
- import './chunk-runtime-rpc.1e7530d3.js';
16
- import './chunk-utils-timers.06f993db.js';
17
- import './chunk-utils-source-map.c6dfbbc1.js';
15
+ import './chunk-runtime-rpc.42aebbb9.js';
16
+ import './chunk-utils-timers.793fd179.js';
17
+ import './chunk-utils-source-map.29ff1088.js';
18
18
  import './spy.js';
19
19
  import 'tinyspy';
20
20
  import 'console';
21
21
  import 'perf_hooks';
22
22
  import './chunk-integrations-coverage.befed097.js';
23
- import './chunk-runtime-error.6287172c.js';
23
+ import './chunk-runtime-error.616e92ca.js';
24
+ import './vendor-source-map-support.1ce17397.js';
24
25
  import 'source-map';
25
26
 
26
27
  function groupBy(collection, iteratee) {