vitest 1.2.0 → 1.2.1

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 (42) hide show
  1. package/dist/browser.d.ts +1 -1
  2. package/dist/browser.js +1 -1
  3. package/dist/chunks/{api-setup.MAoRkVWJ.js → api-setup.omeaEsoT.js} +4 -4
  4. package/dist/chunks/{integrations-globals.VbxbZ7hn.js → integrations-globals.9QpVy4UR.js} +3 -3
  5. package/dist/chunks/{runtime-console.hf2msWA9.js → runtime-console.Iloo9fIt.js} +2 -2
  6. package/dist/chunks/{runtime-runBaseTests.LWFmrzDk.js → runtime-runBaseTests.S8ZSFig3.js} +6 -6
  7. package/dist/cli.js +4 -4
  8. package/dist/config.d.ts +1 -74
  9. package/dist/coverage.d.ts +1 -1
  10. package/dist/environments.d.ts +1 -1
  11. package/dist/execute.d.ts +1 -1
  12. package/dist/execute.js +2 -2
  13. package/dist/index.d.ts +3 -4
  14. package/dist/index.js +4 -4
  15. package/dist/node.d.ts +2 -2
  16. package/dist/node.js +4 -4
  17. package/dist/{reporters-trlZlObr.d.ts → reporters-rzC174PQ.d.ts} +78 -3
  18. package/dist/reporters.d.ts +1 -1
  19. package/dist/reporters.js +3 -3
  20. package/dist/runners.d.ts +1 -1
  21. package/dist/runners.js +2 -2
  22. package/dist/{suite-6Pt_ep5V.d.ts → suite-MFRDkZcV.d.ts} +1 -1
  23. package/dist/suite.d.ts +2 -2
  24. package/dist/vendor/{base.8wUUWReP.js → base.4sEqnqgY.js} +2 -2
  25. package/dist/vendor/{base.dzu0Y6Hj.js → base.QYERqzkH.js} +1 -1
  26. package/dist/vendor/{execute.3_hyGknJ.js → execute.edwByI27.js} +1 -1
  27. package/dist/vendor/{index.D-jOsMas.js → index.kwCLJK4i.js} +1 -1
  28. package/dist/vendor/{index.3iX2R_Z5.js → index.vs_-lzuF.js} +1 -1
  29. package/dist/vendor/{node.xyYo9ZvH.js → node.p6h5JSuL.js} +81 -49
  30. package/dist/vendor/{reporters.2PaQ2peU.js → reporters.cA9x-5v-.js} +2 -2
  31. package/dist/vendor/{setup-common.j9IXYrbN.js → setup-common.4GIL70qB.js} +1 -1
  32. package/dist/vendor/{vi.smj1Ggd4.js → vi.Bw2UL9c9.js} +13 -4
  33. package/dist/vendor/{vm.vFKXXdo0.js → vm.9N6CwTZh.js} +2 -2
  34. package/dist/worker.js +1 -1
  35. package/dist/workers/forks.js +3 -3
  36. package/dist/workers/runVmTests.js +5 -5
  37. package/dist/workers/threads.js +3 -3
  38. package/dist/workers/vmForks.js +4 -4
  39. package/dist/workers/vmThreads.js +4 -4
  40. package/dist/workers.d.ts +1 -1
  41. package/dist/workers.js +5 -5
  42. package/package.json +8 -8
@@ -25,9 +25,9 @@ import nodeos__default from 'node:os';
25
25
  import EventEmitter from 'node:events';
26
26
  import Tinypool$1, { Tinypool } from 'tinypool';
27
27
  import { c as createBirpc } from './index.cAUulNDf.js';
28
- import { g as groupBy, A as AggregateErrorPonyfill, b as slash$1, t as toArray, a as isPrimitive, d as deepMerge, n as noop$1, c as stdout } from './base.dzu0Y6Hj.js';
28
+ import { g as groupBy, A as AggregateErrorPonyfill, b as slash$1, t as toArray, a as isPrimitive, d as deepMerge, n as noop$1, c as stdout } from './base.QYERqzkH.js';
29
29
  import { MessageChannel } from 'node:worker_threads';
30
- import { createDefer, shuffle, inspect, positionToOffset, lineSplitRE, highlight, toArray as toArray$1, notNullish } from '@vitest/utils';
30
+ import { createDefer, shuffle, highlight, inspect, positionToOffset, lineSplitRE, toArray as toArray$1, notNullish } from '@vitest/utils';
31
31
  import { writeFile, rm } from 'node:fs/promises';
32
32
  import { performance } from 'node:perf_hooks';
33
33
  import { execa } from 'execa';
@@ -35,7 +35,7 @@ import { TraceMap, generatedPositionFor, parseErrorStacktrace } from '@vitest/ut
35
35
  import ge from 'module';
36
36
  import { ancestor, findNodeAround } from 'acorn-walk';
37
37
  import { generateHash, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, getTasks, hasFailed, getTests } from '@vitest/runner/utils';
