vitest 0.25.3 → 0.25.4

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.1c8923c4.js} +4 -2
  4. package/dist/{chunk-integrations-globals.1e636d22.js → chunk-integrations-globals.789c69e2.js} +7 -7
  5. package/dist/{chunk-runtime-chain.f993b1dc.js → chunk-runtime-chain.315721df.js} +8 -7
  6. package/dist/{chunk-runtime-error.6287172c.js → chunk-runtime-error.95c286d7.js} +2 -2
  7. package/dist/{chunk-runtime-mocker.c4d85347.js → chunk-runtime-mocker.cdc0ec57.js} +34 -18
  8. package/dist/{chunk-runtime-rpc.1e7530d3.js → chunk-runtime-rpc.b368762d.js} +2 -2
  9. package/dist/chunk-runtime-setup.80b27439.js +659 -0
  10. package/dist/{chunk-runtime-test-state.de4d6ff8.js → chunk-runtime-test-state.7c288e2d.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.b81cda77.js} +2 -0
  14. package/dist/{chunk-vite-node-externalize.c57d0ad1.js → chunk-vite-node-externalize.ddcbafa3.js} +55 -26
  15. package/dist/{chunk-vite-node-client.58cb6bfa.js → chunk-vite-node-source-map.61c5ea66.js} +37 -11
  16. package/dist/{chunk-vite-node-utils.f6d73fbe.js → chunk-vite-node-utils.abe05c5c.js} +1 -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-81973d31.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-1cf24598.d.ts} +70 -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.61c5ea66.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, b as toFilePath } from './chunk-vite-node-utils.abe05c5c.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.b81cda77.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.4";
39
39
 
