vitest 0.15.1 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,21 +1,21 @@
1
- import { g as globalApis } from './chunk-constants.7b9cfc82.mjs';
2
- import { i as index } from './vendor-entry.7ec02ea2.mjs';
1
+ import { g as globalApis } from './chunk-constants.511c6e9b.mjs';
2
+ import { i as index } from './vendor-entry.2edaf3e0.mjs';
3
3
  import 'url';
4
4
  import './chunk-utils-global.79a8b1cc.mjs';
5
5
  import 'tty';
6
6
  import 'local-pkg';
7
7
  import 'path';
8
8
  import 'fs';
9
- import './chunk-runtime-chain.ce7f4b92.mjs';
9
+ import './chunk-env-node.dc514f41.mjs';
10
+ import 'module';
11
+ import './chunk-runtime-chain.68f305d0.mjs';
10
12
  import 'chai';
11
13
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
12
14
  import './chunk-runtime-rpc.5e78af38.mjs';
13
- import './chunk-utils-source-map.2556cba8.mjs';
15
+ import './chunk-utils-source-map.f52527bc.mjs';
14
16
  import './chunk-integrations-spy.674b628e.mjs';
15
17
  import 'tinyspy';
16
18
  import 'util';
17
- import './chunk-defaults.dc6dc23d.mjs';
18
- import 'module';
19
19
 
20
20
  function registerApiGlobally() {
21
21
  globalApis.forEach((api) => {
@@ -3,29 +3,10 @@ import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
3
3
  import { r as rpc } from './chunk-runtime-rpc.5e78af38.mjs';
4
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, e as getFullName, f as safeSetTimeout, h as safeClearTimeout, n as noop, r as resetModules } from './chunk-utils-global.79a8b1cc.mjs';
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 } from './chunk-utils-source-map.2556cba8.mjs';
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 } from './chunk-utils-source-map.f52527bc.mjs';
7
7
  import { i as isMockFunction, s as spyOn, f as fn, a as spies } from './chunk-integrations-spy.674b628e.mjs';
8
8
  import require$$0, { format } from 'util';
9
9
 
