vitest 0.10.5 → 0.12.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 (27) hide show
  1. package/dist/{chunk-api-setup.2c4e9375.js → chunk-api-setup.a6d28d1e.js} +4 -4
  2. package/dist/{chunk-constants.54c46a47.js → chunk-constants.07c1f709.js} +1 -1
  3. package/dist/{chunk-defaults.c143550b.js → chunk-defaults.9b4b1577.js} +17 -3
  4. package/dist/{chunk-install-pkg.73b84ae1.js → chunk-install-pkg.fd8d1022.js} +1 -1
  5. package/dist/{chunk-integrations-globals.d3383e75.js → chunk-integrations-globals.bc12987e.js} +8 -8
  6. package/dist/{chunk-integrations-spy.f036df6f.js → chunk-integrations-spy.bee66426.js} +1 -1
  7. package/dist/{chunk-runtime-chain.d0bd6df6.js → chunk-runtime-chain.da3a4a85.js} +116 -90
  8. package/dist/{chunk-runtime-mocker.0871693a.js → chunk-runtime-mocker.c6de56c0.js} +15 -8
  9. package/dist/{chunk-runtime-rpc.710f6f7f.js → chunk-runtime-rpc.5148195e.js} +1 -1
  10. package/dist/{chunk-utils-global.eb31f3da.js → chunk-utils-global.7092f9ed.js} +4 -4
  11. package/dist/{chunk-utils-timers.27e0c6e9.js → chunk-utils-timers.d1b169ca.js} +1 -1
  12. package/dist/{chunk-vite-node-externalize.965e6527.js → chunk-vite-node-externalize.dcc18b18.js} +13 -15
  13. package/dist/{chunk-vite-node-utils.6b0ec89a.js → chunk-vite-node-utils.ebc9e052.js} +17 -8
  14. package/dist/cli.js +7 -7
  15. package/dist/config.cjs +15 -1
  16. package/dist/config.d.ts +67 -0
  17. package/dist/config.js +15 -1
  18. package/dist/entry.js +7 -7
  19. package/dist/index.d.ts +84 -13
  20. package/dist/index.js +5 -5
  21. package/dist/node.d.ts +89 -14
  22. package/dist/node.js +8 -8
  23. package/dist/spy.js +1 -1
  24. package/dist/{vendor-entry.9551d577.js → vendor-entry.3062f869.js} +181 -74
  25. package/dist/{vendor-index.40be925a.js → vendor-index.6c69a0a8.js} +0 -0
  26. package/dist/worker.js +14 -15
  27. package/package.json +4 -4
@@ -1,5 +1,5 @@
1
1
  import { promises } from 'fs';
2
- import { c as createBirpc } from './chunk-vite-node-utils.6b0ec89a.js';
2
+ import { c as createBirpc } from './chunk-vite-node-utils.ebc9e052.js';
3
3
  import require$$0$1 from 'stream';
4
4
  import require$$0 from 'zlib';
5
5
  import require$$3 from 'net';
@@ -9,11 +9,11 @@ import require$$2 from 'events';
9
9
  import require$$1 from 'https';
10
10
  import require$$2$1 from 'http';
11
11
  import url from 'url';
12
- import { A as API_PATH } from './chunk-constants.54c46a47.js';
13
- import { r as interpretSourcePos, b as parseStacktrace } from './chunk-utils-timers.27e0c6e9.js';
12
+ import { A as API_PATH } from './chunk-constants.07c1f709.js';
13
+ import { r as interpretSourcePos, b as parseStacktrace } from './chunk-utils-timers.d1b169ca.js';
14
14
  import 'module';
15
15
  import 'vm';
16
- import './chunk-utils-global.eb31f3da.js';
16
+ import './chunk-utils-global.7092f9ed.js';
17
17
  import 'tty';
18
18
  import 'local-pkg';
19
19
  import 'path';
@@ -1,5 +1,5 @@
1
1
  import { fileURLToPath } from 'url';
2
- import { k as resolve } from './chunk-utils-global.eb31f3da.js';
2
+ import { h as resolve } from './chunk-utils-global.7092f9ed.js';
3
3
 
4
4
  const distDir = resolve(fileURLToPath(import.meta.url), "../../dist");
5
5
  const defaultPort = 51204;