38
- import { R as ReportersMap, B as BenchmarkReportsMap, s as stripAnsi, a as ansiStyles, b as sliceAnsi, d as divider, F as F_POINTER, c as cliTruncate } from './reporters.2PaQ2peU.js';
38
+ import { R as ReportersMap, B as BenchmarkReportsMap, s as stripAnsi, a as ansiStyles, b as sliceAnsi, d as divider, F as F_POINTER, c as cliTruncate } from './reporters.cA9x-5v-.js';
39
39
  import { resolveModule, isPackageExists } from 'local-pkg';
40
40
  import { isCI, provider as provider$1 } from 'std-env';
41
41
  import crypto, { createHash } from 'node:crypto';
@@ -64,7 +64,7 @@ function _mergeNamespaces(n, m) {
64
64
  return Object.freeze(n);
65
65
  }
66
66
 
67
- var version$1 = "1.2.0";
67
+ var version$1 = "1.2.1";
68
68
 
69
69
  /*
70
70
  How it works:
@@ -3523,7 +3523,8 @@ function createBrowserPool(ctx) {
3523
3523
  });
3524
3524
  const provider = project.browserProvider;
3525
3525
  providers.add(provider);
3526
- const origin = `http://${((_a = ctx.config.browser.api) == null ? void 0 : _a.host) || "localhost"}:${project.browser.config.server.port}`;
3526
+ const resolvedUrls = (_a = project.browser) == null ? void 0 : _a.resolvedUrls;
3527
+ const origin = (resolvedUrls == null ? void 0 : resolvedUrls.local[0]) ?? (resolvedUrls == null ? void 0 : resolvedUrls.network[0]);
3527
3528
  const paths = files.map((file) => relative(project.config.root, file));
3528
3529
  if (project.config.browser.isolate) {
3529
3530
  for (const path of paths) {
@@ -4475,7 +4476,6 @@ function getMemoryLimit(config) {
4475
4476
 
4476
4477
  const builtinPools = ["forks", "threads", "browser", "vmThreads", "vmForks", "typescript"];
4477
4478
  function createPool(ctx) {
4478
- var _a;
4479
4479
  const pools = {
4480
4480
  forks: null,
4481
4481
  threads: null,
@@ -4504,7 +4504,14 @@ function createPool(ctx) {
4504
4504
  }
4505
4505
  return getDefaultPoolName(project, file);
4506
4506
  }
4507
- const conditions = ((_a = ctx.server.config.resolve.conditions) == null ? void 0 : _a.flatMap((c) => ["--conditions", c])) || [];
4507
+ const potentialConditions = /* @__PURE__ */ new Set(["production", "development", ...ctx.server.config.resolve.conditions]);
4508
+ const conditions = [...potentialConditions].filter((condition) => {
4509
+ if (condition === "production")
4510
+ return ctx.server.config.isProduction;
4511
+ if (condition === "development")
4512
+ return !ctx.server.config.isProduction;
4513
+ return true;
4514
+ }).flatMap((c) => ["--conditions", c]);
4508
4515
  const execArgv = process.execArgv.filter(
4509
4516
  (execArg) => execArg.startsWith("--cpu-prof") || execArg.startsWith("--heap-prof") || execArg.startsWith("--diagnostic-dir")
4510
4517
  );
@@ -4567,7 +4574,7 @@ function createPool(ctx) {
4567
4574
  return sequencer.sort(specs);
4568
4575
  }
4569
4576
  await Promise.all(Object.entries(filesByPool).map(async (entry) => {
4570
- var _a2;
4577
+ var _a;
4571
4578
  const [pool, files2] = entry;
4572
4579
  if (!files2.length)
4573
4580
  return null;
@@ -4578,7 +4585,7 @@ function createPool(ctx) {
4578
4585
  return pools[pool].runTests(specs, invalidate);
4579
4586
  }
4580
4587
  const poolHandler = await resolveCustomPool(pool);
4581
- pools[_a2 = poolHandler.name] ?? (pools[_a2] = poolHandler);
4588
+ pools[_a = poolHandler.name] ?? (pools[_a] = poolHandler);
4582
4589
  return poolHandler.runTests(specs, invalidate);
4583
4590
  }));
4584
4591
  }
@@ -4587,8 +4594,8 @@ function createPool(ctx) {
4587
4594
  runTests,
4588
4595
  async close() {
4589
4596
  await Promise.all(Object.values(pools).map((p) => {
4590
- var _a2;
4591
- return (_a2 = p == null ? void 0 : p.close) == null ? void 0 : _a2.call(p);
4597
+ var _a;
4598
+ return (_a = p == null ? void 0 : p.close) == null ? void 0 : _a.call(p);
4592
4599
  }));
4593
4600
  }
4594
4601
  };
@@ -6573,7 +6580,23 @@ createLogUpdate(process$2.stdout);
6573
6580
 
6574
6581
  createLogUpdate(process$2.stderr);
6575
6582
 