10
- var __defProp$5 = Object.defineProperty;
11
- var __defProps$2 = Object.defineProperties;
12
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
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
- for (var prop in b || (b = {}))
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
- }
26
- return a;
27
- };
28
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
29
10
  function createChainable(keys, fn) {
30
11
  function create(obj) {
31
12
  const chain2 = function(...args) {
@@ -34,7 +15,7 @@ function createChainable(keys, fn) {
34
15
  for (const key of keys) {
35
16
  Object.defineProperty(chain2, key, {
36
17
  get() {
37
- return create(__spreadProps$2(__spreadValues$5({}, obj), { [key]: true }));
18
+ return create({ ...obj, [key]: true });
38
19
  }
39
20
  });
40
21
  }
@@ -466,22 +447,6 @@ const addSerializer = (plugin) => {
466
447
  };
467
448
  const getSerializers = () => PLUGINS;
468
449
 
469
- var __defProp$4 = Object.defineProperty;
470
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
471
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
472
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
473
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
474
- var __spreadValues$4 = (a, b) => {
475
- for (var prop in b || (b = {}))
476
- if (__hasOwnProp$4.call(b, prop))
477
- __defNormalProp$4(a, prop, b[prop]);
478
- if (__getOwnPropSymbols$4)
479
- for (var prop of __getOwnPropSymbols$4(b)) {
480
- if (__propIsEnum$4.call(b, prop))
481
- __defNormalProp$4(a, prop, b[prop]);
482
- }
483
- return a;
484
- };
485
450
  const SNAPSHOT_VERSION = "1";
486
451
  const writeSnapshotVersion = () => `// Vitest Snapshot v${SNAPSHOT_VERSION}`;
487
452
  const testNameToKey = (testName, count) => `${testName} ${count}`;
@@ -514,12 +479,13 @@ const removeExtraLineBreaks = (string) => string.length > 2 && string.startsWith
514
479
  const escapeRegex = true;
515
480
  const printFunctionName = false;
516
481
  function serialize(val, indent = 2, formatOverrides = {}) {
517
- return normalizeNewlines(format_1(val, __spreadValues$4({
482
+ return normalizeNewlines(format_1(val, {
518
483
  escapeRegex,
519
484
  indent,
520
485
  plugins: getSerializers(),
521
- printFunctionName
522
- }, formatOverrides)));
486
+ printFunctionName,
487
+ ...formatOverrides
488
+ }));
523
489
  }
524
490
  function escapeBacktickString(str) {
525
491
  return str.replace(/`|\\|\${/g, "\\$&");
@@ -581,7 +547,7 @@ function deepMergeArray(target = [], source = []) {
581
547
  }
582
548
  function deepMergeSnapshot(target, source) {
583
549
  if (isObject(target) && isObject(source)) {
584
- const mergedOutput = __spreadValues$4({}, target);
550
+ const mergedOutput = { ...target };
585
551
  Object.keys(source).forEach((key) => {
586
552
  if (isObject(source[key]) && !source[key].$$typeof) {
587
553
  if (!(key in target))
@@ -694,22 +660,6 @@ function stripSnapshotIndentation(inlineSnapshot) {
694
660
  return inlineSnapshot;
695
661
  }
696
662
 
697
- var __defProp$3 = Object.defineProperty;
698
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
699
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
700
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
701
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
702
- var __spreadValues$3 = (a, b) => {
703
- for (var prop in b || (b = {}))
704
- if (__hasOwnProp$3.call(b, prop))
705
- __defNormalProp$3(a, prop, b[prop]);
706
- if (__getOwnPropSymbols$3)
707
- for (var prop of __getOwnPropSymbols$3(b)) {
708
- if (__propIsEnum$3.call(b, prop))
709
- __defNormalProp$3(a, prop, b[prop]);
710
- }
711
- return a;
712
- };
713
663
  class SnapshotState {
714
664
  constructor(testFilePath, snapshotPath, options) {
715
665
  this.testFilePath = testFilePath;
@@ -727,9 +677,10 @@ class SnapshotState {
727
677
  this.unmatched = 0;
728
678
  this._updateSnapshot = options.updateSnapshot;
729
679
  this.updated = 0;
730
- this._snapshotFormat = __spreadValues$3({
731
- printBasicPrototype: false
732
- }, options.snapshotFormat);
680
+ this._snapshotFormat = {
681
+ printBasicPrototype: false,
682
+ ...options.snapshotFormat
683
+ };
733
684
  }
734
685
  markSnapshotsAsCheckedForTest(testName) {
735
686
  this._uncheckedKeys.forEach((uncheckedKey) => {
@@ -737,7 +688,7 @@ class SnapshotState {
737
688
  this._uncheckedKeys.delete(uncheckedKey);
738
689
  });
739
690
  }
740
- _getInlineSnapshotStack(stacks) {
691
+ _inferInlineSnapshotStack(stacks) {
741
692
  const promiseIndex = stacks.findIndex((i) => i.method.match(/__VITEST_(RESOLVES|REJECTS)__/));
742
693
  if (promiseIndex !== -1)
743
694
  return stacks[promiseIndex + 3];
@@ -750,14 +701,16 @@ class SnapshotState {
750
701
  const error = options.error || new Error("Unknown error");
751
702
  const stacks = parseStacktrace(error, true);
752
703
  stacks.forEach((i) => i.file = slash(i.file));
753
- const stack = this._getInlineSnapshotStack(stacks);
704
+ const stack = this._inferInlineSnapshotStack(stacks);
754
705
  if (!stack) {
755
706
  throw new Error(`Vitest: Couldn't infer stack frame for inline snapshot.
756
707
  ${JSON.stringify(stacks)}`);
757
708
  }
758
- this._inlineSnapshots.push(__spreadValues$3({
759
- snapshot: receivedSerialized
760
- }, stack));
709
+ stack.column--;
710
+ this._inlineSnapshots.push({
711
+ snapshot: receivedSerialized,
712
+ ...stack
713
+ });
761
714
  } else {
762
715
  this._snapshotData[key] = receivedSerialized;
763
716
  }
@@ -921,6 +874,10 @@ class SnapshotClient {
921
874
  clearTest() {
922
875
  this.test = void 0;
923
876
  }
877
+ skipTestSnapshots(test) {
878
+ var _a;
879
+ (_a = this.snapshotState) == null ? void 0 : _a.markSnapshotsAsCheckedForTest(test.name);
880
+ }
924
881
  assert(options) {
925
882
  const {
926
883
  test = this.test,
@@ -987,13 +944,21 @@ function getSnapshotClient() {
987
944
  _client = new SnapshotClient();
988
945
  return _client;
989
946
  }
990
- const getErrorString = (expected) => {
947
+ const getErrorMessage = (err) => {
948
+ if (err instanceof Error)
949
+ return err.message;
950
+ return err;
951
+ };
952
+ const getErrorString = (expected, promise) => {
953
+ if (typeof expected !== "function") {
954
+ if (!promise)
955
+ throw new Error(`expected must be a function, received ${typeof expected}`);
956
+ return getErrorMessage(expected);
957
+ }
991
958
  try {
992
959
  expected();
993
960
  } catch (e) {
994
- if (e instanceof Error)
995
- return e.message;
996
- return e;
961
+ return getErrorMessage(e);
997
962
  }
998
963
  throw new Error("snapshot function didn't threw");
999
964
  };
@@ -1043,9 +1008,10 @@ const SnapshotPlugin = (chai, utils) => {
1043
1008
  utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingSnapshot", function(message) {
1044
1009
  const expected = utils.flag(this, "object");
1045
1010
  const test = utils.flag(this, "vitest-test");
1011
+ const promise = utils.flag(this, "promise");
1046
1012
  const errorMessage = utils.flag(this, "message");
1047
1013
  getSnapshotClient().assert({
1048
- received: getErrorString(expected),
1014
+ received: getErrorString(expected, promise),
1049
1015
  test,
1050
1016
  message,
1051
1017
  errorMessage
@@ -1055,9 +1021,10 @@ const SnapshotPlugin = (chai, utils) => {
1055
1021
  const expected = utils.flag(this, "object");
1056
1022
  const error = utils.flag(this, "error");
1057
1023
  const test = utils.flag(this, "vitest-test");
1024
+ const promise = utils.flag(this, "promise");
1058
1025
  const errorMessage = utils.flag(this, "message");
1059
1026
  getSnapshotClient().assert({
1060
- received: getErrorString(expected),
1027
+ received: getErrorString(expected, promise),
1061
1028
  test,
1062
1029
  message,
1063
1030
  inlineSnapshot,
@@ -1495,25 +1462,6 @@ function toString(value) {
1495
1462
  }
1496
1463
  }
1497
1464
 
1498
- var __defProp$2 = Object.defineProperty;
1499
- var __defProps$1 = Object.defineProperties;
1500
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
1501
- var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
1502
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
1503
- var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
1504
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1505
- var __spreadValues$2 = (a, b) => {
1506
- for (var prop in b || (b = {}))
1507
- if (__hasOwnProp$2.call(b, prop))
1508
- __defNormalProp$2(a, prop, b[prop]);
1509
- if (__getOwnPropSymbols$2)
1510
- for (var prop of __getOwnPropSymbols$2(b)) {
1511
- if (__propIsEnum$2.call(b, prop))
1512
- __defNormalProp$2(a, prop, b[prop]);
1513
- }
1514
- return a;
1515
- };
1516
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
1517
1465
  class AsymmetricMatcher {
1518
1466
  constructor(sample, inverse = false) {
1519
1467
  this.sample = sample;
@@ -1521,11 +1469,12 @@ class AsymmetricMatcher {
1521
1469
  this.$$typeof = Symbol.for("jest.asymmetricMatcher");
1522
1470
  }
1523
1471
  getMatcherContext(expect) {
1524
- return __spreadProps$1(__spreadValues$2({}, getState(expect || globalThis[GLOBAL_EXPECT])), {
1472
+ return {
1473
+ ...getState(expect || globalThis[GLOBAL_EXPECT]),
1525
1474
  equals,
1526
1475
  isNot: this.inverse,
1527
1476
  utils: matcherUtils
1528
- });
1477
+ };
1529
1478
  }
1530
1479
  }
1531
1480
  class StringContaining extends AsymmetricMatcher {
@@ -1695,42 +1644,25 @@ const JestAsymmetricMatchers = (chai, utils) => {
1695
1644
  };
1696
1645
  };
1697
1646
 
1698
- var __defProp$1 = Object.defineProperty;
1699
- var __defProps = Object.defineProperties;
1700
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
1701
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
1702
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
1703
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
1704
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1705
- var __spreadValues$1 = (a, b) => {
1706
- for (var prop in b || (b = {}))
1707
- if (__hasOwnProp$1.call(b, prop))
1708
- __defNormalProp$1(a, prop, b[prop]);
1709
- if (__getOwnPropSymbols$1)
1710
- for (var prop of __getOwnPropSymbols$1(b)) {
1711
- if (__propIsEnum$1.call(b, prop))
1712
- __defNormalProp$1(a, prop, b[prop]);
1713
- }
1714
- return a;
1715
- };
1716
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1717
1647
  const isAsyncFunction = (fn) => typeof fn === "function" && fn[Symbol.toStringTag] === "AsyncFunction";
1718
1648
  const getMatcherState = (assertion, expect) => {
1719
1649
  const obj = assertion._obj;
1720
1650
  const isNot = util.flag(assertion, "negate");
1721
1651
  const promise = util.flag(assertion, "promise") || "";
1722
- const jestUtils = __spreadProps(__spreadValues$1({}, matcherUtils), {
1652
+ const jestUtils = {
1653
+ ...matcherUtils,
1723
1654
  iterableEquality,
1724
1655
  subsetEquality
1725
- });
1726
- const matcherState = __spreadProps(__spreadValues$1({}, getState(expect)), {
1656
+ };
1657
+ const matcherState = {
1658
+ ...getState(expect),
1727
1659
  isNot,
1728
1660
  utils: jestUtils,
1729
1661
  promise,
1730
1662
  equals,
1731
1663
  suppressedErrors: [],
1732
1664
  snapshotState: getSnapshotClient().snapshotState
1733
- });
1665
+ };
1734
1666
  return {
1735
1667
  state: matcherState,
1736
1668
  isNot,
@@ -1854,7 +1786,9 @@ function createExpect(test) {
1854
1786
  }
1855
1787
  const globalExpect = createExpect();
1856
1788
  Object.defineProperty(globalThis, GLOBAL_EXPECT, {
1857
- value: globalExpect
1789
+ value: globalExpect,
1790
+ writable: true,
1791
+ configurable: true
1858
1792
  });
1859
1793
 
1860
1794
  const collectorContext = {
@@ -4663,22 +4597,6 @@ function resetDate() {
4663
4597
  globalThis.Date = RealDate;
4664
4598
  }
4665
4599
 
4666
- var __defProp = Object.defineProperty;
4667
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4668
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4669
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
4670
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4671
- var __spreadValues = (a, b) => {
4672
- for (var prop in b || (b = {}))
4673
- if (__hasOwnProp.call(b, prop))
4674
- __defNormalProp(a, prop, b[prop]);
4675
- if (__getOwnPropSymbols)
4676
- for (var prop of __getOwnPropSymbols(b)) {
4677
- if (__propIsEnum.call(b, prop))
4678
- __defNormalProp(a, prop, b[prop]);
4679
- }
4680
- return a;
4681
- };
4682
4600
  class FakeTimers {
4683
4601
  constructor({
4684
4602
  global,
@@ -4740,10 +4658,11 @@ class FakeTimers {
4740
4658
  }
4741
4659
  if (!this._fakingTime) {
4742
4660
  const toFake = Object.keys(this._fakeTimers.timers);
4743
- this._clock = this._fakeTimers.install(__spreadValues({
4661
+ this._clock = this._fakeTimers.install({
4744
4662
  now: Date.now(),
4745
- toFake
4746
- }, this._userConfig));
4663
+ toFake,
4664
+ ...this._userConfig
4665
+ });
4747
4666
  this._fakingTime = true;
4748
4667
  }
4749
4668
  }
@@ -1,43 +1,23 @@
1
- import { n as normalizeRequestId, i as isNodeBuiltin, b as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.c0a0e1b3.mjs';
1
+ import { n as normalizeRequestId, i as isNodeBuiltin, b as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.4b58ae05.mjs';
2
2
  import { normalizePath } from 'vite';
3
3
  import { a as getWorkerState, J as isWindows, K as mergeSlashes, d as dirname, m as resolve, l as basename, L as getType, M as getAllProperties, s as slash } from './chunk-utils-global.79a8b1cc.mjs';
4
4
  import { existsSync, readdirSync } from 'fs';
5
- import { d as distDir } from './chunk-constants.7b9cfc82.mjs';
5
+ import { d as distDir } from './chunk-constants.511c6e9b.mjs';
6
6
 
7
- var __defProp = Object.defineProperty;
8
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
- var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
7
  const _VitestMocker = class {
24
8
  constructor(options, moduleCache, request) {
25
9
  this.options = options;
26
10
  this.moduleCache = moduleCache;
27
- this.callbacks = {};
28
- this.root = this.options.root;
29
11
  this.request = request;
30
12
  }
31
- get mockMap() {
32
- return this.options.mockMap;
13
+ get root() {
14
+ return this.options.root;
33
15
  }
34
- on(event, cb) {
35
- var _a;
36
- (_a = this.callbacks)[event] ?? (_a[event] = []);
37
- this.callbacks[event].push(cb);
16
+ get base() {
17
+ return this.options.base;
38
18
  }
39
- emit(event, ...args) {
40
- (this.callbacks[event] ?? []).forEach((fn) => fn(...args));
19
+ get mockMap() {
20
+ return this.options.mockMap;
41
21
  }
42
22
  getSuiteFilepath() {
43
23
  return getWorkerState().filepath || "global";
@@ -46,7 +26,10 @@ const _VitestMocker = class {
46
26
  const suite = this.getSuiteFilepath();
47
27
  const suiteMocks = this.mockMap.get(suite);
48
28
  const globalMocks = this.mockMap.get("global");
49
- return __spreadValues(__spreadValues({}, globalMocks), suiteMocks);
29
+ return {
30
+ ...globalMocks,
31
+ ...suiteMocks
32
+ };
50
33
  }
51
34
  async resolvePath(id, importer) {
52
35
  const path = await this.options.resolveId(id, importer);
@@ -73,17 +56,14 @@ const _VitestMocker = class {
73
56
  if (cached)
74
57
  return cached;
75
58
  const exports = await mock();
76
- this.emit("mocked", cacheName, { exports });
59
+ this.moduleCache.set(cacheName, { exports });
77
60
  return exports;
78
61
  }
79
62
  getDependencyMock(dep) {
80
- return this.getMocks()[this.resolveDependency(dep)];
81
- }
82
- resolveDependency(dep) {
83
- return normalizeRequestId(dep.replace(this.root, "")).replace(/^\/@fs\//, isWindows ? "" : "/");
63
+ return this.getMocks()[this.normalizePath(dep)];
84
64
  }
85
65
  normalizePath(path) {
86
- return normalizeRequestId(path.replace(this.root, "")).replace(/^\/@fs\//, isWindows ? "" : "/");
66
+ return normalizeRequestId(path.replace(this.root, ""), this.base).replace(/^\/@fs\//, isWindows ? "" : "/");
87
67
  }
88
68
  getFsPath(path, external) {
89
69
  if (external)
@@ -135,17 +115,17 @@ const _VitestMocker = class {
135
115
  }
136
116
  unmockPath(path) {
137
117
  const suitefile = this.getSuiteFilepath();
138
- const fsPath = this.normalizePath(path);
118
+ const id = this.normalizePath(path);
139
119
  const mock = this.mockMap.get(suitefile);
140
- if (mock == null ? void 0 : mock[fsPath])
141
- delete mock[fsPath];
120
+ if (mock == null ? void 0 : mock[id])
121
+ delete mock[id];
142
122
  }
143
123
  mockPath(path, external, factory) {
144
124
  const suitefile = this.getSuiteFilepath();
145
- const fsPath = this.normalizePath(path);
146
- if (!this.mockMap.has(suitefile))
147
- this.mockMap.set(suitefile, {});
148
- this.mockMap.get(suitefile)[fsPath] = factory || this.resolveMockPath(path, external);
125
+ const id = this.normalizePath(path);
126
+ const mocks = this.mockMap.get(suitefile) || {};
127
+ mocks[id] = factory || this.resolveMockPath(path, external);
128
+ this.mockMap.set(suitefile, mocks);
149
129
  }
150
130
  async importActual(id, importer) {
151
131
  const { path, external } = await this.resolvePath(id, importer);
@@ -175,8 +155,10 @@ const _VitestMocker = class {
175
155
  }
176
156
  async requestWithMock(dep) {
177
157
  var _a;
178
- await this.ensureSpy();
179
- await this.resolveMocks();
158
+ await Promise.all([
159
+ this.ensureSpy(),
160
+ this.resolveMocks()
161
+ ]);
180
162
  const mock = this.getDependencyMock(dep);
181
163
  const callstack = this.request.callstack;
182
164
  if (mock === null) {
@@ -187,7 +169,7 @@ const _VitestMocker = class {
187
169
  const cacheKey = toFilePath(dep, this.root);
188
170
  const mod = ((_a = this.moduleCache.get(cacheKey)) == null ? void 0 : _a.exports) || await this.request(dep);
189
171
  const exports = this.mockValue(mod);
190
- this.emit("mocked", cacheName, { exports });
172
+ this.moduleCache.set(cacheName, { exports });
191
173
  return exports;
192
174
  }
193
175
  if (typeof mock === "function" && !callstack.includes(`mock:${dep}`)) {
@@ -207,9 +189,6 @@ const _VitestMocker = class {
207
189
  queueUnmock(id, importer) {
208
190
  _VitestMocker.pendingIds.push({ type: "unmock", id, importer });
209
191
  }
210
- withRequest(request) {
211
- return new _VitestMocker(this.options, this.moduleCache, request);
212
- }
213
192
  };
214
193
  let VitestMocker = _VitestMocker;
215
194
  VitestMocker.pendingIds = [];
@@ -226,16 +205,11 @@ class VitestRunner extends ViteNodeRunner {
226
205
  constructor(options) {
227
206
  super(options);
228
207
  this.options = options;
229
- this.entries = /* @__PURE__ */ new Set();
230
- this.mocker = new VitestMocker(options, this.moduleCache);
231
208
  }
232
209
  prepareContext(context) {
233
210
  const request = context.__vite_ssr_import__;
234
211
  const resolveId = context.__vitest_resolve_id__;
235
- const mocker = this.mocker.withRequest(request);
236
- mocker.on("mocked", (dep, module) => {
237
- this.moduleCache.set(dep, module);
238
- });
212
+ const mocker = new VitestMocker(this.options, this.moduleCache, request);
239
213
  const workerState = getWorkerState();
240
214
  if (workerState.filepath && normalizePath(workerState.filepath) === normalizePath(context.__filename)) {
241
215
  Object.defineProperty(context.__vite_ssr_import_meta__, "vitest", { get: () => globalThis.__vitest_index__ });
@@ -7328,22 +7328,6 @@ function unifiedDiff(actual, expected, options = {}) {
7328
7328
  return formatted.map((i) => indent + i).join("\n");
7329
7329
  }
7330
7330
 
7331
- var __defProp = Object.defineProperty;
7332
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7333
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7334
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7335
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7336
- var __spreadValues = (a, b) => {
7337
- for (var prop in b || (b = {}))
7338
- if (__hasOwnProp.call(b, prop))
7339
- __defNormalProp(a, prop, b[prop]);
7340
- if (__getOwnPropSymbols)
7341
- for (var prop of __getOwnPropSymbols(b)) {
7342
- if (__propIsEnum.call(b, prop))
7343
- __defNormalProp(a, prop, b[prop]);
7344
- }
7345
- return a;
7346
- };
7347
7331
  const EXPECTED_COLOR = picocolors.exports.green;
7348
7332
  const RECEIVED_COLOR = picocolors.exports.red;
7349
7333
  const INVERTED_COLOR = picocolors.exports.inverse;
@@ -7416,16 +7400,18 @@ function stringify(object, maxDepth = 10, options) {
7416
7400
  const MAX_LENGTH = 1e4;
7417
7401
  let result;
7418
7402
  try {
7419
- result = format_1(object, __spreadValues({
7403
+ result = format_1(object, {
7420
7404
  maxDepth,
7421
- plugins: PLUGINS
7422
- }, options));
7405
+ plugins: PLUGINS,
7406
+ ...options
7407
+ });
7423
7408
  } catch {
7424
- result = format_1(object, __spreadValues({
7409
+ result = format_1(object, {
7425
7410
  callToJSON: false,
7426
7411
  maxDepth,
7427
- plugins: PLUGINS
7428
- }, options));
7412
+ plugins: PLUGINS,
7413
+ ...options
7414
+ });
7429
7415
  }
7430
7416
  return result.length >= MAX_LENGTH && maxDepth > 1 ? stringify(object, Math.floor(maxDepth / 2)) : result;
7431
7417
  }