@@ -1,7 +1,7 @@
1
1
  import { existsSync, promises } from 'fs';
2
2
  import { createRequire } from 'module';
3
3
  import { pathToFileURL } from 'url';
4
- import { t as toArray, k as resolve } from './chunk-utils-global.eb31f3da.js';
4
+ import { t as toArray, h as resolve } from './chunk-utils-global.7092f9ed.js';
5
5
 
6
6
  const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
7
7
  const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**"];
@@ -28,6 +28,19 @@ const coverageConfigDefaults = {
28
28
  allowExternal: false,
29
29
  extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
30
30
  };
31
+ const fakeTimersDefaults = {
32
+ loopLimit: 1e4,
33
+ shouldClearNativeTimers: true,
34
+ toFake: [
35
+ "setTimeout",
36
+ "clearTimeout",
37
+ "setInterval",
38
+ "clearInterval",
39
+ "setImmediate",
40
+ "clearImmediate",
41
+ "Date"
42
+ ]
43
+ };
31
44
  const config = {
32
45
  allowOnly: !process.env.CI,
33
46
  watch: !process.env.CI,
@@ -50,7 +63,8 @@ const config = {
50
63
  ui: false,
51
64
  uiBase: "/__vitest__/",
52
65
  open: true,
53
- coverage: coverageConfigDefaults
66
+ coverage: coverageConfigDefaults,
67
+ fakeTimers: fakeTimersDefaults
54
68
  };
55
69
  const configDefaults = Object.freeze(config);
56
70
 
@@ -119,7 +133,7 @@ async function reportCoverage(ctx) {
119
133
  })
120
134
  };
121
135
  }));
122
- const offset = 203;
136
+ const offset = 224;
123
137
  report._getSourceMap = (coverage) => {
124
138
  const path = pathToFileURL(coverage.url).href;
125
139
  const data = sourceMapMeta[path];
@@ -2,7 +2,7 @@ import path$2 from 'path';
2
2
  import fs$2 from 'fs';
3
3
  import require$$0 from 'util';
4
4
  import childProcess$1 from 'child_process';
5
- import { p as pathKey, s as signalExit, m as mergeStream$1, g as getStream$1, c as crossSpawn$1, o as onetime$1 } from './vendor-index.40be925a.js';
5
+ import { p as pathKey, s as signalExit, m as mergeStream$1, g as getStream$1, c as crossSpawn$1, o as onetime$1 } from './vendor-index.6c69a0a8.js';
6
6
  import require$$0$1 from 'os';
7
7
  import './vendor-_commonjsHelpers.addc3445.js';
8
8
  import 'assert';
@@ -1,22 +1,22 @@
1
- import { g as globalApis } from './chunk-constants.54c46a47.js';
2
- import { i as index } from './vendor-entry.9551d577.js';
1
+ import { g as globalApis } from './chunk-constants.07c1f709.js';
2
+ import { i as index } from './vendor-entry.3062f869.js';
3
3
  import 'url';
4
- import './chunk-utils-global.eb31f3da.js';
4
+ import './chunk-utils-global.7092f9ed.js';
5
5
  import 'tty';
6
6
  import 'local-pkg';
7
7
  import 'path';
8
8
  import 'fs';
9
9
  import 'console';
10
10
  import 'stream';
11
- import './chunk-runtime-chain.d0bd6df6.js';
11
+ import './chunk-runtime-chain.da3a4a85.js';
12
12
  import 'chai';
13
13
  import './vendor-_commonjsHelpers.addc3445.js';
14
- import './chunk-runtime-rpc.710f6f7f.js';
15
- import './chunk-utils-timers.27e0c6e9.js';
16
- import './chunk-integrations-spy.f036df6f.js';
14
+ import './chunk-runtime-rpc.5148195e.js';
15
+ import './chunk-utils-timers.d1b169ca.js';
16
+ import './chunk-integrations-spy.bee66426.js';
17
17
  import 'tinyspy';
18
18
  import 'util';
19
- import './chunk-defaults.c143550b.js';
19
+ import './chunk-defaults.9b4b1577.js';
20
20
  import 'module';
21
21
  import 'crypto';
22
22
 
@@ -36,7 +36,7 @@ function enhanceSpy(spy) {
36
36
  });
