@noma.to/qwik-mock 1.0.2 → 1.1.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 (53) hide show
  1. package/lib/lib/qwik-mock.cjs +24 -6
  2. package/lib/lib/qwik-mock.mjs +24 -6
  3. package/lib-types/index.d.ts +2 -1
  4. package/lib-types/lib/qwik-mock.d.ts +21 -19
  5. package/package.json +7 -6
  6. package/lib/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.cjs +0 -83
  7. package/lib/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +0 -83
  8. package/lib/node_modules/.pnpm/@vitest_expect@4.0.18/node_modules/@vitest/expect/dist/index.cjs +0 -1785
  9. package/lib/node_modules/.pnpm/@vitest_expect@4.0.18/node_modules/@vitest/expect/dist/index.mjs +0 -1785
  10. package/lib/node_modules/.pnpm/@vitest_pretty-format@4.0.18/node_modules/@vitest/pretty-format/dist/index.cjs +0 -964
  11. package/lib/node_modules/.pnpm/@vitest_pretty-format@4.0.18/node_modules/@vitest/pretty-format/dist/index.mjs +0 -964
  12. package/lib/node_modules/.pnpm/@vitest_runner@4.0.18/node_modules/@vitest/runner/dist/chunk-tasks.cjs +0 -60
  13. package/lib/node_modules/.pnpm/@vitest_runner@4.0.18/node_modules/@vitest/runner/dist/chunk-tasks.mjs +0 -60
  14. package/lib/node_modules/.pnpm/@vitest_runner@4.0.18/node_modules/@vitest/runner/dist/index.cjs +0 -1102
  15. package/lib/node_modules/.pnpm/@vitest_runner@4.0.18/node_modules/@vitest/runner/dist/index.mjs +0 -1102
  16. package/lib/node_modules/.pnpm/@vitest_snapshot@4.0.18/node_modules/@vitest/snapshot/dist/index.cjs +0 -1289
  17. package/lib/node_modules/.pnpm/@vitest_snapshot@4.0.18/node_modules/@vitest/snapshot/dist/index.mjs +0 -1289
  18. package/lib/node_modules/.pnpm/@vitest_spy@4.0.18/node_modules/@vitest/spy/dist/index.cjs +0 -422
  19. package/lib/node_modules/.pnpm/@vitest_spy@4.0.18/node_modules/@vitest/spy/dist/index.mjs +0 -422
  20. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.cjs +0 -6
  21. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.mjs +0 -6
  22. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.cjs +0 -98
  23. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs +0 -98
  24. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/diff.cjs +0 -1626
  25. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/diff.mjs +0 -1626
  26. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/display.cjs +0 -690
  27. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/display.mjs +0 -690
  28. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/error.cjs +0 -39
  29. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/error.mjs +0 -39
  30. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/helpers.cjs +0 -151
  31. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/helpers.mjs +0 -151
  32. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/serialize.cjs +0 -114
  33. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/serialize.mjs +0 -114
  34. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/source-map.cjs +0 -125
  35. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/source-map.mjs +0 -125
  36. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/timers.cjs +0 -22
  37. package/lib/node_modules/.pnpm/@vitest_utils@4.0.18/node_modules/@vitest/utils/dist/timers.mjs +0 -22
  38. package/lib/node_modules/.pnpm/chai@6.2.2/node_modules/chai/index.cjs +0 -4056
  39. package/lib/node_modules/.pnpm/chai@6.2.2/node_modules/chai/index.mjs +0 -4056
  40. package/lib/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.cjs +0 -994
  41. package/lib/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs +0 -994
  42. package/lib/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.cjs +0 -101
  43. package/lib/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +0 -101
  44. package/lib/node_modules/.pnpm/tinyrainbow@3.0.3/node_modules/tinyrainbow/dist/index.cjs +0 -84
  45. package/lib/node_modules/.pnpm/tinyrainbow@3.0.3/node_modules/tinyrainbow/dist/index.mjs +0 -84
  46. package/lib/node_modules/.pnpm/vitest@4.0.18_@types_node@25.1.0_@vitest_ui@4.0.18_happy-dom@20.0.11_jiti@2.4.2_jsdom@26.1.0__pd2l5poczrcnqygjcqiguyknnm/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.cjs +0 -4
  47. package/lib/node_modules/.pnpm/vitest@4.0.18_@types_node@25.1.0_@vitest_ui@4.0.18_happy-dom@20.0.11_jiti@2.4.2_jsdom@26.1.0__pd2l5poczrcnqygjcqiguyknnm/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs +0 -4
  48. package/lib/node_modules/.pnpm/vitest@4.0.18_@types_node@25.1.0_@vitest_ui@4.0.18_happy-dom@20.0.11_jiti@2.4.2_jsdom@26.1.0__pd2l5poczrcnqygjcqiguyknnm/node_modules/vitest/dist/chunks/date.Bq6ZW5rf.cjs +0 -51
  49. package/lib/node_modules/.pnpm/vitest@4.0.18_@types_node@25.1.0_@vitest_ui@4.0.18_happy-dom@20.0.11_jiti@2.4.2_jsdom@26.1.0__pd2l5poczrcnqygjcqiguyknnm/node_modules/vitest/dist/chunks/date.Bq6ZW5rf.mjs +0 -51
  50. package/lib/node_modules/.pnpm/vitest@4.0.18_@types_node@25.1.0_@vitest_ui@4.0.18_happy-dom@20.0.11_jiti@2.4.2_jsdom@26.1.0__pd2l5poczrcnqygjcqiguyknnm/node_modules/vitest/dist/chunks/utils.DvEY5TfP.cjs +0 -45
  51. package/lib/node_modules/.pnpm/vitest@4.0.18_@types_node@25.1.0_@vitest_ui@4.0.18_happy-dom@20.0.11_jiti@2.4.2_jsdom@26.1.0__pd2l5poczrcnqygjcqiguyknnm/node_modules/vitest/dist/chunks/utils.DvEY5TfP.mjs +0 -45
  52. package/lib/node_modules/.pnpm/vitest@4.0.18_@types_node@25.1.0_@vitest_ui@4.0.18_happy-dom@20.0.11_jiti@2.4.2_jsdom@26.1.0__pd2l5poczrcnqygjcqiguyknnm/node_modules/vitest/dist/chunks/vi.2VT5v0um.cjs +0 -2609
  53. package/lib/node_modules/.pnpm/vitest@4.0.18_@types_node@25.1.0_@vitest_ui@4.0.18_happy-dom@20.0.11_jiti@2.4.2_jsdom@26.1.0__pd2l5poczrcnqygjcqiguyknnm/node_modules/vitest/dist/chunks/vi.2VT5v0um.mjs +0 -2609
