vitest 0.16.0 → 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.efeeaa5c.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.7103058b.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) => {
@@ -756,9 +707,10 @@ class SnapshotState {
756
707
  ${JSON.stringify(stacks)}`);
757
708
  }
758
709
  stack.column--;
759
- this._inlineSnapshots.push(__spreadValues$3({
760
- snapshot: receivedSerialized
761
- }, stack));
710
+ this._inlineSnapshots.push({
711
+ snapshot: receivedSerialized,
712
+ ...stack
713
+ });
762
714
  } else {
763
715
  this._snapshotData[key] = receivedSerialized;
764
716
  }
@@ -992,13 +944,21 @@ function getSnapshotClient() {
992
944
  _client = new SnapshotClient();
993
945
  return _client;
994
946
  }
995
- 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
+ }
996
958
  try {
997
959
  expected();
998
960
  } catch (e) {
999
- if (e instanceof Error)
1000
- return e.message;
1001
- return e;
961
+ return getErrorMessage(e);
1002
962
  }
1003
963
  throw new Error("snapshot function didn't threw");
1004
964
  };
@@ -1048,9 +1008,10 @@ const SnapshotPlugin = (chai, utils) => {
1048
1008
  utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingSnapshot", function(message) {
1049
1009
  const expected = utils.flag(this, "object");
1050
1010
  const test = utils.flag(this, "vitest-test");
1011
+ const promise = utils.flag(this, "promise");
1051
1012
  const errorMessage = utils.flag(this, "message");
1052
1013
  getSnapshotClient().assert({
1053
- received: getErrorString(expected),
1014
+ received: getErrorString(expected, promise),
1054
1015
  test,
1055
1016
  message,
1056
1017
  errorMessage
@@ -1060,9 +1021,10 @@ const SnapshotPlugin = (chai, utils) => {
1060
1021
  const expected = utils.flag(this, "object");
1061
1022
  const error = utils.flag(this, "error");
1062
1023
  const test = utils.flag(this, "vitest-test");
1024
+ const promise = utils.flag(this, "promise");
1063
1025
  const errorMessage = utils.flag(this, "message");
1064
1026
  getSnapshotClient().assert({
1065
- received: getErrorString(expected),
1027
+ received: getErrorString(expected, promise),
1066
1028
  test,
1067
1029
  message,
1068
1030
  inlineSnapshot,
@@ -1500,25 +1462,6 @@ function toString(value) {
1500
1462
  }
1501
1463
  }
1502
1464
 
1503
- var __defProp$2 = Object.defineProperty;
1504
- var __defProps$1 = Object.defineProperties;
1505
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
1506
- var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
1507
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
1508
- var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
1509
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1510
- var __spreadValues$2 = (a, b) => {
1511
- for (var prop in b || (b = {}))
1512
- if (__hasOwnProp$2.call(b, prop))
1513
- __defNormalProp$2(a, prop, b[prop]);
1514
- if (__getOwnPropSymbols$2)
1515
- for (var prop of __getOwnPropSymbols$2(b)) {
1516
- if (__propIsEnum$2.call(b, prop))
1517
- __defNormalProp$2(a, prop, b[prop]);
1518
- }
1519
- return a;
1520
- };
1521
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
1522
1465
  class AsymmetricMatcher {
1523
1466
  constructor(sample, inverse = false) {
1524
1467
  this.sample = sample;
@@ -1526,11 +1469,12 @@ class AsymmetricMatcher {
1526
1469
  this.$$typeof = Symbol.for("jest.asymmetricMatcher");
1527
1470
  }
1528
1471
  getMatcherContext(expect) {
1529
- return __spreadProps$1(__spreadValues$2({}, getState(expect || globalThis[GLOBAL_EXPECT])), {
1472
+ return {
1473
+ ...getState(expect || globalThis[GLOBAL_EXPECT]),
1530
1474
  equals,
1531
1475
  isNot: this.inverse,
1532
1476
  utils: matcherUtils
1533
- });
1477
+ };
1534
1478
  }
1535
1479
  }
1536
1480
  class StringContaining extends AsymmetricMatcher {
@@ -1700,42 +1644,25 @@ const JestAsymmetricMatchers = (chai, utils) => {
1700
1644
  };
1701
1645
  };
1702
1646
 
1703
- var __defProp$1 = Object.defineProperty;
1704
- var __defProps = Object.defineProperties;
1705
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
1706
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
1707
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
1708
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
1709
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1710
- var __spreadValues$1 = (a, b) => {
1711
- for (var prop in b || (b = {}))
1712
- if (__hasOwnProp$1.call(b, prop))
1713
- __defNormalProp$1(a, prop, b[prop]);
1714
- if (__getOwnPropSymbols$1)
1715
- for (var prop of __getOwnPropSymbols$1(b)) {
1716
- if (__propIsEnum$1.call(b, prop))
1717
- __defNormalProp$1(a, prop, b[prop]);
1718
- }
1719
- return a;
1720
- };
1721
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1722
1647
  const isAsyncFunction = (fn) => typeof fn === "function" && fn[Symbol.toStringTag] === "AsyncFunction";
1723
1648
  const getMatcherState = (assertion, expect) => {
1724
1649
  const obj = assertion._obj;
1725
1650
  const isNot = util.flag(assertion, "negate");
1726
1651
  const promise = util.flag(assertion, "promise") || "";
1727
- const jestUtils = __spreadProps(__spreadValues$1({}, matcherUtils), {
1652
+ const jestUtils = {
1653
+ ...matcherUtils,
1728
1654
  iterableEquality,
1729
1655
  subsetEquality
1730
- });
1731
- const matcherState = __spreadProps(__spreadValues$1({}, getState(expect)), {
1656
+ };
1657
+ const matcherState = {
1658
+ ...getState(expect),
1732
1659
  isNot,
1733
1660
  utils: jestUtils,
1734
1661
  promise,
1735
1662
  equals,
1736
1663
  suppressedErrors: [],
1737
1664
  snapshotState: getSnapshotClient().snapshotState
1738
- });
1665
+ };
1739
1666
  return {
1740
1667
  state: matcherState,
1741
1668
  isNot,
@@ -4670,22 +4597,6 @@ function resetDate() {
4670
4597
  globalThis.Date = RealDate;
4671
4598
  }
4672
4599
 
4673
- var __defProp = Object.defineProperty;
4674
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4675
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4676
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
4677
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4678
- var __spreadValues = (a, b) => {
4679
- for (var prop in b || (b = {}))
4680
- if (__hasOwnProp.call(b, prop))
4681
- __defNormalProp(a, prop, b[prop]);
4682
- if (__getOwnPropSymbols)
4683
- for (var prop of __getOwnPropSymbols(b)) {
4684
- if (__propIsEnum.call(b, prop))
4685
- __defNormalProp(a, prop, b[prop]);
4686
- }
4687
- return a;
4688
- };
4689
4600
  class FakeTimers {
4690
4601
  constructor({
4691
4602
  global,
@@ -4747,10 +4658,11 @@ class FakeTimers {
4747
4658
  }
4748
4659
  if (!this._fakingTime) {
4749
4660
  const toFake = Object.keys(this._fakeTimers.timers);
4750
- this._clock = this._fakeTimers.install(__spreadValues({
4661
+ this._clock = this._fakeTimers.install({
4751
4662
  now: Date.now(),
4752
- toFake
4753
- }, this._userConfig));
4663
+ toFake,
4664
+ ...this._userConfig
4665
+ });
4754
4666
  this._fakingTime = true;
4755
4667
  }
4756
4668
  }
@@ -1,43 +1,23 @@
1
- import { n as normalizeRequestId, i as isNodeBuiltin, b as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.7450fc0c.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
  }