37
37
  },
38
38
  get lastCall() {
39
- return stub.calls.at(-1);
39
+ return stub.calls[stub.calls.length - 1];
40
40
  }
41
41
  };
42
42
  let onceImplementations = [];
@@ -1,27 +1,27 @@
1
1
  import chai$1, { expect as expect$1, util } from 'chai';
2
2
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
3
- import { r as rpc } from './chunk-runtime-rpc.710f6f7f.js';
4
- import { i as isObject, a as index, g as getCallLastIndex, s as slash, b as getWorkerState, c as getNames, d as assertTypes, p as picocolors, n as noop, t as toArray, r as resetModules } from './chunk-utils-global.eb31f3da.js';
3
+ import { r as rpc } from './chunk-runtime-rpc.5148195e.js';
4
+ import { i as isObject, j as join, d as dirname, g as getCallLastIndex, s as slash, a as getWorkerState, b as getNames, c as assertTypes, p as picocolors, n as noop, t as toArray, r as resetModules } from './chunk-utils-global.7092f9ed.js';
5
5
  import fs, { promises } from 'fs';
6
- import { p as plugins_1, f as format_1, g as getOriginalPos, a as posToNumber, n as numberToPos, l as lineSplitRE, b as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils, c as setTimeout, d as clearTimeout } from './chunk-utils-timers.27e0c6e9.js';
7
- import { i as isMockFunction, s as spyOn, f as fn, a as spies } from './chunk-integrations-spy.f036df6f.js';
6
+ import { p as plugins_1, f as format_1, g as getOriginalPos, a as posToNumber, n as numberToPos, l as lineSplitRE, b as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils, c as setTimeout, d as clearTimeout } from './chunk-utils-timers.d1b169ca.js';
7
+ import { i as isMockFunction, s as spyOn, f as fn, a as spies } from './chunk-integrations-spy.bee66426.js';
8
8
  import require$$0, { format } from 'util';
9
9
 
10
- var __defProp$4 = Object.defineProperty;
10
+ var __defProp$5 = Object.defineProperty;
11
11
  var __defProps$2 = Object.defineProperties;
12
12
  var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