@@ -1,422 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- function isMockFunction(fn2) {
4
- return typeof fn2 === "function" && "_isMockFunction" in fn2 && fn2._isMockFunction === true;
5
- }
6
- const MOCK_RESTORE = /* @__PURE__ */ new Set();
7
- const REGISTERED_MOCKS = /* @__PURE__ */ new Set();
8
- const MOCK_CONFIGS = /* @__PURE__ */ new WeakMap();
9
- function createMockInstance(options = {}) {
10
- var _ref;
11
- const { originalImplementation, restore, mockImplementation, resetToMockImplementation, resetToMockName } = options;
12
- if (restore) {
13
- MOCK_RESTORE.add(restore);
14
- }
15
- const config = getDefaultConfig(originalImplementation);
16
- const state = getDefaultState();
17
- const mock = createMock({
18
- config,
19
- state,
20
- ...options
21
- });
22
- const mockLength = ((_ref = mockImplementation || originalImplementation) === null || _ref === void 0 ? void 0 : _ref.length) ?? 0;
23
- Object.defineProperty(mock, "length", {
24
- writable: true,
25
- enumerable: false,
26
- value: mockLength,
27
- configurable: true
28
- });
29
- if (resetToMockName) {
30
- config.mockName = mock.name || "vi.fn()";
31
- }
32
- MOCK_CONFIGS.set(mock, config);
33
- REGISTERED_MOCKS.add(mock);
34
- mock._isMockFunction = true;
35
- mock.getMockImplementation = () => {
36
- return config.onceMockImplementations[0] || config.mockImplementation;
37
- };
38
- Object.defineProperty(mock, "mock", {
39
- configurable: false,
40
- enumerable: true,
41
- writable: false,
42
- value: state
43
- });
44
- mock.mockImplementation = function mockImplementation2(implementation) {
45
- config.mockImplementation = implementation;
46
- return mock;
47
- };
48
- mock.mockImplementationOnce = function mockImplementationOnce(implementation) {
49
- config.onceMockImplementations.push(implementation);
50
- return mock;
51
- };
52
- mock.withImplementation = function withImplementation(implementation, callback) {
53
- const previousImplementation = config.mockImplementation;
54
- const previousOnceImplementations = config.onceMockImplementations;
55
- const reset = () => {
56
- config.mockImplementation = previousImplementation;
57
- config.onceMockImplementations = previousOnceImplementations;
58
- };
59
- config.mockImplementation = implementation;
60
- config.onceMockImplementations = [];
61
- const returnValue = callback();
62
- if (typeof returnValue === "object" && typeof (returnValue === null || returnValue === void 0 ? void 0 : returnValue.then) === "function") {
63
- return returnValue.then(() => {
64
- reset();
65
- return mock;
66
- });
67
- } else {
68
- reset();
69
- }
70
- return mock;
71
- };
72
- mock.mockReturnThis = function mockReturnThis() {
73
- return mock.mockImplementation(function() {
74
- return this;
75
- });
76
- };
77
- mock.mockReturnValue = function mockReturnValue(value) {
78
- return mock.mockImplementation(() => value);
79
- };
80
- mock.mockReturnValueOnce = function mockReturnValueOnce(value) {
81
- return mock.mockImplementationOnce(() => value);
82
- };
83
- mock.mockResolvedValue = function mockResolvedValue(value) {
84
- return mock.mockImplementation(() => Promise.resolve(value));
85
- };
86
- mock.mockResolvedValueOnce = function mockResolvedValueOnce(value) {
87
- return mock.mockImplementationOnce(() => Promise.resolve(value));
88
- };
89
- mock.mockRejectedValue = function mockRejectedValue(value) {
90
- return mock.mockImplementation(() => Promise.reject(value));
91
- };
92
- mock.mockRejectedValueOnce = function mockRejectedValueOnce(value) {
93
- return mock.mockImplementationOnce(() => Promise.reject(value));
94
- };
95
- mock.mockClear = function mockClear() {
96
- state.calls = [];
97
- state.contexts = [];
98
- state.instances = [];
99
- state.invocationCallOrder = [];
100
- state.results = [];
101
- state.settledResults = [];
102
- return mock;
103
- };
104
- mock.mockReset = function mockReset() {
105
- mock.mockClear();
106
- config.mockImplementation = resetToMockImplementation ? mockImplementation : void 0;
107
- config.mockName = resetToMockName ? mock.name || "vi.fn()" : "vi.fn()";
108
- config.onceMockImplementations = [];
109
- return mock;
110
- };
111
- mock.mockRestore = function mockRestore() {
112
- mock.mockReset();
113
- return restore === null || restore === void 0 ? void 0 : restore();
114
- };
115
- mock.mockName = function mockName(name) {
116
- if (typeof name === "string") {
117
- config.mockName = name;
118
- }
119
- return mock;
120
- };
121
- mock.getMockName = function getMockName() {
122
- return config.mockName || "vi.fn()";
123
- };
124
- if (Symbol.dispose) {
125
- mock[Symbol.dispose] = () => mock.mockRestore();
126
- }
127
- if (mockImplementation) {
128
- mock.mockImplementation(mockImplementation);
129
- }
130
- return mock;
131
- }
132
- function fn(originalImplementation) {
133
- if (originalImplementation != null && isMockFunction(originalImplementation)) {
134
- return originalImplementation;
135
- }
136
- return createMockInstance({
137
- mockImplementation: originalImplementation,
138
- resetToMockImplementation: true
139
- });
140
- }
141
- function spyOn(object, key, accessor) {
142
- assert(object != null, "The vi.spyOn() function could not find an object to spy upon. The first argument must be defined.");
143
- assert(typeof object === "object" || typeof object === "function", "Vitest cannot spy on a primitive value.");
144
- const [originalDescriptorObject, originalDescriptor] = getDescriptor(object, key) || [];
145
- assert(originalDescriptor || key in object, `The property "${String(key)}" is not defined on the ${typeof object}.`);
146
- let accessType = accessor || "value";
147
- let ssr = false;
148
- if (accessType === "value" && originalDescriptor && originalDescriptor.value == null && originalDescriptor.get) {
149
- accessType = "get";
150
- ssr = true;
151
- }
152
- let original;
153
- if (originalDescriptor) {
154
- original = originalDescriptor[accessType];
155
- } else if (accessType !== "value") {
156
- original = () => object[key];
157
- } else {
158
- original = object[key];
159
- }
160
- const originalImplementation = ssr && original ? original() : original;
161
- const originalType = typeof originalImplementation;
162
- assert(
163
- // allow only functions
164
- originalType === "function" || accessType !== "value" && original == null,
165
- `vi.spyOn() can only spy on a function. Received ${originalType}.`
166
- );
167
- if (isMockFunction(originalImplementation)) {
168
- return originalImplementation;
169
- }
170
- const reassign = (cb) => {
171
- const { value, ...desc } = originalDescriptor || {
172
- configurable: true,
173
- writable: true
174
- };
175
- if (accessType !== "value") {
176
- delete desc.writable;
177
- }
178
- desc[accessType] = cb;
179
- Object.defineProperty(object, key, desc);
180
- };
181
- const restore = () => {
182
- if (originalDescriptorObject !== object) {
183
- Reflect.deleteProperty(object, key);
184
- } else if (originalDescriptor && !original) {
185
- Object.defineProperty(object, key, originalDescriptor);
186
- } else {
187
- reassign(original);
188
- }
189
- };
190
- const mock = createMockInstance({
191
- restore,
192
- originalImplementation,
193
- resetToMockName: true
194
- });
195
- try {
196
- reassign(ssr ? () => mock : mock);
197
- } catch (error) {
198
- if (error instanceof TypeError && Symbol.toStringTag && object[Symbol.toStringTag] === "Module" && (error.message.includes("Cannot redefine property") || error.message.includes("Cannot replace module namespace") || error.message.includes("can't redefine non-configurable property"))) {
199
- throw new TypeError(`Cannot spy on export "${String(key)}". Module namespace is not configurable in ESM. See: https://vitest.dev/guide/browser/#limitations`, { cause: error });
200
- }
201
- throw error;
202
- }
203
- return mock;
204
- }
205
- function getDescriptor(obj, method) {
206
- const objDescriptor = Object.getOwnPropertyDescriptor(obj, method);
207
- if (objDescriptor) {
208
- return [obj, objDescriptor];
209
- }
210
- let currentProto = Object.getPrototypeOf(obj);
211
- while (currentProto !== null) {
212
- const descriptor = Object.getOwnPropertyDescriptor(currentProto, method);
213
- if (descriptor) {
214
- return [currentProto, descriptor];
215
- }
216
- currentProto = Object.getPrototypeOf(currentProto);
217
- }
218
- }
219
- function assert(condition, message) {
220
- if (!condition) {
221
- throw new Error(message);
222
- }
223
- }
224
- let invocationCallCounter = 1;
225
- function createMock({ state, config, name: mockName, prototypeState, prototypeConfig, keepMembersImplementation, mockImplementation, prototypeMembers = [] }) {
226
- const original = config.mockOriginal;
227
- const pseudoOriginal = mockImplementation;
228
- const name = mockName || (original === null || original === void 0 ? void 0 : original.name) || "Mock";
229
- const namedObject = { [name]: (function(...args) {
230
- registerCalls(args, state, prototypeState);
231
- registerInvocationOrder(invocationCallCounter++, state, prototypeState);
232
- const result = {
233
- type: "incomplete",
234
- value: void 0
235
- };
236
- const settledResult = {
237
- type: "incomplete",
238
- value: void 0
239
- };
240
- registerResult(result, state, prototypeState);
241
- registerSettledResult(settledResult, state, prototypeState);
242
- const context = new.target ? void 0 : this;
243
- const [instanceIndex, instancePrototypeIndex] = registerInstance(context, state, prototypeState);
244
- const [contextIndex, contextPrototypeIndex] = registerContext(context, state, prototypeState);
245
- const implementation = config.onceMockImplementations.shift() || config.mockImplementation || (prototypeConfig === null || prototypeConfig === void 0 ? void 0 : prototypeConfig.onceMockImplementations.shift()) || (prototypeConfig === null || prototypeConfig === void 0 ? void 0 : prototypeConfig.mockImplementation) || original || function() {
246
- };
247
- let returnValue;
248
- let thrownValue;
249
- let didThrow = false;
250
- try {
251
- if (new.target) {
252
- returnValue = Reflect.construct(implementation, args, new.target);
253
- for (const prop of prototypeMembers) {
254
- const prototypeMock = returnValue[prop];
255
- if (prototypeMock !== mock.prototype[prop]) {
256
- continue;
257
- }
258
- const isMock = isMockFunction(prototypeMock);
259
- const prototypeState2 = isMock ? prototypeMock.mock : void 0;
260
- const prototypeConfig2 = isMock ? MOCK_CONFIGS.get(prototypeMock) : void 0;
261
- returnValue[prop] = createMockInstance({
262
- originalImplementation: keepMembersImplementation ? prototypeConfig2 === null || prototypeConfig2 === void 0 ? void 0 : prototypeConfig2.mockOriginal : void 0,
263
- prototypeState: prototypeState2,
264
- prototypeConfig: prototypeConfig2,
265
- keepMembersImplementation
266
- });
267
- }
268
- } else {
269
- returnValue = implementation.apply(this, args);
270
- }
271
- } catch (error) {
272
- thrownValue = error;
273
- didThrow = true;
274
- if (error instanceof TypeError && error.message.includes("is not a constructor")) {
275
- console.warn(`[vitest] The ${namedObject[name].getMockName()} mock did not use 'function' or 'class' in its implementation, see https://vitest.dev/api/vi#vi-spyon for examples.`);
276
- }
277
- throw error;
278
- } finally {
279
- if (didThrow) {
280
- result.type = "throw";
281
- result.value = thrownValue;
282
- settledResult.type = "rejected";
283
- settledResult.value = thrownValue;
284
- } else {
285
- result.type = "return";
286
- result.value = returnValue;
287
- if (new.target) {
288
- state.contexts[contextIndex - 1] = returnValue;
289
- state.instances[instanceIndex - 1] = returnValue;
290
- if (contextPrototypeIndex != null && prototypeState) {
291
- prototypeState.contexts[contextPrototypeIndex - 1] = returnValue;
292
- }
293
- if (instancePrototypeIndex != null && prototypeState) {
294
- prototypeState.instances[instancePrototypeIndex - 1] = returnValue;
295
- }
296
- }
297
- if (returnValue instanceof Promise) {
298
- returnValue.then((settledValue) => {
299
- settledResult.type = "fulfilled";
300
- settledResult.value = settledValue;
301
- }, (rejectedValue) => {
302
- settledResult.type = "rejected";
303
- settledResult.value = rejectedValue;
304
- });
305
- } else {
306
- settledResult.type = "fulfilled";
307
- settledResult.value = returnValue;
308
- }
309
- }
310
- }
311
- return returnValue;
312
- }) };
313
- const mock = namedObject[name];
314
- const copyPropertiesFrom = original || pseudoOriginal;
315
- if (copyPropertiesFrom) {
316
- copyOriginalStaticProperties(mock, copyPropertiesFrom);
317
- }
318
- return mock;
319
- }
320
- function registerCalls(args, state, prototypeState) {
321
- state.calls.push(args);
322
- prototypeState === null || prototypeState === void 0 ? void 0 : prototypeState.calls.push(args);
323
- }
324
- function registerInvocationOrder(order, state, prototypeState) {
325
- state.invocationCallOrder.push(order);
326
- prototypeState === null || prototypeState === void 0 ? void 0 : prototypeState.invocationCallOrder.push(order);
327
- }
328
- function registerResult(result, state, prototypeState) {
329
- state.results.push(result);
330
- prototypeState === null || prototypeState === void 0 ? void 0 : prototypeState.results.push(result);
331
- }
332
- function registerSettledResult(result, state, prototypeState) {
333
- state.settledResults.push(result);
334
- prototypeState === null || prototypeState === void 0 ? void 0 : prototypeState.settledResults.push(result);
335
- }
336
- function registerInstance(instance, state, prototypeState) {
337
- const instanceIndex = state.instances.push(instance);
338
- const instancePrototypeIndex = prototypeState === null || prototypeState === void 0 ? void 0 : prototypeState.instances.push(instance);
339
- return [instanceIndex, instancePrototypeIndex];
340
- }
341
- function registerContext(context, state, prototypeState) {
342
- const contextIndex = state.contexts.push(context);
343
- const contextPrototypeIndex = prototypeState === null || prototypeState === void 0 ? void 0 : prototypeState.contexts.push(context);
344
- return [contextIndex, contextPrototypeIndex];
345
- }
346
- function copyOriginalStaticProperties(mock, original) {
347
- const { properties, descriptors } = getAllProperties(original);
348
- for (const key of properties) {
349
- const descriptor = descriptors[key];
350
- const mockDescriptor = getDescriptor(mock, key);
351
- if (mockDescriptor) {
352
- continue;
353
- }
354
- Object.defineProperty(mock, key, descriptor);
355
- }
356
- }
357
- const ignoreProperties = /* @__PURE__ */ new Set([
358
- "length",
359
- "name",
360
- "prototype",
361
- /* @__PURE__ */ Symbol.for("nodejs.util.promisify.custom")
362
- ]);
363
- function getAllProperties(original) {
364
- const properties = /* @__PURE__ */ new Set();
365
- const descriptors = {};
366
- while (original && original !== Object.prototype && original !== Function.prototype) {
367
- const ownProperties = [...Object.getOwnPropertyNames(original), ...Object.getOwnPropertySymbols(original)];
368
- for (const prop of ownProperties) {
369
- if (descriptors[prop] || ignoreProperties.has(prop)) {
370
- continue;
371
- }
372
- properties.add(prop);
373
- descriptors[prop] = Object.getOwnPropertyDescriptor(original, prop);
374
- }
375
- original = Object.getPrototypeOf(original);
376
- }
377
- return {
378
- properties,
379
- descriptors
380
- };
381
- }
382
- function getDefaultConfig(original) {
383
- return {
384
- mockImplementation: void 0,
385
- mockOriginal: original,
386
- mockName: "vi.fn()",
387
- onceMockImplementations: []
388
- };
389
- }
390
- function getDefaultState() {
391
- const state = {
392
- calls: [],
393
- contexts: [],
394
- instances: [],
395
- invocationCallOrder: [],
396
- settledResults: [],
397
- results: [],
398
- get lastCall() {
399
- return state.calls.at(-1);
400
- }
401
- };
402
- return state;
403
- }
404
- function restoreAllMocks() {
405
- for (const restore of MOCK_RESTORE) {
406
- restore();
407
- }
408
- MOCK_RESTORE.clear();
409
- }
410
- function clearAllMocks() {
411
- REGISTERED_MOCKS.forEach((mock) => mock.mockClear());
412
- }
413
- function resetAllMocks() {
414
- REGISTERED_MOCKS.forEach((mock) => mock.mockReset());
415
- }
416
- exports.clearAllMocks = clearAllMocks;
417
- exports.createMockInstance = createMockInstance;
418
- exports.fn = fn;
419
- exports.isMockFunction = isMockFunction;
420
- exports.resetAllMocks = resetAllMocks;
421
- exports.restoreAllMocks = restoreAllMocks;
422
- exports.spyOn = spyOn;