6576
- var version = "1.2.0";
6583
+ var version = "1.2.1";
6584
+
6585
+ const HIGHLIGHT_SUPPORTED_EXTS = new Set(["js", "ts"].flatMap((lang) => [
6586
+ `.${lang}`,
6587
+ `.m${lang}`,
6588
+ `.c${lang}`,
6589
+ `.${lang}x`,
6590
+ `.m${lang}x`,
6591
+ `.c${lang}x`
6592
+ ]));
6593
+ function highlightCode(id, source, colors) {
6594
+ const ext = extname(id);
6595
+ if (!HIGHLIGHT_SUPPORTED_EXTS.has(ext))
6596
+ return source;
6597
+ const isJsx = ext.endsWith("x");
6598
+ return highlight(source, { jsx: isJsx, colors: colors || c });
6599
+ }
6577
6600
 
6578
6601
  async function printError(error, project, options) {
6579
6602
  const { showCodeFrame = true, fullStack = false, type } = options;
@@ -6807,14 +6830,6 @@ const ERASE_DOWN = `${ESC$1}J`;
6807
6830
  const ERASE_SCROLLBACK = `${ESC$1}3J`;
6808
6831
  const CURSOR_TO_START = `${ESC$1}1;1H`;
6809
6832
  const CLEAR_SCREEN = "\x1Bc";
6810
- const HIGHLIGHT_SUPPORTED_EXTS = new Set(["js", "ts"].flatMap((lang) => [
6811
- `.${lang}`,
6812
- `.m${lang}`,
6813
- `.c${lang}`,
6814
- `.${lang}x`,
6815
- `.m${lang}x`,
6816
- `.c${lang}x`
6817
- ]));
6818
6833
  class Logger {
6819
6834
  constructor(ctx, console = globalThis.console) {
6820
6835
  this.ctx = ctx;
@@ -6880,11 +6895,7 @@ class Logger {
6880
6895
  highlight(filename, source) {
6881
6896
  if (this._highlights.has(filename))
6882
6897
  return this._highlights.get(filename);
6883
- const ext = extname(filename);
6884
- if (!HIGHLIGHT_SUPPORTED_EXTS.has(ext))
6885
- return source;
6886
- const isJsx = ext.endsWith("x");
6887
- const code = highlight(source, { jsx: isJsx, colors: c });
6898
+ const code = highlightCode(filename, source);
6888
6899
  this._highlights.set(filename, code);
6889
6900
  return code;
6890
6901
  }
@@ -6935,12 +6946,13 @@ No ${config.mode} files found, exiting with code 1`));
6935
6946
  if (this.ctx.config.sequence.sequencer === RandomSequencer)
6936
6947
  this.log(c.gray(` Running tests with seed "${this.ctx.config.sequence.seed}"`));
6937
6948
  this.ctx.projects.forEach((project) => {
6938
- var _a2;
6939
6949
  if (!project.browser)
6940
6950
  return;
6941
6951
  const name = project.getName();
6942
6952
  const output = project.isCore() ? "" : ` [${name}]`;
6943
- this.log(c.dim(c.green(` ${output} Browser runner started at http://${((_a2 = project.config.browser.api) == null ? void 0 : _a2.host) || "localhost"}:${c.bold(`${project.browser.config.server.port}`)}`)));
6953
+ const resolvedUrls = project.browser.resolvedUrls;
6954
+ const origin = (resolvedUrls == null ? void 0 : resolvedUrls.local[0]) ?? (resolvedUrls == null ? void 0 : resolvedUrls.network[0]);
6955
+ this.log(c.dim(c.green(` ${output} Browser runner started at ${new URL("/", origin)}`)));
6944
6956
  });
6945
6957
  if (this.ctx.config.ui)
6946
6958
  this.log(c.dim(c.green(` UI started at http://${((_a = this.ctx.config.api) == null ? void 0 : _a.host) || "localhost"}:${c.bold(`${this.ctx.server.config.server.port}`)}${this.ctx.config.uiBase}`)));
@@ -7023,12 +7035,11 @@ function getBetterEnd(code, node) {
7023
7035
  end += 1;
7024
7036
  return end;
7025
7037
  }
7026
- const regexpHoistable = /^[ \t]*\b(vi|vitest)\s*\.\s*(mock|unmock|hoisted)\(/m;
7027
- const regexpAssignedHoisted = /=[ \t]*(\bawait|)[ \t]*\b(vi|vitest)\s*\.\s*hoisted\(/;
7038
+ const regexpHoistable = /\b(vi|vitest)\s*\.\s*(mock|unmock|hoisted)\(/;
7028
7039
  const hashbangRE = /^#!.*\n/;
7029
- function hoistMocks(code, id, parse) {
7040
+ function hoistMocks(code, id, parse, colors) {
7030
7041
  var _a;
7031
- const needHoisting = regexpHoistable.test(code) || regexpAssignedHoisted.test(code);
7042
+ const needHoisting = regexpHoistable.test(code);
7032
7043
  if (!needHoisting)
7033
7044
  return;
7034
7045
  const s = new MagicString(code);
@@ -7092,6 +7103,16 @@ ${err.message}`);
7092
7103
  }
7093
7104
  const declaredConst = /* @__PURE__ */ new Set();
7094
7105
  const hoistedNodes = [];
7106
+ function createSyntaxError(node, message) {
7107
+ const _error = new SyntaxError(message);
7108
+ Error.captureStackTrace(_error, createSyntaxError);
7109
+ return {
7110
+ name: "SyntaxError",
7111
+ message: _error.message,
7112
+ stack: _error.stack,
7113
+ frame: generateCodeFrame(highlightCode(id, code, colors), 4, node.start + 1)
7114
+ };
7115
+ }
7095
7116
  esmWalker(ast, {
7096
7117
  onIdentifier(id2, info, parentStack) {
7097
7118
  const binding = idToImportMap.get(id2.name);
@@ -7114,22 +7135,28 @@ ${err.message}`);
7114
7135
  }
7115
7136
  },
7116
7137
  onCallExpression(node) {
7117
- var _a2, _b, _c;
7138
+ var _a2, _b, _c, _d, _e;
7118
7139
  if (node.callee.type === "MemberExpression" && isIdentifier(node.callee.object) && (node.callee.object.name === "vi" || node.callee.object.name === "vitest") && isIdentifier(node.callee.property)) {
7119
7140
  const methodName = node.callee.property.name;
7120
7141
  if (methodName === "mock" || methodName === "unmock")
7121
7142
  hoistedNodes.push(node);
7122
7143
  if (methodName === "hoisted") {
7123
- const declarationNode = (_a2 = findNodeAround(ast, node.start, "VariableDeclaration")) == null ? void 0 : _a2.node;
7124
- const init = (_b = declarationNode == null ? void 0 : declarationNode.declarations[0]) == null ? void 0 : _b.init;
7144
+ const defaultExport = (_a2 = findNodeAround(ast, node.start, "ExportDefaultDeclaration")) == null ? void 0 : _a2.node;
7145
+ if ((defaultExport == null ? void 0 : defaultExport.declaration) === node || (defaultExport == null ? void 0 : defaultExport.declaration.type) === "AwaitExpression" && defaultExport.declaration.argument === node)
7146
+ throw createSyntaxError(defaultExport, "Cannot export hoisted variable. You can control hoisting behavior by placing the import from this file first.");
7147
+ const declarationNode = (_b = findNodeAround(ast, node.start, "VariableDeclaration")) == null ? void 0 : _b.node;
7148
+ const init = (_c = declarationNode == null ? void 0 : declarationNode.declarations[0]) == null ? void 0 : _c.init;
7125
7149
  const isViHoisted = (node2) => {
7126
7150
  return node2.callee.type === "MemberExpression" && isIdentifier(node2.callee.object) && (node2.callee.object.name === "vi" || node2.callee.object.name === "vitest") && isIdentifier(node2.callee.property) && node2.callee.property.name === "hoisted";
7127
7151
  };
7128
7152
  const canMoveDeclaration = init && init.type === "CallExpression" && isViHoisted(init) || init && init.type === "AwaitExpression" && init.argument.type === "CallExpression" && isViHoisted(init.argument);
7129
7153
  if (canMoveDeclaration) {
7154
+ const nodeExported = (_d = findNodeAround(ast, declarationNode.start, "ExportNamedDeclaration")) == null ? void 0 : _d.node;
7155
+ if ((nodeExported == null ? void 0 : nodeExported.declaration) === declarationNode)
7156
+ throw createSyntaxError(nodeExported, "Cannot export hoisted variable. You can control hoisting behavior by placing the import from this file first.");
7130
7157
  hoistedNodes.push(declarationNode);
7131
7158
  } else {
7132
- const awaitedExpression = (_c = findNodeAround(ast, node.start, "AwaitExpression")) == null ? void 0 : _c.node;
7159
+ const awaitedExpression = (_e = findNodeAround(ast, node.start, "AwaitExpression")) == null ? void 0 : _e.node;
7133
7160
  hoistedNodes.push((awaitedExpression == null ? void 0 : awaitedExpression.argument) === node ? awaitedExpression : node);
7134
7161
  }
7135
7162
  }
@@ -7161,14 +7188,10 @@ ${err.message}`);
7161
7188
  function createError(outsideNode, insideNode) {
7162
7189
  const outsideCall = getNodeCall(outsideNode);
7163
7190
  const insideCall = getNodeCall(insideNode);
7164
- const _error = new SyntaxError(`Cannot call ${getNodeName(insideCall)} inside ${getNodeName(outsideCall)}: both methods are hoisted to the top of the file and not actually called inside each other.`);
7165
- const error = {
7166
- name: "SyntaxError",
7167
- message: _error.message,
7168
- stack: _error.stack,
7169
- frame: generateCodeFrame(highlight(code), 4, insideCall.start + 1)
7170
- };
7171
- throw error;
7191
+ throw createSyntaxError(
7192
+ insideCall,
7193
+ `Cannot call ${getNodeName(insideCall)} inside ${getNodeName(outsideCall)}: both methods are hoisted to the top of the file and not actually called inside each other.`
7194
+ );
7172
7195
  }
7173
7196
  for (let i = 0; i < hoistedNodes.length; i++) {
7174
7197
  const node = hoistedNodes[i];
@@ -7299,10 +7322,13 @@ function resolveFsAllow(projectRoot, rootConfigFile) {
7299
7322
  }
7300
7323
 
7301
7324
  async function createBrowserServer(project, configFile) {
7325
+ var _a;
7302
7326
  const root = project.config.root;
7303
7327
  await project.ctx.packageInstaller.ensureInstalled("@vitest/browser", root);
7304
7328
  const configPath = typeof configFile === "string" ? configFile : false;
7305
7329
  const server = await createServer({
7330
+ ...project.options,
7331
+ // spread project config inlined in root workspace config
7306
7332
  logLevel: "error",
7307
7333
  mode: project.config.mode,
7308
7334
  configFile: configPath,
@@ -7314,14 +7340,15 @@ async function createBrowserServer(project, configFile) {
7314
7340
  }
7315
7341
  },
7316
7342
  plugins: [
7343
+ ...((_a = project.options) == null ? void 0 : _a.plugins) || [],
7317
7344
  (await import('@vitest/browser')).default(project, "/"),
7318
7345
  CoverageTransform(project.ctx),
7319
7346
  {
7320
7347
  enforce: "post",
7321
7348
  name: "vitest:browser:config",
7322
7349
  async config(config) {
7323
- var _a, _b, _c;
7324
- const server2 = resolveApiServerConfig(((_a = config.test) == null ? void 0 : _a.browser) || {}) || {
7350
+ var _a2, _b, _c;
7351
+ const server2 = resolveApiServerConfig(((_a2 = config.test) == null ? void 0 : _a2.browser) || {}) || {
7325
7352
  port: defaultBrowserPort
7326
7353
  };
7327
7354
  server2.middlewareMode = false;
@@ -7351,7 +7378,7 @@ async function createBrowserServer(project, configFile) {
7351
7378
  ]
7352
7379
  });
7353
7380
  await server.listen();
7354
- (await import('../chunks/api-setup.MAoRkVWJ.js')).setup(project, server);
7381
+ (await import('../chunks/api-setup.omeaEsoT.js')).setup(project, server);
7355
7382
  return server;
7356
7383
  }
7357
7384
 
@@ -7680,7 +7707,7 @@ async function loadGlobalSetupFile(file, runner) {
7680
7707
 
7681
7708
  async function initializeProject(workspacePath, ctx, options) {
7682
7709
  var _a;
7683
- const project = new WorkspaceProject(workspacePath, ctx);
7710
+ const project = new WorkspaceProject(workspacePath, ctx, options);
7684
7711
  const configFile = options.extends ? resolve(dirname(options.workspaceConfigPath), options.extends) : typeof workspacePath === "number" || workspacePath.endsWith("/") ? false : workspacePath;
7685
7712
  const root = options.root || (typeof workspacePath === "number" ? void 0 : workspacePath.endsWith("/") ? workspacePath : dirname(workspacePath));
7686
7713
  const config = {
@@ -7699,9 +7726,10 @@ async function initializeProject(workspacePath, ctx, options) {
7699
7726
  return project;
7700
7727
  }
7701
7728
  class WorkspaceProject {
7702
- constructor(path, ctx) {
7729
+ constructor(path, ctx, options) {
7703
7730
  this.path = path;
7704
7731
  this.ctx = ctx;
7732
+ this.options = options;
7705
7733
  }
7706
7734
  configOverride;
7707
7735
  config;
@@ -8542,6 +8570,10 @@ class Vitest {
8542
8570
  this.projectsTestFiles.set(id, new Set(matchingProjects));
8543
8571
  this.changedTests.add(id);
8544
8572
  this.scheduleRerun([id]);
8573
+ } else {
8574
+ const needsRerun = this.handleFileChanged(id);
8575
+ if (needsRerun.length)
8576
+ this.scheduleRerun(needsRerun);
8545
8577
  }
8546
8578
  };
8547
8579
  const watcher = this.server.watcher;
@@ -8833,7 +8865,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
8833
8865
  try {
8834
8866
  await ctx.setServer(options, server, userConfig);
8835
8867
  if (options.api && options.watch)
8836
- (await import('../chunks/api-setup.MAoRkVWJ.js')).setup(ctx);
8868
+ (await import('../chunks/api-setup.omeaEsoT.js')).setup(ctx);
8837
8869
  } catch (err) {
8838
8870
  await ctx.logger.printError(err, { fullStack: true });
8839
8871
  process.exit(1);
@@ -1,9 +1,9 @@
1
1
  import { performance } from 'node:perf_hooks';
2
2
  import c from 'picocolors';
3
3
  import { b as isNode, c as relativePath } from './index.rJjbcrrp.js';
4
- import { UNKNOWN_TEST_ID } from '../chunks/runtime-console.hf2msWA9.js';
4
+ import { UNKNOWN_TEST_ID } from '../chunks/runtime-console.Iloo9fIt.js';
5
5
  import { isAbsolute, relative, dirname, basename, resolve } from 'pathe';
6
- import { b as slash, t as toArray } from './base.dzu0Y6Hj.js';
6
+ import { b as slash, t as toArray } from './base.QYERqzkH.js';
7
7
  import { g as getFullName, h as hasFailedSnapshot } from './tasks.IknbGB2n.js';
8
8
  import { getSafeTimers, notNullish } from '@vitest/utils';
9
9
  import { isCI } from 'std-env';
@@ -10,7 +10,7 @@ async function setupCommonEnv(config) {
10
10
  globalSetup = true;
11
11
  setSafeTimers();
12
12
  if (config.globals)
13
- (await import('../chunks/integrations-globals.VbxbZ7hn.js')).registerApiGlobally();
13
+ (await import('../chunks/integrations-globals.9QpVy4UR.js')).registerApiGlobally();
14
14
  }
15
15
  function setupDefines(defines) {
16
16
  for (const key in defines)
@@ -9,7 +9,7 @@ import { g as getFullName } from './tasks.IknbGB2n.js';
9
9
  import { g as getWorkerState, a as getCurrentEnvironment } from './global.CkGT_TMy.js';
10
10
  import { getSafeTimers, assertTypes, createSimpleStackTrace } from '@vitest/utils';
11
11
  import { parseSingleStack } from '@vitest/utils/source-map';
12
- import { i as isChildProcess } from './base.dzu0Y6Hj.js';
12
+ import { i as isChildProcess } from './base.QYERqzkH.js';
13
13
  import { R as RealDate, r as resetDate, m as mockDate } from './date.Ns1pGd_X.js';
14
14
  import { spyOn, fn, isMockFunction, mocks } from '@vitest/spy';
15
15
 
@@ -3118,7 +3118,7 @@ class FakeTimers {
3118
3118
  }
3119
3119
  }
3120
3120
  useFakeTimers() {
3121
- var _a, _b;
3121
+ var _a, _b, _c;
3122
3122
  if (this._fakingDate) {
3123
3123
  throw new Error(
3124
3124
  '"setSystemTime" was called already and date was mocked. Reset timers using `vi.useRealTimers()` if you want to use fake timers again.'
@@ -3128,10 +3128,19 @@ class FakeTimers {
3128
3128
  const toFake = Object.keys(this._fakeTimers.timers).filter((timer) => timer !== "nextTick");
3129
3129
  if (((_b = (_a = this._userConfig) == null ? void 0 : _a.toFake) == null ? void 0 : _b.includes("nextTick")) && isChildProcess())
3130
3130
  throw new Error("process.nextTick cannot be mocked inside child_process");
3131
+ const existingFakedMethods = (((_c = this._userConfig) == null ? void 0 : _c.toFake) || toFake).filter((method) => {
3132
+ switch (method) {
3133
+ case "hrtime":
3134
+ case "nextTick":
3135
+ return typeof process !== "undefined" && method in process && process[method];
3136
+ default:
3137
+ return method in globalThis && globalThis[method];
3138
+ }
3139
+ });
3131
3140
  this._clock = this._fakeTimers.install({
3132
3141
  now: Date.now(),
3133
- toFake,
3134
- ...this._userConfig
3142
+ ...this._userConfig,
3143
+ toFake: existingFakedMethods
3135
3144
  });
3136
3145
  this._fakingTime = true;
3137
3146
  }
@@ -1,8 +1,8 @@
1
1
  import vm, { isContext } from 'node:vm';
2
2
  import { pathToFileURL, fileURLToPath } from 'node:url';
3
3
  import { dirname, basename, extname, normalize, join, resolve } from 'pathe';
4
- import { createCustomConsole } from '../chunks/runtime-console.hf2msWA9.js';
5
- import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.3_hyGknJ.js';
4
+ import { createCustomConsole } from '../chunks/runtime-console.Iloo9fIt.js';
5
+ import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.edwByI27.js';
6
6
  import { distDir } from '../path.js';
7
7
  import { dirname as dirname$1 } from 'node:path';
8
8
  import { statSync, readFileSync } from 'node:fs';
package/dist/worker.js CHANGED
@@ -3,7 +3,7 @@ import { workerId } from 'tinypool';
3
3
  import { ViteNodeRunner, ModuleCacheMap } from 'vite-node/client';
4
4
  import { resolve, normalize } from 'pathe';
5
5
  import { e as environments } from './vendor/environments.sU0TD7wX.js';
6
- import { i as isChildProcess, s as setProcessTitle } from './vendor/base.dzu0Y6Hj.js';
6
+ import { i as isChildProcess, s as setProcessTitle } from './vendor/base.QYERqzkH.js';
7
7
  import { createRequire } from 'node:module';
8
8
  import { c as createRuntimeRpc, a as rpcDone } from './vendor/rpc.w4v8oCkK.js';
9
9
  import 'node:console';
@@ -1,10 +1,10 @@
1
1
  import v8 from 'node:v8';
2
2
  import { c as createForksRpcOptions, u as unwrapForksConfig } from '../vendor/utils.GbToHGHI.js';
3
- import { r as runBaseTests } from '../vendor/base.8wUUWReP.js';
3
+ import { r as runBaseTests } from '../vendor/base.4sEqnqgY.js';
4
4
  import '@vitest/utils';
5
5
  import 'vite-node/client';
6
6
  import '../vendor/global.CkGT_TMy.js';
7
- import '../vendor/execute.3_hyGknJ.js';
7
+ import '../vendor/execute.edwByI27.js';
8
8
  import 'node:vm';
9
9
  import 'node:url';
10
10
  import 'vite-node/utils';
@@ -12,7 +12,7 @@ import 'pathe';
12
12
  import '@vitest/utils/error';
13
13
  import '../path.js';
14
14
  import 'node:fs';
15
- import '../vendor/base.dzu0Y6Hj.js';
15
+ import '../vendor/base.QYERqzkH.js';
16
16
 
17
17
  class ForksBaseWorker {
18
18
  getRpcOptions() {
@@ -5,11 +5,11 @@ import timers from 'node:timers';
5
5
  import { performance } from 'node:perf_hooks';
6
6
  import { startTests } from '@vitest/runner';
7
7
  import { setupColors, createColors } from '@vitest/utils';
8
- import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from '../vendor/index.D-jOsMas.js';
8
+ import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from '../vendor/index.kwCLJK4i.js';
9
9
  import { a as startCoverageInsideWorker, s as stopCoverageInsideWorker } from '../vendor/coverage.E7sG1b3r.js';
10
10
  import { g as getWorkerState } from '../vendor/global.CkGT_TMy.js';
11
- import { V as VitestIndex } from '../vendor/index.3iX2R_Z5.js';
12
- import { s as setupCommonEnv } from '../vendor/setup-common.j9IXYrbN.js';
11
+ import { V as VitestIndex } from '../vendor/index.vs_-lzuF.js';
12
+ import { s as setupCommonEnv } from '../vendor/setup-common.4GIL70qB.js';
13
13
  import 'chai';
14
14
  import '@vitest/snapshot/environment';
15
15
  import 'pathe';
@@ -22,14 +22,14 @@ import '@vitest/runner/utils';
22
22
  import '../vendor/index.rJjbcrrp.js';
23
23
  import 'std-env';
24
24
  import '../vendor/run-once.Olz_Zkd8.js';
25
- import '../vendor/vi.smj1Ggd4.js';
25
+ import '../vendor/vi.Bw2UL9c9.js';
26
26
  import '../vendor/_commonjsHelpers.jjO7Zipk.js';
27
27
  import '@vitest/expect';
28
28
  import '@vitest/snapshot';
29
29
  import '@vitest/utils/error';
30
30
  import '../vendor/tasks.IknbGB2n.js';
31
31
  import '@vitest/utils/source-map';
32
- import '../vendor/base.dzu0Y6Hj.js';
32
+ import '../vendor/base.QYERqzkH.js';
33
33
  import '../vendor/date.Ns1pGd_X.js';
34
34
  import '@vitest/spy';
35
35
 
@@ -1,8 +1,8 @@
1
- import { r as runBaseTests } from '../vendor/base.8wUUWReP.js';
1
+ import { r as runBaseTests } from '../vendor/base.4sEqnqgY.js';
2
2
  import { a as createThreadsRpcOptions } from '../vendor/utils.GbToHGHI.js';
3
3
  import 'vite-node/client';
4
4
  import '../vendor/global.CkGT_TMy.js';
5
- import '../vendor/execute.3_hyGknJ.js';
5
+ import '../vendor/execute.edwByI27.js';
6
6
  import 'node:vm';
7
7
  import 'node:url';
8
8
  import 'vite-node/utils';
@@ -11,7 +11,7 @@ import '@vitest/utils/error';
11
11
  import '../path.js';
12
12
  import 'node:fs';
13
13
  import '@vitest/utils';
14
- import '../vendor/base.dzu0Y6Hj.js';
14
+ import '../vendor/base.QYERqzkH.js';
15
15
 
16
16
  class ThreadsBaseWorker {
17
17
  getRpcOptions(ctx) {
@@ -1,22 +1,22 @@
1
1
  import v8 from 'node:v8';
2
2
  import { c as createForksRpcOptions, u as unwrapForksConfig } from '../vendor/utils.GbToHGHI.js';
3
- import { r as runVmTests } from '../vendor/vm.vFKXXdo0.js';
3
+ import { r as runVmTests } from '../vendor/vm.9N6CwTZh.js';
4
4
  import '@vitest/utils';
5
5
  import 'node:vm';
6
6
  import 'node:url';
7
7
  import 'pathe';
8
- import '../chunks/runtime-console.hf2msWA9.js';
8
+ import '../chunks/runtime-console.Iloo9fIt.js';
9
9
  import 'node:stream';
10
10
  import 'node:console';
11
11
  import 'node:path';
12
12
  import '../vendor/date.Ns1pGd_X.js';
13
- import '../vendor/execute.3_hyGknJ.js';
13
+ import '../vendor/execute.edwByI27.js';
14
14
  import 'vite-node/client';
15
15
  import 'vite-node/utils';
16
16
  import '@vitest/utils/error';
17
17
  import '../path.js';
18
18
  import 'node:fs';
19
- import '../vendor/base.dzu0Y6Hj.js';
19
+ import '../vendor/base.QYERqzkH.js';
20
20
  import 'node:module';
21
21
  import 'vite-node/constants';
22
22
  import '../vendor/index.rJjbcrrp.js';
@@ -1,21 +1,21 @@
1
1
  import { a as createThreadsRpcOptions } from '../vendor/utils.GbToHGHI.js';
2
- import { r as runVmTests } from '../vendor/vm.vFKXXdo0.js';
2
+ import { r as runVmTests } from '../vendor/vm.9N6CwTZh.js';
3
3
  import '@vitest/utils';
4
4
  import 'node:vm';
5
5
  import 'node:url';
6
6
  import 'pathe';
7
- import '../chunks/runtime-console.hf2msWA9.js';
7
+ import '../chunks/runtime-console.Iloo9fIt.js';
8
8
  import 'node:stream';
9
9
  import 'node:console';
10
10
  import 'node:path';
11
11
  import '../vendor/date.Ns1pGd_X.js';
12
- import '../vendor/execute.3_hyGknJ.js';
12
+ import '../vendor/execute.edwByI27.js';
13
13
  import 'vite-node/client';
14
14
  import 'vite-node/utils';
15
15
  import '@vitest/utils/error';
16
16
  import '../path.js';
17
17
  import 'node:fs';
18
- import '../vendor/base.dzu0Y6Hj.js';
18
+ import '../vendor/base.QYERqzkH.js';
19
19
  import 'node:module';
20
20
  import 'vite-node/constants';
21
21
  import '../vendor/index.rJjbcrrp.js';
package/dist/workers.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as v8 from 'v8';
2
- import { p as BirpcOptions, h as RuntimeRPC, q as ContextRPC, r as WorkerGlobalState, t as WorkerContext, R as ResolvedConfig } from './reporters-trlZlObr.js';
2
+ import { n as BirpcOptions, f as RuntimeRPC, o as ContextRPC, p as WorkerGlobalState, q as WorkerContext, R as ResolvedConfig } from './reporters-rzC174PQ.js';
3
3
  import { Awaitable } from '@vitest/utils';
4
4
  import 'vite';
5
5
  import '@vitest/runner';
package/dist/workers.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapForksConfig } from './vendor/utils.GbToHGHI.js';
2
2
  export { p as provideWorkerState } from './vendor/global.CkGT_TMy.js';
3
3
  export { run as runVitestWorker } from './worker.js';
4
- export { r as runVmTests } from './vendor/vm.vFKXXdo0.js';
5
- export { r as runBaseTests } from './vendor/base.8wUUWReP.js';
4
+ export { r as runVmTests } from './vendor/vm.9N6CwTZh.js';
5
+ export { r as runBaseTests } from './vendor/base.4sEqnqgY.js';
6
6
  import '@vitest/utils';
7
7
  import 'node:url';
8
8
  import 'tinypool';
@@ -10,16 +10,16 @@ import 'vite-node/client';
10
10
  import 'pathe';
11
11
  import './vendor/environments.sU0TD7wX.js';
12
12
  import 'node:console';
13
- import './vendor/base.dzu0Y6Hj.js';
13
+ import './vendor/base.QYERqzkH.js';
14
14
  import 'node:module';
15
15
  import './vendor/rpc.w4v8oCkK.js';
16
16
  import './vendor/index.cAUulNDf.js';
17
17
  import 'node:vm';
18
- import './chunks/runtime-console.hf2msWA9.js';
18
+ import './chunks/runtime-console.Iloo9fIt.js';
19
19
  import 'node:stream';
20
20
  import 'node:path';
21
21
  import './vendor/date.Ns1pGd_X.js';
22
- import './vendor/execute.3_hyGknJ.js';
22
+ import './vendor/execute.edwByI27.js';
23
23
  import 'vite-node/utils';
24
24
  import '@vitest/utils/error';
25
25
  import './path.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "1.2.0",
4
+ "version": "1.2.1",
5
5
  "description": "Next generation testing framework powered by Vite",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -136,7 +136,7 @@
136
136
  }
137
137
  },
138
138
  "dependencies": {
139
- "acorn-walk": "^8.3.1",
139
+ "acorn-walk": "^8.3.2",
140
140
  "cac": "^6.7.14",
141
141
  "chai": "^4.3.10",
142
142
  "debug": "^4.3.4",
@@ -151,12 +151,12 @@
151
151
  "tinypool": "^0.8.1",
152
152
  "vite": "^5.0.0",
153
153
  "why-is-node-running": "^2.2.2",
154
- "@vitest/expect": "1.2.0",
155
- "@vitest/runner": "1.2.0",
156
- "@vitest/spy": "1.2.0",
157
- "@vitest/snapshot": "1.2.0",
158
- "@vitest/utils": "1.2.0",
159
- "vite-node": "1.2.0"
154
+ "@vitest/expect": "1.2.1",
155
+ "@vitest/snapshot": "1.2.1",
156
+ "@vitest/runner": "1.2.1",
157
+ "@vitest/spy": "1.2.1",
158
+ "vite-node": "1.2.1",
159
+ "@vitest/utils": "1.2.1"
160
160
  },
161
161
  "devDependencies": {
162
162
  "@ampproject/remapping": "^2.2.1",