13
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
14
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
15
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
16
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
17
- var __spreadValues$4 = (a, b) => {
13
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
14
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
15
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
16
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
17
+ var __spreadValues$5 = (a, b) => {
18
18
  for (var prop in b || (b = {}))
19
- if (__hasOwnProp$4.call(b, prop))
20
- __defNormalProp$4(a, prop, b[prop]);
21
- if (__getOwnPropSymbols$4)
22
- for (var prop of __getOwnPropSymbols$4(b)) {
23
- if (__propIsEnum$4.call(b, prop))
24
- __defNormalProp$4(a, prop, b[prop]);
19
+ if (__hasOwnProp$5.call(b, prop))
20
+ __defNormalProp$5(a, prop, b[prop]);
21
+ if (__getOwnPropSymbols$5)
22
+ for (var prop of __getOwnPropSymbols$5(b)) {
23
+ if (__propIsEnum$5.call(b, prop))
24
+ __defNormalProp$5(a, prop, b[prop]);
25
25
  }
26
26
  return a;
27
27
  };
@@ -34,7 +34,7 @@ function createChainable(keys, fn) {
34
34
  for (const key of keys) {
35
35
  Object.defineProperty(chain2, key, {
36
36
  get() {
37
- return create(__spreadProps$2(__spreadValues$4({}, obj), { [key]: true }));
37
+ return create(__spreadProps$2(__spreadValues$5({}, obj), { [key]: true }));
38
38
  }
39
39
  });
40
40
  }
@@ -454,19 +454,19 @@ const addSerializer = (plugin) => {
454
454
  };
455
455
  const getSerializers = () => PLUGINS;
456
456
 
457
- var __defProp$3 = Object.defineProperty;
458
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
459
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
460
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
461
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
462
- var __spreadValues$3 = (a, b) => {
457
+ var __defProp$4 = Object.defineProperty;
458
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
459
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
460
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
461
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
462
+ var __spreadValues$4 = (a, b) => {
463
463
  for (var prop in b || (b = {}))
464
- if (__hasOwnProp$3.call(b, prop))
465
- __defNormalProp$3(a, prop, b[prop]);
466
- if (__getOwnPropSymbols$3)
467
- for (var prop of __getOwnPropSymbols$3(b)) {
468
- if (__propIsEnum$3.call(b, prop))
469
- __defNormalProp$3(a, prop, b[prop]);
464
+ if (__hasOwnProp$4.call(b, prop))
465
+ __defNormalProp$4(a, prop, b[prop]);
466
+ if (__getOwnPropSymbols$4)
467
+ for (var prop of __getOwnPropSymbols$4(b)) {
468
+ if (__propIsEnum$4.call(b, prop))
469
+ __defNormalProp$4(a, prop, b[prop]);
470
470
  }
471
471
  return a;
472
472
  };
@@ -502,7 +502,7 @@ const removeExtraLineBreaks = (string) => string.length > 2 && string.startsWith
502
502
  const escapeRegex = true;
503
503
  const printFunctionName = false;
504
504
  function serialize(val, indent = 2, formatOverrides = {}) {
505
- return normalizeNewlines(format_1(val, __spreadValues$3({
505
+ return normalizeNewlines(format_1(val, __spreadValues$4({
506
506
  escapeRegex,
507
507
  indent,
508
508
  plugins: getSerializers(),
@@ -517,7 +517,7 @@ function printBacktickString(str) {
517
517
  }
518
518
  function ensureDirectoryExists(filePath) {
519
519
  try {
520
- fs.mkdirSync(index.join(index.dirname(filePath)), { recursive: true });
520
+ fs.mkdirSync(join(dirname(filePath)), { recursive: true });
521
521
  } catch {
522
522
  }
523
523
  }
@@ -565,7 +565,7 @@ function deepMergeArray(target = [], source = []) {
565
565
  }
566
566
  function deepMergeSnapshot(target, source) {
567
567
  if (isObject(target) && isObject(source)) {
568
- const mergedOutput = __spreadValues$3({}, target);
568
+ const mergedOutput = __spreadValues$4({}, target);
569
569
  Object.keys(source).forEach((key) => {
570
570
  if (isObject(source[key]) && !source[key].$$typeof) {
571
571
  if (!(key in target))
@@ -675,19 +675,19 @@ function stripSnapshotIndentation(inlineSnapshot) {
675
675
  return inlineSnapshot;
676
676
  }
677
677
 
678
- var __defProp$2 = Object.defineProperty;
679
- var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
680
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
681
- var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
682
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
683
- var __spreadValues$2 = (a, b) => {
678
+ var __defProp$3 = Object.defineProperty;
679
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
680
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
681
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
682
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
683
+ var __spreadValues$3 = (a, b) => {
684
684
  for (var prop in b || (b = {}))
685
- if (__hasOwnProp$2.call(b, prop))
686
- __defNormalProp$2(a, prop, b[prop]);
687
- if (__getOwnPropSymbols$2)
688
- for (var prop of __getOwnPropSymbols$2(b)) {
689
- if (__propIsEnum$2.call(b, prop))
690
- __defNormalProp$2(a, prop, b[prop]);
685
+ if (__hasOwnProp$3.call(b, prop))
686
+ __defNormalProp$3(a, prop, b[prop]);
687
+ if (__getOwnPropSymbols$3)
688
+ for (var prop of __getOwnPropSymbols$3(b)) {
689
+ if (__propIsEnum$3.call(b, prop))
690
+ __defNormalProp$3(a, prop, b[prop]);
691
691
  }
692
692
  return a;
693
693
  };
@@ -708,7 +708,7 @@ class SnapshotState {
708
708
  this.unmatched = 0;
709
709
  this._updateSnapshot = options.updateSnapshot;
710
710
  this.updated = 0;
711
- this._snapshotFormat = __spreadValues$2({
711
+ this._snapshotFormat = __spreadValues$3({
712
712
  printBasicPrototype: false
713
713
  }, options.snapshotFormat);
714
714
  }
@@ -736,7 +736,7 @@ class SnapshotState {
736
736
  throw new Error(`Vitest: Couldn't infer stack frame for inline snapshot.
737
737
  ${JSON.stringify(stacks)}`);
738
738
  }
739
- this._inlineSnapshots.push(__spreadValues$2({
739
+ this._inlineSnapshots.push(__spreadValues$3({
740
740
  snapshot: receivedSerialized
741
741
  }, stack));
742
742
  } else {
@@ -1058,15 +1058,15 @@ if (!Object.prototype.hasOwnProperty.call(global, MATCHERS_OBJECT)) {
1058
1058
  expectedAssertionsNumber: null,
1059
1059
  expectedAssertionsNumberErrorGen: null
1060
1060
  };
1061
- Object.defineProperty(global, MATCHERS_OBJECT, {
1061
+ Object.defineProperty(globalThis, MATCHERS_OBJECT, {
1062
1062
  value: {
1063
1063
  state: defaultState
1064
1064
  }
1065
1065
  });
1066
1066
  }
1067
- const getState = () => global[MATCHERS_OBJECT].state;
1067
+ const getState = () => globalThis[MATCHERS_OBJECT].state;
1068
1068
  const setState = (state) => {
1069
- Object.assign(global[MATCHERS_OBJECT].state, state);
1069
+ Object.assign(globalThis[MATCHERS_OBJECT].state, state);
1070
1070
  };
1071
1071
  const JestChaiExpect = (chai, utils) => {
1072
1072
  function def(name, fn) {
@@ -1448,21 +1448,21 @@ Number of calls: ${picocolors.exports.bold(spy.mock.calls.length)}
1448
1448
  utils.addMethod(chai.expect, "addSnapshotSerializer", addSerializer);
1449
1449
  };
1450
1450
 
1451
- var __defProp$1 = Object.defineProperty;
1451
+ var __defProp$2 = Object.defineProperty;
1452
1452
  var __defProps$1 = Object.defineProperties;
1453
1453
  var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
1454
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
1455
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
1456
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
1457
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1458
- var __spreadValues$1 = (a, b) => {
1454
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
1455
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
1456
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
1457
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1458
+ var __spreadValues$2 = (a, b) => {
1459
1459
  for (var prop in b || (b = {}))
1460
- if (__hasOwnProp$1.call(b, prop))
1461
- __defNormalProp$1(a, prop, b[prop]);
1462
- if (__getOwnPropSymbols$1)
1463
- for (var prop of __getOwnPropSymbols$1(b)) {
1464
- if (__propIsEnum$1.call(b, prop))
1465
- __defNormalProp$1(a, prop, b[prop]);
1460
+ if (__hasOwnProp$2.call(b, prop))
1461
+ __defNormalProp$2(a, prop, b[prop]);
1462
+ if (__getOwnPropSymbols$2)
1463
+ for (var prop of __getOwnPropSymbols$2(b)) {
1464
+ if (__propIsEnum$2.call(b, prop))
1465
+ __defNormalProp$2(a, prop, b[prop]);
1466
1466
  }
1467
1467
  return a;
1468
1468
  };
@@ -1474,7 +1474,7 @@ class AsymmetricMatcher {
1474
1474
  this.$$typeof = Symbol.for("jest.asymmetricMatcher");
1475
1475
  }
1476
1476
  getMatcherContext() {
1477
- return __spreadProps$1(__spreadValues$1({}, getState()), {
1477
+ return __spreadProps$1(__spreadValues$2({}, getState()), {
1478
1478
  equals,
1479
1479
  isNot: this.inverse,
1480
1480
  utils: matcherUtils
@@ -1648,21 +1648,21 @@ const JestAsymmetricMatchers = (chai, utils) => {
1648
1648
  };
1649
1649
  };
1650
1650
 
1651
- var __defProp = Object.defineProperty;
1651
+ var __defProp$1 = Object.defineProperty;
1652
1652
  var __defProps = Object.defineProperties;
1653
1653
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
1654
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
1655
- var __hasOwnProp = Object.prototype.hasOwnProperty;
1656
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
1657
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1658
- var __spreadValues = (a, b) => {
1654
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
1655
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
1656
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
1657
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1658
+ var __spreadValues$1 = (a, b) => {
1659
1659
  for (var prop in b || (b = {}))
1660
- if (__hasOwnProp.call(b, prop))
1661
- __defNormalProp(a, prop, b[prop]);
1662
- if (__getOwnPropSymbols)
1663
- for (var prop of __getOwnPropSymbols(b)) {
1664
- if (__propIsEnum.call(b, prop))
1665
- __defNormalProp(a, prop, b[prop]);
1660
+ if (__hasOwnProp$1.call(b, prop))
1661
+ __defNormalProp$1(a, prop, b[prop]);
1662
+ if (__getOwnPropSymbols$1)
1663
+ for (var prop of __getOwnPropSymbols$1(b)) {
1664
+ if (__propIsEnum$1.call(b, prop))
1665
+ __defNormalProp$1(a, prop, b[prop]);
1666
1666
  }
1667
1667
  return a;
1668
1668
  };
@@ -1672,11 +1672,11 @@ const getMatcherState = (assertion) => {
1672
1672
  const obj = assertion._obj;
1673
1673
  const isNot = util.flag(assertion, "negate");
1674
1674
  const promise = util.flag(assertion, "promise") || "";
1675
- const jestUtils = __spreadProps(__spreadValues({}, matcherUtils), {
1675
+ const jestUtils = __spreadProps(__spreadValues$1({}, matcherUtils), {
1676
1676
  iterableEquality,
1677
1677
  subsetEquality
1678
1678
  });
1679
- const matcherState = __spreadProps(__spreadValues({}, getState()), {
1679
+ const matcherState = __spreadProps(__spreadValues$1({}, getState()), {
1680
1680
  isNot,
1681
1681
  utils: jestUtils,
1682
1682
  promise,
@@ -4572,13 +4572,29 @@ function resetDate() {
4572
4572
  globalThis.Date = RealDate;
4573
4573
  }
4574
4574
 
4575
+ var __defProp = Object.defineProperty;
4576
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4577
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4578
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
4579
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4580
+ var __spreadValues = (a, b) => {
4581
+ for (var prop in b || (b = {}))
4582
+ if (__hasOwnProp.call(b, prop))
4583
+ __defNormalProp(a, prop, b[prop]);
4584
+ if (__getOwnPropSymbols)
4585
+ for (var prop of __getOwnPropSymbols(b)) {
4586
+ if (__propIsEnum.call(b, prop))
4587
+ __defNormalProp(a, prop, b[prop]);
4588
+ }
4589
+ return a;
4590
+ };
4575
4591
  class FakeTimers {
4576
4592
  constructor({
4577
4593
  global,
4578
- maxLoops = 1e4
4594
+ config
4579
4595
  }) {
4580
4596
  this._now = RealDate.now;
4581
- this._maxLoops = maxLoops;
4597
+ this._userConfig = config;
4582
4598
  this._fakingDate = false;
4583
4599
  this._fakingTime = false;
4584
4600
  this._fakeTimers = withGlobal_1(global);
@@ -4633,12 +4649,10 @@ class FakeTimers {
4633
4649
  }
4634
4650
  if (!this._fakingTime) {
4635
4651
  const toFake = Object.keys(this._fakeTimers.timers);
4636
- this._clock = this._fakeTimers.install({
4637
- loopLimit: this._maxLoops,
4652
+ this._clock = this._fakeTimers.install(__spreadValues({
4638
4653
  now: Date.now(),
4639
- toFake,
4640
- shouldClearNativeTimers: true
4641
- });
4654
+ toFake
4655
+ }, this._userConfig));
4642
4656
  this._fakingTime = true;
4643
4657
  }
4644
4658
  }
@@ -4665,6 +4679,9 @@ class FakeTimers {
4665
4679
  return this._clock.countTimers();
4666
4680
  return 0;
4667
4681
  }
4682
+ configure(config) {
4683
+ this._userConfig = config;
4684
+ }
4668
4685
  _checkFakeTimers() {
4669
4686
  if (!this._fakingTime) {
4670
4687
  throw new Error('Timers are not mocked. Try calling "vi.useFakeTimers()" first.');
@@ -4677,18 +4694,25 @@ class VitestUtils {
4677
4694
  constructor() {
4678
4695
  this.spyOn = spyOn;
4679
4696
  this.fn = fn;
4680
- this._timers = new FakeTimers({
4681
- global: globalThis,
4682
- maxLoops: 1e4
4683
- });
4684
4697
  this._mocker = typeof __vitest_mocker__ !== "undefined" ? __vitest_mocker__ : null;
4685
4698
  this._mockedDate = null;
4686
4699
  if (!this._mocker) {
4687
4700
  const errorMsg = 'Vitest was initialized with native Node instead of Vite Node.\n\nOne of the following is possible:\n- "vitest" is imported outside of your tests (in that case, use "vitest/node" or import.meta.vitest)\n- "vitest" is imported inside "globalSetup" (use "setupFiles", because "globalSetup" runs in a different context)\n- Your dependency inside "node_modules" imports "vitest" directly (in that case, inline that dependency, using "deps.inline" config)\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n';
4688
4701
  throw new Error(errorMsg);
4689
4702
  }
4703
+ const workerState = getWorkerState();
4704
+ this._timers = new FakeTimers({
4705
+ global: globalThis,
4706
+ config: workerState.config.fakeTimers
4707
+ });
4690
4708
  }
4691
- useFakeTimers() {
4709
+ useFakeTimers(config) {
4710
+ if (config) {
4711
+ this._timers.configure(config);
4712
+ } else {
4713
+ const workerState = getWorkerState();
4714
+ this._timers.configure(workerState.config.fakeTimers);
4715
+ }
4692
4716
  this._timers.useFakeTimers();
4693
4717
  return this;
4694
4718
  }
@@ -4778,9 +4802,11 @@ class VitestUtils {
4778
4802
  return this;
4779
4803
  }
4780
4804
  stubGlobal(name, value) {
4781
- globalThis[name] = value;
4782
- if (globalThis.window)
4805
+ if (globalThis.window) {
4783
4806
  globalThis.window[name] = value;
4807
+ } else {
4808
+ globalThis[name] = value;
4809
+ }
4784
4810
  return this;
4785
4811
  }
4786
4812
  resetModules() {
@@ -1,8 +1,8 @@
1
- import { n as normalizeRequestId, i as isNodeBuiltin, t as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.6b0ec89a.js';
1
+ import { n as normalizeRequestId, i as isNodeBuiltin, t as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.ebc9e052.js';
2
2
  import { normalizePath } from 'vite';
3
- import { b as getWorkerState, D as isWindows, E as mergeSlashes, h as dirname, f as basename, k as resolve, F as getType, G as getAllProperties, s as slash } from './chunk-utils-global.eb31f3da.js';
3
+ import { a as getWorkerState, C as isWindows, D as mergeSlashes, d as dirname, f as basename, h as resolve, E as getType, F as getAllProperties, s as slash } from './chunk-utils-global.7092f9ed.js';
4
4
  import { existsSync, readdirSync } from 'fs';
5
- import { d as distDir } from './chunk-constants.54c46a47.js';
5
+ import { d as distDir } from './chunk-constants.07c1f709.js';
6
6
 
7
7
  var __defProp = Object.defineProperty;
8
8
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
@@ -177,6 +177,7 @@ const _VitestMocker = class {
177
177
  await this.ensureSpy();
178
178
  await this.resolveMocks();
179
179
  const mock = this.getDependencyMock(dep);
180
+ const callstack = this.request.callstack;
180
181
  if (mock === null) {
181
182
  const cacheName = `${dep}__mock`;
182
183
  const cache = this.moduleCache.get(cacheName);
@@ -188,9 +189,14 @@ const _VitestMocker = class {
188
189
  this.emit("mocked", cacheName, { exports });
189
190
  return exports;
190
191
  }
191
- if (typeof mock === "function")
192
- return this.callFunctionMock(dep, mock);
193
- if (typeof mock === "string")
192
+ if (typeof mock === "function" && !callstack.includes(`mock:${dep}`)) {
193
+ callstack.push(`mock:${dep}`);
194
+ const result = await this.callFunctionMock(dep, mock);
195
+ const indexMock = callstack.indexOf(`mock:${dep}`);
196
+ callstack.splice(indexMock, 1);
197
+ return result;
198
+ }
199
+ if (typeof mock === "string" && !callstack.includes(mock))
194
200
  dep = mock;
195
201
  return this.request(dep);
196
202
  }
@@ -224,6 +230,7 @@ class VitestRunner extends ViteNodeRunner {
224
230
  }
225
231
  prepareContext(context) {
226
232
  const request = context.__vite_ssr_import__;
233
+ const resolveId = context.__vitest_resolve_id__;
227
234
  const mocker = this.mocker.withRequest(request);
228
235
  mocker.on("mocked", (dep, module) => {
229
236
  this.moduleCache.set(dep, module);
@@ -233,8 +240,8 @@ class VitestRunner extends ViteNodeRunner {
233
240
  Object.defineProperty(context.__vite_ssr_import_meta__, "vitest", { get: () => globalThis.__vitest_index__ });
234
241
  }
235
242
  return Object.assign(context, {
236
- __vite_ssr_import__: (dep) => mocker.requestWithMock(dep),
237
- __vite_ssr_dynamic_import__: (dep) => mocker.requestWithMock(dep),
243
+ __vite_ssr_import__: async (dep) => mocker.requestWithMock(await resolveId(dep)),
244
+ __vite_ssr_dynamic_import__: async (dep) => mocker.requestWithMock(await resolveId(dep)),
238
245
  __vitest_mocker__: mocker
239
246
  });
240
247
  }
@@ -1,4 +1,4 @@
1
- import { b as getWorkerState } from './chunk-utils-global.eb31f3da.js';
1
+ import { a as getWorkerState } from './chunk-utils-global.7092f9ed.js';
2
2
 
3
3
  const rpc = () => {
4
4
  return getWorkerState().rpc;
@@ -242,9 +242,9 @@ const _path = /*#__PURE__*/Object.freeze({
242
242
  parse: parse
243
243
  });
244
244
 
245
- const index = {
245
+ ({
246
246
  ..._path
247
- };
247
+ });
248
248
 
249
249
  function getWorkerState() {
250
250
  return globalThis.__vitest_worker__;
@@ -419,7 +419,7 @@ async function ensurePackageInstalled(dependency, promptInstall = !process.env.C
419
419
  message: picocolors.exports.reset(`Do you want to install ${picocolors.exports.green(dependency)}?`)
420
420
  });
421
421
  if (install) {
422
- await (await import('./chunk-install-pkg.73b84ae1.js')).installPackage(dependency, { dev: true });
422
+ await (await import('./chunk-install-pkg.fd8d1022.js')).installPackage(dependency, { dev: true });
423
423
  process.stderr.write(picocolors.exports.yellow(`
424
424
  Package ${dependency} installed, re-run the command to start.
425
425
  `));
@@ -457,4 +457,4 @@ function getCallLastIndex(code) {
457
457
  return null;
458
458
  }
459
459
 
460
- export { ensurePackageInstalled as A, stdout as B, extname as C, isWindows as D, mergeSlashes as E, getType as F, getAllProperties as G, clone as H, partitionSuiteChildren as I, hasTests as J, index as a, getWorkerState as b, getNames as c, assertTypes as d, notNullish as e, basename as f, getCallLastIndex as g, dirname as h, isObject as i, join as j, resolve as k, isAbsolute as l, relative as m, noop as n, getTests as o, picocolors as p, getFullName as q, resetModules as r, slash as s, toArray as t, hasFailed as u, hasFailedSnapshot as v, getSuites as w, normalize as x, deepMerge as y, toNamespacedPath as z };
460
+ export { stdout as A, extname as B, isWindows as C, mergeSlashes as D, getType as E, getAllProperties as F, clone as G, partitionSuiteChildren as H, hasTests as I, getWorkerState as a, getNames as b, assertTypes as c, dirname as d, notNullish as e, basename as f, getCallLastIndex as g, resolve as h, isObject as i, join as j, isAbsolute as k, relative as l, getTests as m, noop as n, getFullName as o, picocolors as p, hasFailed as q, resetModules as r, slash as s, toArray as t, hasFailedSnapshot as u, getSuites as v, normalize as w, deepMerge as x, toNamespacedPath as y, ensurePackageInstalled as z };
@@ -1,4 +1,4 @@
1
- import { s as slash, e as notNullish, p as picocolors } from './chunk-utils-global.eb31f3da.js';
1
+ import { s as slash, e as notNullish, p as picocolors } from './chunk-utils-global.7092f9ed.js';
2
2
 
3
3
  const setTimeout$1 = globalThis.setTimeout;
4
4
  const setInterval = globalThis.setInterval;