40
40
  class EndError extends Error {
41
41
  constructor(value) {
@@ -7860,7 +7860,6 @@ const WAIT_FOR_CHANGE_PASS = `
7860
7860
  ${picocolors.exports.bold(picocolors.exports.inverse(picocolors.exports.green(" PASS ")))}${picocolors.exports.green(" Waiting for file changes...")}`;
7861
7861
  const WAIT_FOR_CHANGE_FAIL = `
7862
7862
  ${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
7863
  const LAST_RUN_LOG_TIMEOUT = 1500;
7865
7864
  class BaseReporter {
7866
7865
  constructor() {
@@ -7915,7 +7914,7 @@ class BaseReporter {
7915
7914
  state += ` ${picocolors.exports.dim("|")} ${picocolors.exports.yellow(`${skipped.length} skipped`)}`;
7916
7915
  let suffix = picocolors.exports.dim(" (") + state + picocolors.exports.dim(")");
7917
7916
  if (task.result.duration) {
7918
- const color = task.result.duration > DURATION_LONG$2 ? picocolors.exports.yellow : picocolors.exports.gray;
7917
+ const color = task.result.duration > this.ctx.config.slowTestThreshold ? picocolors.exports.yellow : picocolors.exports.gray;
7919
7918
  suffix += color(` ${Math.round(task.result.duration)}${picocolors.exports.dim("ms")}`);
7920
7919
  }
7921
7920
  if (this.ctx.config.logHeapUsage && task.result.heap != null)
@@ -8532,10 +8531,10 @@ class JsonReporter$1 {
8532
8531
  assertionResults,
8533
8532
  startTime,
8534
8533
  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",
8534
+ status: tests2.some((t) => {
8535
+ var _a2;
8536
+ return ((_a2 = t.result) == null ? void 0 : _a2.state) === "fail";
8537
+ }) ? "failed" : "passed",
8539
8538
  message: ((_b = (_a = file.result) == null ? void 0 : _a.error) == null ? void 0 : _b.message) ?? "",
8540
8539
  name: file.filepath
8541
8540
  });
@@ -8726,12 +8725,18 @@ function escapeXML(value) {
8726
8725
  true
8727
8726
  );
8728
8727
  }
8728
+ function executionTime(durationMS) {
8729
+ return (durationMS / 1e3).toLocaleString(void 0, { useGrouping: false, maximumFractionDigits: 10 });
8730
+ }
8729
8731
  function getDuration(task) {
8730
8732
  var _a;
8731
8733
  const duration = ((_a = task.result) == null ? void 0 : _a.duration) ?? 0;
8732
- return (duration / 1e3).toLocaleString(void 0, { useGrouping: false, maximumFractionDigits: 10 });
8734
+ return executionTime(duration);
8733
8735
  }
8734
8736
  class JUnitReporter {
8737
+ constructor() {
8738
+ this._timeStart = new Date();
8739
+ }
8735
8740
  async onInit(ctx) {
8736
8741
  this.ctx = ctx;
8737
8742
  const outputFile = getOutputFile(this.ctx.config, "junit");
@@ -8746,6 +8751,7 @@ class JUnitReporter {
8746
8751
  } else {
8747
8752
  this.baseLog = async (text) => this.ctx.logger.log(text);
8748
8753
  }
8754
+ this._timeStart = new Date();
8749
8755
  this.logger = new IndentedLogger(this.baseLog);
8750
8756
  }
8751
8757
  async writeElement(name, attrs, children) {
@@ -8817,13 +8823,13 @@ class JUnitReporter {
8817
8823
  await this.logger.log('<?xml version="1.0" encoding="UTF-8" ?>');
8818
8824
  const transformed = files.map((file) => {
8819
8825
  const tasks = file.tasks.flatMap((task) => flattenTasks$1(task));
8820
- const stats = tasks.reduce(
8821
- (stats2, task) => {
8826
+ const stats2 = tasks.reduce(
8827
+ (stats3, task) => {
8822
8828
  var _a, _b;
8823
8829
  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")
8830
+ passed: stats3.passed + Number(((_a = task.result) == null ? void 0 : _a.state) === "pass"),
8831
+ failures: stats3.failures + Number(((_b = task.result) == null ? void 0 : _b.state) === "fail"),
8832
+ skipped: stats3.skipped + Number(task.mode === "skip" || task.mode === "todo")
8827
8833
  };
8828
8834
  },
8829
8835
  {
@@ -8835,10 +8841,21 @@ class JUnitReporter {
8835
8841
  return {
8836
8842
  ...file,
8837
8843
  tasks,
8838
- stats
8844
+ stats: stats2
8839
8845
  };
8840
8846
  });
8841
- await this.writeElement("testsuites", {}, async () => {
8847
+ const stats = transformed.reduce((stats2, file) => {
8848
+ stats2.tests += file.tasks.length;
8849
+ stats2.failures += file.stats.failures;
8850
+ return stats2;
8851
+ }, {
8852
+ name: process.env.VITEST_JUNIT_SUITE_NAME || "vitest tests",
8853
+ tests: 0,
8854
+ failures: 0,
8855
+ errors: 0,
8856
+ time: executionTime(new Date().getTime() - this._timeStart.getTime())
8857
+ });
8858
+ await this.writeElement("testsuites", stats, async () => {
8842
8859
  for (const file of transformed) {
8843
8860
  await this.writeElement("testsuite", {
8844
8861
  name: file.name,
@@ -9386,7 +9403,8 @@ const config = {
9386
9403
  checker: "tsc",
9387
9404
  include: ["**/*.{test,spec}-d.{ts,js}"],
9388
9405
  exclude: defaultExclude
9389
- }
9406
+ },
9407
+ slowTestThreshold: 300
9390
9408
  };
9391
9409
  const configDefaults = Object.freeze(config);
9392
9410
 
@@ -10188,7 +10206,7 @@ createLogUpdate(process$1.stdout);
10188
10206
 
10189
10207
  createLogUpdate(process$1.stderr);
10190
10208
 
10191
- var version = "0.25.3";
10209
+ var version = "0.25.4";
10192
10210
 
10193
10211
  function fileFromParsedStack(stack) {
10194
10212
  var _a, _b;
@@ -10593,10 +10611,13 @@ class Vitest {
10593
10611
  checker.onParseEnd(async ({ files, sourceErrors }) => {
10594
10612
  this.state.collectFiles(checker.getTestFiles());
10595
10613
  await this.report("onCollected");
10596
- if (!files.length)
10614
+ if (!files.length) {
10597
10615
  this.logger.printNoTestFound();
10598
- else
10616
+ } else {
10617
+ if (hasFailed(files))
10618
+ process.exitCode = 1;
10599
10619
  await this.report("onFinished", files);
10620
+ }
10600
10621
  if (sourceErrors.length && !this.config.typecheck.ignoreSourceErrors) {
10601
10622
  process.exitCode = 1;
10602
10623
  await this.logger.printSourceTypeErrors(sourceErrors);
@@ -11056,7 +11077,7 @@ ${picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inve
11056
11077
  };
11057
11078
  };
11058
11079
 
11059
- const hoistRegexp = /^ *\b((?:vitest|vi)\s*.\s*(mock|unmock)\(["`'\s]+(.*[@\w_-]+)["`'\s]+)[),]{1};?/gm;
11080
+ const hoistRegexp = /^[ \t]*\b((?:vitest|vi)\s*.\s*(mock|unmock)\(["`'\s]+(.*[@\w_-]+)["`'\s]+)[),]{1};?/gm;
11060
11081
  const vitestRegexp = /import {[^}]*}.*(?=["'`]vitest["`']).*/gm;
11061
11082
  function hoistMocks(code) {
11062
11083
  let m;
@@ -11297,6 +11318,9 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
11297
11318
  else if (preOptions.browser)
11298
11319
  open = "/";
11299
11320
  const config = {
11321
+ esbuild: {
11322
+ sourcemap: "external"
11323
+ },
11300
11324
  resolve: {
11301
11325
  mainFields: [],
11302
11326
  alias: preOptions.alias,
@@ -11358,7 +11382,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
11358
11382
  try {
11359
11383
  await ctx.setServer(options, server);
11360
11384
  if (options.api && options.watch)
11361
- (await import('./chunk-api-setup.c9f38753.js')).setup(ctx);
11385
+ (await import('./chunk-api-setup.1c8923c4.js')).setup(ctx);
11362
11386
  } catch (err) {
11363
11387
  ctx.logger.printError(err, true);
11364
11388
  process.exit(1);
@@ -11417,6 +11441,11 @@ function registerConsoleShortcuts(ctx) {
11417
11441
  async function _keypressHandler(str, key) {
11418
11442
  if (str === "" || str === "\x1B" || key && key.ctrl && key.name === "c")
11419
11443
  return ctx.exit(true);
11444
+ if (!isWindows && key && key.ctrl && key.name === "z") {
11445
+ process.kill(process.ppid, "SIGTSTP");
11446
+ process.kill(process.pid, "SIGTSTP");
11447
+ return;
11448
+ }
11420
11449
  if (ctx.runningPromise)
11421
11450
  return;
11422
11451
  const name = key == null ? void 0 : key.name;
@@ -2,8 +2,34 @@ 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, n as normalizeRequestId, b as toFilePath, c as isPrimitive, i as isNodeBuiltin, d as normalizeModuleId, m as mergeSlashes } from './chunk-vite-node-utils.abe05c5c.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_URL = `${SOURCEMAPPING_URL}=data:application/json;charset=utf-8;source=vite-node`;
12
+ const VITE_NODE_SOURCEMAPPING_REGEXP = new RegExp(`//# ${VITE_NODE_SOURCEMAPPING_URL};base64,(.+)`);
13
+ const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,(.+)`);
14
+ async function withInlineSourcemap(result) {
15
+ const { code, map } = result;
16
+ if (!map || code.includes(VITE_NODE_SOURCEMAPPING_URL))
17
+ return result;
18
+ if (OTHER_SOURCE_MAP_REGEXP.test(code))
19
+ result.code = code.replace(OTHER_SOURCE_MAP_REGEXP, "");
20
+ result.code = `${code}
21
+
22
+ //# ${VITE_NODE_SOURCEMAPPING_URL};base64,${Buffer.from(JSON.stringify(map), "utf-8").toString("base64")}
23
+ `;
24
+ return result;
25
+ }
26
+ function extractSourceMap(code) {
27
+ var _a;
28
+ const mapString = (_a = code.match(VITE_NODE_SOURCEMAPPING_REGEXP)) == null ? void 0 : _a[1];
29
+ if (mapString)
30
+ return JSON.parse(Buffer.from(mapString, "base64").toString("utf-8"));
31
+ return null;
32
+ }
7
33
 
8
34
  const debugExecute = createDebug("vite-node:client:execute");
9
35
  const debugNative = createDebug("vite-node:client:native");
@@ -96,14 +122,11 @@ class ModuleCacheMap extends Map {
96
122
  return invalidated;
97
123
  }
98
124
  getSourceMap(id) {
99
- var _a, _b;
100
- const fsPath = this.normalizePath(id);
101
- const cache = this.get(fsPath);
125
+ const cache = this.get(id);
102
126
  if (cache.map)
103
127
  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"));
128
+ const map = cache.code && extractSourceMap(cache.code);
129
+ if (map) {
107
130
  cache.map = map;
108
131
  return map;
109
132
  }
@@ -140,7 +163,10 @@ class ViteNodeRunner {
140
163
  if (mod.promise)
141
164
  return mod.promise;
142
165
  const promise = this.directRequest(id, fsPath, callstack);
143
- Object.assign(mod, { promise });
166
+ Object.assign(mod, { promise, evaluated: false });
167
+ promise.finally(() => {
168
+ mod.evaluated = true;
169
+ });
144
170
  return await promise;
145
171
  }
146
172
  async directRequest(id, fsPath, _callstack) {
@@ -219,7 +245,7 @@ ${getStack()}`), 2e3);
219
245
  return true;
220
246
  }
221
247
  });
222
- Object.assign(mod, { code: transformed, exports });
248
+ Object.assign(mod, { code: transformed, exports, evaluated: false });
223
249
  const __filename = fileURLToPath(url);
224
250
  const moduleProxy = {
225
251
  set exports(value) {
@@ -318,7 +344,7 @@ function defineExport(exports, key, value) {
318
344
  function exportAll(exports, sourceModule) {
319
345
  if (exports === sourceModule)
320
346
  return;
321
- if (typeof sourceModule !== "object" || Array.isArray(sourceModule) || !sourceModule)
347
+ if (isPrimitive(sourceModule) || Array.isArray(sourceModule))
322
348
  return;
323
349
  for (const key in sourceModule) {
324
350
  if (key !== "default") {
@@ -400,4 +426,4 @@ function nanoid(size = 21) {
400
426
  return id;
401
427
  }
402
428
 
403
- export { ModuleCacheMap as M, ViteNodeRunner as V, createBirpc as c };
429
+ export { ModuleCacheMap as M, ViteNodeRunner as V, createBirpc as c, withInlineSourcemap as w };
@@ -1374,19 +1374,6 @@ function toFilePath(id, root) {
1374
1374
  absolute = absolute.slice(1);
1375
1375
  return isWindows && absolute.startsWith("/") ? slash(fileURLToPath$1(pathToFileURL(absolute.slice(1)).href)) : absolute;
1376
1376
  }
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
1377
  function toArray(array) {
1391
1378
  if (array === null || array === void 0)
1392
1379
  array = [];
@@ -1395,4 +1382,4 @@ function toArray(array) {
1395
1382
  return [array];
1396
1383
  }
1397
1384
 
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 };
1385
+ 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 };
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.ddcbafa3.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.61c5ea66.js';
20
20
  import 'module';
21
21
  import 'vm';
22
- import './chunk-vite-node-utils.f6d73fbe.js';
22
+ import './chunk-vite-node-utils.abe05c5c.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.b81cda77.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-1cf24598.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.7c288e2d.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.80b27439.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.315721df.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.b368762d.js';
16
+ import './chunk-utils-timers.b81cda77.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.95c286d7.js';
24
+ import './vendor-source-map-support.1ce17397.js';
24
25
  import 'source-map';
25
26
 
26
27
  function groupBy(collection, iteratee) {
@@ -1,4 +1,4 @@
1
- import { ae as Environment } from './types-de0e0997.js';
1
+ import { ae as Environment } from './types-1cf24598.js';
2
2
  import 'vite';
3
3
  import 'tinybench';
4
4
  import 'fs';
@@ -1,5 +1,5 @@
1
1
  import { SpyImpl } from 'tinyspy';
2
- import { w as SuiteAPI, v as TestAPI, aw as BenchmarkAPI, y as SuiteHooks, H as HookListener, L as TestContext, p as Suite, x as HookCleanupCallback, O as OnTestFailedHandler, q as Test } from './types-de0e0997.js';
2
+ import { w as SuiteAPI, v as TestAPI, aw as BenchmarkAPI, y as SuiteHooks, H as HookListener, L as TestContext, p as Suite, x as HookCleanupCallback, O as OnTestFailedHandler, q as Test } from './types-1cf24598.js';
3
3
 
4
4
  declare type Not<T extends boolean> = T extends true ? false : true;
5
5
  declare type And<Types extends boolean[]> = Types[number] extends true ? true : false;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { s as spyOn, f as fn, M as MaybeMockedDeep, a as MaybeMocked, b as MaybePartiallyMocked, c as MaybePartiallyMockedDeep, E as EnhancedSpy } from './index-9f5bc072.js';
2
- export { A as AssertType, E as EnhancedSpy, q as ExpectTypeOf, x as Mock, y as MockContext, w as MockInstance, z as Mocked, B as MockedClass, u as MockedFunction, v as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, r as assertType, h as beforeAll, k as beforeEach, g as bench, n as createExpect, e as describe, m as expect, p as expectTypeOf, i as it, o as onTestFailed, d as suite, t as test } from './index-9f5bc072.js';
3
- import { D as DoneCallback, F as FakeTimerInstallOpts, R as RuntimeConfig, a as File, T as TaskResultPack, b as ResolvedConfig, M as ModuleGraphData, c as Reporter } from './types-de0e0997.js';
4
- export { a1 as AfterSuiteRunMeta, A as ApiConfig, a7 as ArgumentsType, a6 as Arrayable, a4 as Awaitable, ap as BaseCoverageOptions, av as BenchFunction, at as Benchmark, aw as BenchmarkAPI, au as BenchmarkResult, as as BenchmarkUserOptions, B as BuiltinEnvironment, i as CSSModuleScopeStrategy, C as CollectLineNumbers, f as CollectLines, ab as Constructable, h as Context, ar as CoverageC8Options, aq as CoverageIstanbulOptions, an as CoverageOptions, ak as CoverageProvider, al as CoverageProviderModule, am as CoverageReporter, a9 as DeepMerge, D as DoneCallback, ae as Environment, E as EnvironmentOptions, ad as EnvironmentReturn, ai as ErrorWithDiff, a as File, x as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, a8 as MergeInsertions, ac as ModuleCache, M as ModuleGraphData, aa as MutableArray, a5 as Nullable, aj as OnServerRestartHandler, O as OnTestFailedHandler, ah as ParsedStack, ag as Position, d as RawErrsMap, c as Reporter, a0 as ResolveIdFunction, b as ResolvedConfig, ao as ResolvedCoverageOptions, g as RootAndTarget, l as RunMode, R as RuntimeConfig, K as RuntimeContext, S as SequenceHooks, P as SnapshotData, X as SnapshotMatchOptions, Y as SnapshotResult, W as SnapshotStateOptions, _ as SnapshotSummary, Q as SnapshotUpdateState, p as Suite, w as SuiteAPI, z as SuiteCollector, G as SuiteFactory, y as SuiteHooks, s as Task, n as TaskBase, o as TaskResult, T as TaskResultPack, m as TaskState, q as Test, v as TestAPI, L as TestContext, t as TestFunction, u as TestOptions, e as TscErrorInfo, r as TypeCheck, k as TypecheckConfig, Z as UncheckedSnapshot, U as UserConfig, af as UserConsoleLog, N as Vitest, V as VitestEnvironment, j as VitestRunMode, $ as WorkerContext, a3 as WorkerGlobalState, a2 as WorkerRPC } from './types-de0e0997.js';
1
+ import { s as spyOn, f as fn, M as MaybeMockedDeep, a as MaybeMocked, b as MaybePartiallyMocked, c as MaybePartiallyMockedDeep, E as EnhancedSpy } from './index-81973d31.js';
2
+ export { A as AssertType, E as EnhancedSpy, q as ExpectTypeOf, x as Mock, y as MockContext, w as MockInstance, z as Mocked, B as MockedClass, u as MockedFunction, v as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, r as assertType, h as beforeAll, k as beforeEach, g as bench, n as createExpect, e as describe, m as expect, p as expectTypeOf, i as it, o as onTestFailed, d as suite, t as test } from './index-81973d31.js';
3
+ import { D as DoneCallback, F as FakeTimerInstallOpts, R as RuntimeConfig, a as File, T as TaskResultPack, b as ResolvedConfig, M as ModuleGraphData, c as Reporter } from './types-1cf24598.js';
4
+ export { a1 as AfterSuiteRunMeta, A as ApiConfig, a7 as ArgumentsType, a6 as Arrayable, a4 as Awaitable, ap as BaseCoverageOptions, av as BenchFunction, at as Benchmark, aw as BenchmarkAPI, au as BenchmarkResult, as as BenchmarkUserOptions, B as BuiltinEnvironment, i as CSSModuleScopeStrategy, C as CollectLineNumbers, f as CollectLines, ab as Constructable, h as Context, ar as CoverageC8Options, aq as CoverageIstanbulOptions, an as CoverageOptions, ak as CoverageProvider, al as CoverageProviderModule, am as CoverageReporter, a9 as DeepMerge, D as DoneCallback, ae as Environment, E as EnvironmentOptions, ad as EnvironmentReturn, ai as ErrorWithDiff, a as File, x as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, a8 as MergeInsertions, ac as ModuleCache, M as ModuleGraphData, aa as MutableArray, a5 as Nullable, aj as OnServerRestartHandler, O as OnTestFailedHandler, ah as ParsedStack, ag as Position, d as RawErrsMap, c as Reporter, a0 as ResolveIdFunction, b as ResolvedConfig, ao as ResolvedCoverageOptions, g as RootAndTarget, l as RunMode, R as RuntimeConfig, K as RuntimeContext, S as SequenceHooks, P as SnapshotData, X as SnapshotMatchOptions, Y as SnapshotResult, W as SnapshotStateOptions, _ as SnapshotSummary, Q as SnapshotUpdateState, p as Suite, w as SuiteAPI, z as SuiteCollector, G as SuiteFactory, y as SuiteHooks, s as Task, n as TaskBase, o as TaskResult, T as TaskResultPack, m as TaskState, q as Test, v as TestAPI, L as TestContext, t as TestFunction, u as TestOptions, e as TscErrorInfo, r as TypeCheck, k as TypecheckConfig, Z as UncheckedSnapshot, U as UserConfig, af as UserConsoleLog, N as Vitest, V as VitestEnvironment, j as VitestRunMode, $ as WorkerContext, a3 as WorkerGlobalState, a2 as WorkerRPC } from './types-1cf24598.js';
5
5
  import { TransformResult } from 'vite';
6
6
  import * as chai from 'chai';
7
7
  export { chai };
@@ -146,7 +146,7 @@ declare class VitestUtils {
146
146
  /**
147
147
  * Wait for all imports to load.
148
148
  * Useful, if you have a synchronous call that starts
149
- * importing a module, that you cannot wait otherwise.
149
+ * importing a module that you cannot wait otherwise.
150
150
  */
151
151
  dynamicImportSettled(): Promise<void>;
152
152
  private _config;
package/dist/index.js CHANGED
@@ -1,21 +1,21 @@
1
- export { b as bench, c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.f993b1dc.js';
2
- import { e as dist } from './chunk-runtime-test-state.de4d6ff8.js';
3
- export { a as afterAll, d as afterEach, f as assertType, b as beforeAll, c as beforeEach, k as getRunningMode, h as isFirstRun, l as isWatchMode, o as onTestFailed, g as runOnce, v as vi, j as vitest, w as withCallback } from './chunk-runtime-test-state.de4d6ff8.js';
1
+ export { b as bench, c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.315721df.js';
2
+ import { e as dist } from './chunk-runtime-test-state.7c288e2d.js';
3
+ export { a as afterAll, d as afterEach, f as assertType, b as beforeAll, c as beforeEach, k as getRunningMode, h as isFirstRun, l as isWatchMode, o as onTestFailed, g as runOnce, v as vi, j as vitest, w as withCallback } from './chunk-runtime-test-state.7c288e2d.js';
4
4
  import * as chai from 'chai';
5
5
  export { chai };
6
6
  export { assert, should } from 'chai';
7
7
  import 'util';
8
- import './chunk-typecheck-constants.4891f22f.js';
8
+ import './chunk-typecheck-constants.ed987901.js';
9
9
  import 'path';
10
10
  import './chunk-utils-env.03f840f2.js';
11
11
  import 'tty';
12
12
  import 'url';
13
13
  import 'local-pkg';
14
14
  import './vendor-_commonjsHelpers.addc3445.js';
15
- import './chunk-runtime-rpc.1e7530d3.js';
16
- import './chunk-utils-timers.06f993db.js';
15
+ import './chunk-runtime-rpc.b368762d.js';
16
+ import './chunk-utils-timers.b81cda77.js';
17
17
  import 'fs';
18
- import './chunk-utils-source-map.c6dfbbc1.js';
18
+ import './chunk-utils-source-map.29ff1088.js';
19
19
  import './spy.js';
20
20
  import 'tinyspy';
21
21
 
package/dist/loader.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { pathToFileURL } from 'url';
2
2
  import { readFile } from 'fs/promises';
3
- import { i as isNodeBuiltin, d as normalizeModuleId, h as hasCJSSyntax } from './chunk-vite-node-utils.f6d73fbe.js';
4
- import { g as getWorkerState } from './chunk-typecheck-constants.4891f22f.js';
3
+ import { i as isNodeBuiltin, d as normalizeModuleId, h as hasCJSSyntax } from './chunk-vite-node-utils.abe05c5c.js';
4
+ import { g as getWorkerState } from './chunk-typecheck-constants.ed987901.js';
5
5
  import 'fs';
6
6
  import './chunk-utils-env.03f840f2.js';
7
7
  import 'tty';
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { j as VitestRunMode, U as UserConfig, N as Vitest, ax as ModuleCacheMap, ay as ViteNodeRunnerOptions, az as MockMap, aA as ViteNodeRunner, aB as TestSequencer } from './types-de0e0997.js';
2
- export { aB as TestSequencer, aD as TestSequencerConstructor, N as Vitest, aC as startVitest } from './types-de0e0997.js';
1
+ import { j as VitestRunMode, U as UserConfig, N as Vitest, ax as ModuleCacheMap, ay as ViteNodeRunnerOptions, az as MockMap, aA as ViteNodeRunner, aB as TestSequencer } from './types-1cf24598.js';
2
+ export { aB as TestSequencer, aD as TestSequencerConstructor, N as Vitest, aC as startVitest } from './types-1cf24598.js';
3
3
  import { UserConfig as UserConfig$1, Plugin } from 'vite';
4
4
  import 'tinybench';
5
5
  import 'fs';
@@ -20,6 +20,7 @@ declare class VitestMocker {
20
20
  private request;
21
21
  private static pendingIds;
22
22
  private static spyModule?;
23
+ private resolveCache;
23
24
  constructor(options: ExecuteOptions, moduleCache: ModuleCacheMap, request: ViteRunnerRequest);
24
25
  private get root();
25
26
  private get base();
@@ -36,9 +37,9 @@ declare class VitestMocker {
36
37
  normalizePath(path: string): string;
37
38
  getFsPath(path: string, external: string | null): string;
38
39
  resolveMockPath(mockPath: string, external: string | null): string | null;
39
- mockObject(object: Record<string | symbol, any>): Record<Key, any>;
40
+ mockObject(object: Record<Key, any>, mockExports?: Record<Key, any>): Record<Key, any>;
40
41
  unmockPath(path: string): void;
41
- mockPath(path: string, external: string | null, factory?: () => any): void;
42
+ mockPath(originalId: string, path: string, external: string | null, factory?: () => any): void;
42
43
  importActual<T>(id: string, importer: string): Promise<T>;
43
44
  importMock(id: string, importer: string): Promise<any>;
44
45
  private ensureSpy;