vitest-auto-spy 3.12.0 → 3.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.
- package/AGENTS.md +8 -0
- package/README.md +9 -5
- package/dist/angular.js +16 -3
- package/dist/bun-angular.js +4 -4
- package/dist/bun.js +2 -2
- package/dist/{chunk-B7PDIHEG.js → chunk-7YTPHYP7.js} +16 -4
- package/dist/{chunk-LVLSMH6T.js → chunk-JV5XRAS4.js} +1 -1
- package/dist/{chunk-FKAXOKP5.js → chunk-ZBVBJFNW.js} +2 -2
- package/dist/index.js +17 -4
- package/dist/nestjs.js +2 -2
- package/dist/node.cjs +17 -4
- package/dist/node.js +2 -2
- package/dist/react.js +2 -2
- package/dist/svelte.js +2 -2
- package/dist/vue.js +3 -3
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -668,6 +668,14 @@ sub-tree). The key is non-enumerable, so a spread does not copy it, and there is
|
|
|
668
668
|
`[Symbol.dispose]` on a host mock restores the original implementation instead — call
|
|
669
669
|
`resetAutoSpy(spy)` there. If the project does not transpile `using`, call `spy[Symbol.dispose]()`.
|
|
670
670
|
|
|
671
|
+
`src/lib/dispose-symbol.ts` installs `Symbol.dispose` when the realm has none, and `DISPOSE` — not
|
|
672
|
+
`Symbol.dispose` — is what library code compares against. Node 22 has no explicit resource
|
|
673
|
+
management in V8: it patches the symbol in itself, as `Symbol.for('nodejs.dispose')`, onto the main
|
|
674
|
+
realm only, so under `jsdom` / `happy-dom` (a bare `vm` context) it is absent, the downlevelled
|
|
675
|
+
`using` throws out of `tslib.__addDisposableResource`, and `spy[Symbol.dispose]` degrades into a
|
|
676
|
+
property named `"undefined"`. The shim is the same registry symbol, so it is identical to Node's
|
|
677
|
+
across realms.
|
|
678
|
+
|
|
671
679
|
---
|
|
672
680
|
|
|
673
681
|
## 8. Observable assertions (core entry — no rxjs needed)
|
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ identical API, with **RxJS** spies and **Angular / NestJS / React / Vue·Pinia /
|
|
|
16
16
|
[](https://www.npmjs.com/package/vitest-auto-spy)
|
|
17
17
|
[](https://www.npmjs.com/package/vitest-auto-spy)
|
|
18
18
|
[](https://github.com/ASDAlexey/vitest-auto-spy/actions/workflows/ci.yml)
|
|
19
|
-
[](#install)
|
|
20
20
|
[](https://www.npmjs.com/package/vitest-auto-spy)
|
|
21
21
|
[](https://github.com/ASDAlexey/vitest-auto-spy/actions/workflows/ci.yml)
|
|
22
22
|
[](./LICENSE)
|
|
@@ -1336,10 +1336,14 @@ non-enumerable, so `{ ...spy }` does not carry it into a snapshot, and there is
|
|
|
1336
1336
|
`[Symbol.asyncDispose]` — `resetAutoSpy` is synchronous, and `await using` falls back to `@@dispose`
|
|
1337
1337
|
anyway.
|
|
1338
1338
|
|
|
1339
|
-
**The method is ours; the `using` declaration is your toolchain's.** `
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1339
|
+
**The method is ours; the `using` declaration is your toolchain's.** esbuild and `tsc` both downlevel
|
|
1340
|
+
the declaration. If your setup does not transpile, call `spy[Symbol.dispose]()` or
|
|
1341
|
+
`resetAutoSpy(spy)` directly. On **Node 22** the package installs the missing `Symbol.dispose` when
|
|
1342
|
+
it loads: the downlevelled form reads the symbol off the global `Symbol`, and Node 22 patches it in
|
|
1343
|
+
only on its main realm — under Vitest's `jsdom` environment, whose globals come from a `vm` context,
|
|
1344
|
+
it is absent and `using` throws `TypeError: Symbol.dispose is not defined.`. The shim is
|
|
1345
|
+
`Symbol.for('nodejs.dispose')`, the same registry symbol Node uses, so the key is identical across
|
|
1346
|
+
realms; a runtime that already has the symbol (Node 24+, Bun) is left untouched. A standalone `createFunctionSpy` is **not** covered: it is a host-runner mock, and Vitest
|
|
1343
1347
|
puts its own `[Symbol.dispose]` on those, which restores the original implementation rather than
|
|
1344
1348
|
reverting this library's configuration.
|
|
1345
1349
|
|
package/dist/angular.js
CHANGED
|
@@ -42,6 +42,19 @@ function useVitestAdapter() {
|
|
|
42
42
|
registerMockAdapter(vitestMockAdapter);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
// src/lib/dispose-symbol.ts
|
|
46
|
+
var NODE_DISPOSE_KEY = "nodejs.dispose";
|
|
47
|
+
function installDisposeSymbol(host) {
|
|
48
|
+
const existing = Reflect.get(host, "dispose");
|
|
49
|
+
if (typeof existing === "symbol") {
|
|
50
|
+
return existing;
|
|
51
|
+
}
|
|
52
|
+
const shim = Symbol.for(NODE_DISPOSE_KEY);
|
|
53
|
+
Object.defineProperty(host, "dispose", { value: shim, enumerable: false, configurable: true, writable: false });
|
|
54
|
+
return shim;
|
|
55
|
+
}
|
|
56
|
+
var DISPOSE = installDisposeSymbol(Symbol);
|
|
57
|
+
|
|
45
58
|
// src/lib/docs-links.ts
|
|
46
59
|
var DOCS = "https://asdalexey.github.io/vitest-auto-spy";
|
|
47
60
|
var DOCS_LINKS = {
|
|
@@ -692,7 +705,7 @@ function disposeAutoSpy() {
|
|
|
692
705
|
resetAutoSpy(this);
|
|
693
706
|
}
|
|
694
707
|
function attachDispose(spy) {
|
|
695
|
-
Object.defineProperty(spy,
|
|
708
|
+
Object.defineProperty(spy, DISPOSE, { value: disposeAutoSpy, enumerable: false, configurable: true, writable: true });
|
|
696
709
|
}
|
|
697
710
|
|
|
698
711
|
// src/lib/auto-mock.ts
|
|
@@ -750,7 +763,7 @@ function createAutoMockHandler(seed, unstubbed) {
|
|
|
750
763
|
defineProperty: (_target, key, descriptor) => storeDefinedProp(store, key, descriptor),
|
|
751
764
|
deleteProperty: (_target, key) => dropStoredProp(store, key),
|
|
752
765
|
has(_target, key) {
|
|
753
|
-
return key === AUTO_SPY_MARK || key ===
|
|
766
|
+
return key === AUTO_SPY_MARK || key === DISPOSE || hasStoredProp(store, key);
|
|
754
767
|
},
|
|
755
768
|
ownKeys() {
|
|
756
769
|
return [.../* @__PURE__ */ new Set([...store.values.keys(), ...store.accessors.keys()])];
|
|
@@ -769,7 +782,7 @@ function readKey(store, key, receiver, unstubbed) {
|
|
|
769
782
|
if (key === AUTO_SPY_MARK) {
|
|
770
783
|
return true;
|
|
771
784
|
}
|
|
772
|
-
if (key ===
|
|
785
|
+
if (key === DISPOSE) {
|
|
773
786
|
return disposeAutoSpy;
|
|
774
787
|
}
|
|
775
788
|
if (typeof key === "symbol" || key === "then" || key === "constructor" || isProtocolKey(key) || isDeletedProp(store, key)) {
|
package/dist/bun-angular.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import './chunk-Y4YG7UOK.js';
|
|
2
|
-
import { createSpyForToken } from './chunk-
|
|
2
|
+
import { createSpyForToken } from './chunk-JV5XRAS4.js';
|
|
3
3
|
import './chunk-NQXXUJPS.js';
|
|
4
|
-
export { asInstance, asInstances, asSpy, assertMocked, captureArg, compareTestRuns, createFixture, createFixtureFactory, createMock, createSpyClass, describeDuplicateCopies, diffByField, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, flushEventLoop, flushEventLoopUntil, formatTestRunComparison, getPackageCopies, intersectionEntry, mockConstructor, mockDeep, moduleNamespace, mutationRecord, narrow, resizeEntry, setEmissionTimeout, settleDynamicImport, stubAbortController, stubConstructor, stubIntersectionObserver, stubMediaElement, stubMutationObserver, stubObserver, stubResizeObserver, summarizeTestRun, withOverrides } from './chunk-
|
|
4
|
+
export { asInstance, asInstances, asSpy, assertMocked, captureArg, compareTestRuns, createFixture, createFixtureFactory, createMock, createSpyClass, describeDuplicateCopies, diffByField, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, flushEventLoop, flushEventLoopUntil, formatTestRunComparison, getPackageCopies, intersectionEntry, mockConstructor, mockDeep, moduleNamespace, mutationRecord, narrow, resizeEntry, setEmissionTimeout, settleDynamicImport, stubAbortController, stubConstructor, stubIntersectionObserver, stubMediaElement, stubMutationObserver, stubObserver, stubResizeObserver, summarizeTestRun, withOverrides } from './chunk-ZBVBJFNW.js';
|
|
5
5
|
export { countMockedProps, mockAccessorsProp, mockReadonlyProp, mockReadonlyPropGetter, mockValueProp, restoreMockedProps } from './chunk-R4EWAG7Y.js';
|
|
6
|
-
import { createSpyFromClass } from './chunk-
|
|
7
|
-
export { autoMocked, clearAutoSpy, createAutoMock, createSpyFromClass, resetAutoSpy } from './chunk-
|
|
6
|
+
import { createSpyFromClass } from './chunk-7YTPHYP7.js';
|
|
7
|
+
export { autoMocked, clearAutoSpy, createAutoMock, createSpyFromClass, resetAutoSpy } from './chunk-7YTPHYP7.js';
|
|
8
8
|
import { withDocs, DOCS_LINKS, isAutoSpyLike } from './chunk-3AWKPZCE.js';
|
|
9
9
|
export { createFunctionSpy, errorHandler } from './chunk-3AWKPZCE.js';
|
|
10
10
|
import './chunk-J5O72UHX.js';
|
package/dist/bun.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import './chunk-Y4YG7UOK.js';
|
|
2
2
|
import './chunk-NQXXUJPS.js';
|
|
3
|
-
export { asInstance, asInstances, asSpy, assertMocked, captureArg, compareTestRuns, createFixture, createFixtureFactory, createMock, createSpyClass, describeDuplicateCopies, diffByField, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, flushEventLoop, flushEventLoopUntil, formatTestRunComparison, getPackageCopies, intersectionEntry, mockConstructor, mockDeep, moduleNamespace, mutationRecord, narrow, resizeEntry, setEmissionTimeout, settleDynamicImport, stubAbortController, stubConstructor, stubIntersectionObserver, stubMediaElement, stubMutationObserver, stubObserver, stubResizeObserver, summarizeTestRun, withOverrides } from './chunk-
|
|
3
|
+
export { asInstance, asInstances, asSpy, assertMocked, captureArg, compareTestRuns, createFixture, createFixtureFactory, createMock, createSpyClass, describeDuplicateCopies, diffByField, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, flushEventLoop, flushEventLoopUntil, formatTestRunComparison, getPackageCopies, intersectionEntry, mockConstructor, mockDeep, moduleNamespace, mutationRecord, narrow, resizeEntry, setEmissionTimeout, settleDynamicImport, stubAbortController, stubConstructor, stubIntersectionObserver, stubMediaElement, stubMutationObserver, stubObserver, stubResizeObserver, summarizeTestRun, withOverrides } from './chunk-ZBVBJFNW.js';
|
|
4
4
|
export { countMockedProps, mockAccessorsProp, mockReadonlyProp, mockReadonlyPropGetter, mockValueProp, restoreMockedProps } from './chunk-R4EWAG7Y.js';
|
|
5
|
-
export { autoMocked, clearAutoSpy, createAutoMock, createSpyFromClass, resetAutoSpy } from './chunk-
|
|
5
|
+
export { autoMocked, clearAutoSpy, createAutoMock, createSpyFromClass, resetAutoSpy } from './chunk-7YTPHYP7.js';
|
|
6
6
|
export { createFunctionSpy, errorHandler } from './chunk-3AWKPZCE.js';
|
|
7
7
|
import './chunk-J5O72UHX.js';
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { runClearHook, runConfigReset, resolveUnstubbedGuard, withDocs, DOCS_LINKS, AUTO_SPY_MARK, createFunctionSpy, isMarkedMock, readDeepChildren, markAsMock } from './chunk-3AWKPZCE.js';
|
|
2
2
|
import { getMockAdapter, requireObservableSupport } from './shared-state.js';
|
|
3
3
|
|
|
4
|
+
// src/lib/dispose-symbol.ts
|
|
5
|
+
var NODE_DISPOSE_KEY = "nodejs.dispose";
|
|
6
|
+
function installDisposeSymbol(host) {
|
|
7
|
+
const existing = Reflect.get(host, "dispose");
|
|
8
|
+
if (typeof existing === "symbol") {
|
|
9
|
+
return existing;
|
|
10
|
+
}
|
|
11
|
+
const shim = Symbol.for(NODE_DISPOSE_KEY);
|
|
12
|
+
Object.defineProperty(host, "dispose", { value: shim, enumerable: false, configurable: true, writable: false });
|
|
13
|
+
return shim;
|
|
14
|
+
}
|
|
15
|
+
var DISPOSE = installDisposeSymbol(Symbol);
|
|
4
16
|
function isAccessorBag(value) {
|
|
5
17
|
return typeof value === "object" && value !== null && "getters" in value && "setters" in value;
|
|
6
18
|
}
|
|
@@ -61,7 +73,7 @@ function disposeAutoSpy() {
|
|
|
61
73
|
resetAutoSpy(this);
|
|
62
74
|
}
|
|
63
75
|
function attachDispose(spy) {
|
|
64
|
-
Object.defineProperty(spy,
|
|
76
|
+
Object.defineProperty(spy, DISPOSE, { value: disposeAutoSpy, enumerable: false, configurable: true, writable: true });
|
|
65
77
|
}
|
|
66
78
|
|
|
67
79
|
// src/lib/proxy-props.ts
|
|
@@ -185,7 +197,7 @@ function createAutoMockHandler(seed, unstubbed) {
|
|
|
185
197
|
defineProperty: (_target, key, descriptor) => storeDefinedProp(store, key, descriptor),
|
|
186
198
|
deleteProperty: (_target, key) => dropStoredProp(store, key),
|
|
187
199
|
has(_target, key) {
|
|
188
|
-
return key === AUTO_SPY_MARK || key ===
|
|
200
|
+
return key === AUTO_SPY_MARK || key === DISPOSE || hasStoredProp(store, key);
|
|
189
201
|
},
|
|
190
202
|
ownKeys() {
|
|
191
203
|
return [.../* @__PURE__ */ new Set([...store.values.keys(), ...store.accessors.keys()])];
|
|
@@ -204,7 +216,7 @@ function readKey(store, key, receiver, unstubbed) {
|
|
|
204
216
|
if (key === AUTO_SPY_MARK) {
|
|
205
217
|
return true;
|
|
206
218
|
}
|
|
207
|
-
if (key ===
|
|
219
|
+
if (key === DISPOSE) {
|
|
208
220
|
return disposeAutoSpy;
|
|
209
221
|
}
|
|
210
222
|
if (typeof key === "symbol" || key === "then" || key === "constructor" || isProtocolKey(key) || isDeletedProp(store, key)) {
|
|
@@ -498,4 +510,4 @@ function hasNothingToRead(ObjectClass, accessors, config) {
|
|
|
498
510
|
config.onlyMethodsToSpyOn.length === 0;
|
|
499
511
|
}
|
|
500
512
|
|
|
501
|
-
export { NOT_STORED, autoMocked, clearAutoSpy, createAutoMock, createProxyPropStore, createSpyFromClass, describeStoredProp, disposeAutoSpy, dropStoredProp, isDeletedProp, isProtocolKey, readStoredAccessor, resetAutoSpy, storeDefinedProp, writeStoredAccessor, writeStoredValue };
|
|
513
|
+
export { DISPOSE, NOT_STORED, autoMocked, clearAutoSpy, createAutoMock, createProxyPropStore, createSpyFromClass, describeStoredProp, disposeAutoSpy, dropStoredProp, isDeletedProp, isProtocolKey, readStoredAccessor, resetAutoSpy, storeDefinedProp, writeStoredAccessor, writeStoredValue };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mockValueProp, mockReadonlyPropGetter } from './chunk-R4EWAG7Y.js';
|
|
2
|
-
import { createSpyFromClass, createProxyPropStore, describeStoredProp, dropStoredProp, storeDefinedProp, writeStoredAccessor, writeStoredValue, readStoredAccessor, NOT_STORED, disposeAutoSpy, isProtocolKey, isDeletedProp } from './chunk-
|
|
2
|
+
import { createSpyFromClass, createProxyPropStore, describeStoredProp, dropStoredProp, storeDefinedProp, writeStoredAccessor, writeStoredValue, readStoredAccessor, NOT_STORED, DISPOSE, disposeAutoSpy, isProtocolKey, isDeletedProp } from './chunk-7YTPHYP7.js';
|
|
3
3
|
import { defineHelper, withDocs, DOCS_LINKS, serializeValue, createFunctionSpy, DEEP_CHILDREN } from './chunk-3AWKPZCE.js';
|
|
4
4
|
import { getMockAdapter } from './shared-state.js';
|
|
5
5
|
export { describeDuplicateCopies, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, getPackageCopies, setEmissionTimeout } from './shared-state.js';
|
|
@@ -97,7 +97,7 @@ function readNodeMember(state, target, key, receiver) {
|
|
|
97
97
|
if (key === DEEP_CHILDREN) {
|
|
98
98
|
return state.children;
|
|
99
99
|
}
|
|
100
|
-
if (key ===
|
|
100
|
+
if (key === DISPOSE) {
|
|
101
101
|
return disposeAutoSpy;
|
|
102
102
|
}
|
|
103
103
|
if (key === "then" || isProtocolKey(key)) {
|
package/dist/index.js
CHANGED
|
@@ -109,6 +109,19 @@ function createAccessorsSpies(autoSpy, gettersToSpyOn, settersToSpyOn) {
|
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
// src/lib/dispose-symbol.ts
|
|
113
|
+
var NODE_DISPOSE_KEY = "nodejs.dispose";
|
|
114
|
+
function installDisposeSymbol(host) {
|
|
115
|
+
const existing = Reflect.get(host, "dispose");
|
|
116
|
+
if (typeof existing === "symbol") {
|
|
117
|
+
return existing;
|
|
118
|
+
}
|
|
119
|
+
const shim = Symbol.for(NODE_DISPOSE_KEY);
|
|
120
|
+
Object.defineProperty(host, "dispose", { value: shim, enumerable: false, configurable: true, writable: false });
|
|
121
|
+
return shim;
|
|
122
|
+
}
|
|
123
|
+
var DISPOSE = installDisposeSymbol(Symbol);
|
|
124
|
+
|
|
112
125
|
// src/lib/docs-links.ts
|
|
113
126
|
var DOCS = "https://asdalexey.github.io/vitest-auto-spy";
|
|
114
127
|
var DOCS_LINKS = {
|
|
@@ -708,7 +721,7 @@ function disposeAutoSpy() {
|
|
|
708
721
|
resetAutoSpy(this);
|
|
709
722
|
}
|
|
710
723
|
function attachDispose(spy) {
|
|
711
|
-
Object.defineProperty(spy,
|
|
724
|
+
Object.defineProperty(spy, DISPOSE, { value: disposeAutoSpy, enumerable: false, configurable: true, writable: true });
|
|
712
725
|
}
|
|
713
726
|
|
|
714
727
|
// src/lib/auto-mock.ts
|
|
@@ -766,7 +779,7 @@ function createAutoMockHandler(seed, unstubbed) {
|
|
|
766
779
|
defineProperty: (_target, key, descriptor) => storeDefinedProp(store, key, descriptor),
|
|
767
780
|
deleteProperty: (_target, key) => dropStoredProp(store, key),
|
|
768
781
|
has(_target, key) {
|
|
769
|
-
return key === AUTO_SPY_MARK || key ===
|
|
782
|
+
return key === AUTO_SPY_MARK || key === DISPOSE || hasStoredProp(store, key);
|
|
770
783
|
},
|
|
771
784
|
ownKeys() {
|
|
772
785
|
return [.../* @__PURE__ */ new Set([...store.values.keys(), ...store.accessors.keys()])];
|
|
@@ -785,7 +798,7 @@ function readKey(store, key, receiver, unstubbed) {
|
|
|
785
798
|
if (key === AUTO_SPY_MARK) {
|
|
786
799
|
return true;
|
|
787
800
|
}
|
|
788
|
-
if (key ===
|
|
801
|
+
if (key === DISPOSE) {
|
|
789
802
|
return disposeAutoSpy;
|
|
790
803
|
}
|
|
791
804
|
if (typeof key === "symbol" || key === "then" || key === "constructor" || isProtocolKey(key) || isDeletedProp(store, key)) {
|
|
@@ -1142,7 +1155,7 @@ function readNodeMember(state, target, key, receiver) {
|
|
|
1142
1155
|
if (key === DEEP_CHILDREN) {
|
|
1143
1156
|
return state.children;
|
|
1144
1157
|
}
|
|
1145
|
-
if (key ===
|
|
1158
|
+
if (key === DISPOSE) {
|
|
1146
1159
|
return disposeAutoSpy;
|
|
1147
1160
|
}
|
|
1148
1161
|
if (key === "then" || isProtocolKey(key)) {
|
package/dist/nestjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { trackInjections } from './chunk-
|
|
1
|
+
export { trackInjections } from './chunk-JV5XRAS4.js';
|
|
2
2
|
import { vitestMockAdapter } from './chunk-MG5EAMZR.js';
|
|
3
|
-
import { createSpyFromClass } from './chunk-
|
|
3
|
+
import { createSpyFromClass } from './chunk-7YTPHYP7.js';
|
|
4
4
|
import './chunk-3AWKPZCE.js';
|
|
5
5
|
import './chunk-J5O72UHX.js';
|
|
6
6
|
import { registerMockAdapter } from './shared-state.js';
|
package/dist/node.cjs
CHANGED
|
@@ -289,6 +289,19 @@ function createAccessorsSpies(autoSpy, gettersToSpyOn, settersToSpyOn) {
|
|
|
289
289
|
});
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
+
// src/lib/dispose-symbol.ts
|
|
293
|
+
var NODE_DISPOSE_KEY = "nodejs.dispose";
|
|
294
|
+
function installDisposeSymbol(host) {
|
|
295
|
+
const existing = Reflect.get(host, "dispose");
|
|
296
|
+
if (typeof existing === "symbol") {
|
|
297
|
+
return existing;
|
|
298
|
+
}
|
|
299
|
+
const shim = Symbol.for(NODE_DISPOSE_KEY);
|
|
300
|
+
Object.defineProperty(host, "dispose", { value: shim, enumerable: false, configurable: true, writable: false });
|
|
301
|
+
return shim;
|
|
302
|
+
}
|
|
303
|
+
var DISPOSE = installDisposeSymbol(Symbol);
|
|
304
|
+
|
|
292
305
|
// src/lib/serialize-args.ts
|
|
293
306
|
function createContext() {
|
|
294
307
|
return { seen: /* @__PURE__ */ new WeakSet(), cache: /* @__PURE__ */ new Map(), circularHits: 0 };
|
|
@@ -874,7 +887,7 @@ function disposeAutoSpy() {
|
|
|
874
887
|
resetAutoSpy(this);
|
|
875
888
|
}
|
|
876
889
|
function attachDispose(spy) {
|
|
877
|
-
Object.defineProperty(spy,
|
|
890
|
+
Object.defineProperty(spy, DISPOSE, { value: disposeAutoSpy, enumerable: false, configurable: true, writable: true });
|
|
878
891
|
}
|
|
879
892
|
|
|
880
893
|
// src/lib/auto-mock.ts
|
|
@@ -932,7 +945,7 @@ function createAutoMockHandler(seed, unstubbed) {
|
|
|
932
945
|
defineProperty: (_target, key, descriptor) => storeDefinedProp(store, key, descriptor),
|
|
933
946
|
deleteProperty: (_target, key) => dropStoredProp(store, key),
|
|
934
947
|
has(_target, key) {
|
|
935
|
-
return key === AUTO_SPY_MARK || key ===
|
|
948
|
+
return key === AUTO_SPY_MARK || key === DISPOSE || hasStoredProp(store, key);
|
|
936
949
|
},
|
|
937
950
|
ownKeys() {
|
|
938
951
|
return [.../* @__PURE__ */ new Set([...store.values.keys(), ...store.accessors.keys()])];
|
|
@@ -951,7 +964,7 @@ function readKey(store, key, receiver, unstubbed) {
|
|
|
951
964
|
if (key === AUTO_SPY_MARK) {
|
|
952
965
|
return true;
|
|
953
966
|
}
|
|
954
|
-
if (key ===
|
|
967
|
+
if (key === DISPOSE) {
|
|
955
968
|
return disposeAutoSpy;
|
|
956
969
|
}
|
|
957
970
|
if (typeof key === "symbol" || key === "then" || key === "constructor" || isProtocolKey(key) || isDeletedProp(store, key)) {
|
|
@@ -1310,7 +1323,7 @@ function readNodeMember(state, target, key, receiver) {
|
|
|
1310
1323
|
if (key === DEEP_CHILDREN) {
|
|
1311
1324
|
return state.children;
|
|
1312
1325
|
}
|
|
1313
|
-
if (key ===
|
|
1326
|
+
if (key === DISPOSE) {
|
|
1314
1327
|
return disposeAutoSpy;
|
|
1315
1328
|
}
|
|
1316
1329
|
if (key === "then" || isProtocolKey(key)) {
|
package/dist/node.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRedefineMockAdapter } from './chunk-NQXXUJPS.js';
|
|
2
|
-
export { asInstance, asInstances, asSpy, assertMocked, captureArg, compareTestRuns, createFixture, createFixtureFactory, createMock, createSpyClass, describeDuplicateCopies, diffByField, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, flushEventLoop, flushEventLoopUntil, formatTestRunComparison, getPackageCopies, intersectionEntry, mockConstructor, mockDeep, moduleNamespace, mutationRecord, narrow, resizeEntry, setEmissionTimeout, settleDynamicImport, stubAbortController, stubConstructor, stubIntersectionObserver, stubMediaElement, stubMutationObserver, stubObserver, stubResizeObserver, summarizeTestRun, withOverrides } from './chunk-
|
|
2
|
+
export { asInstance, asInstances, asSpy, assertMocked, captureArg, compareTestRuns, createFixture, createFixtureFactory, createMock, createSpyClass, describeDuplicateCopies, diffByField, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, flushEventLoop, flushEventLoopUntil, formatTestRunComparison, getPackageCopies, intersectionEntry, mockConstructor, mockDeep, moduleNamespace, mutationRecord, narrow, resizeEntry, setEmissionTimeout, settleDynamicImport, stubAbortController, stubConstructor, stubIntersectionObserver, stubMediaElement, stubMutationObserver, stubObserver, stubResizeObserver, summarizeTestRun, withOverrides } from './chunk-ZBVBJFNW.js';
|
|
3
3
|
export { countMockedProps, mockAccessorsProp, mockReadonlyProp, mockReadonlyPropGetter, mockValueProp, restoreMockedProps } from './chunk-R4EWAG7Y.js';
|
|
4
|
-
export { autoMocked, clearAutoSpy, createAutoMock, createSpyFromClass, resetAutoSpy } from './chunk-
|
|
4
|
+
export { autoMocked, clearAutoSpy, createAutoMock, createSpyFromClass, resetAutoSpy } from './chunk-7YTPHYP7.js';
|
|
5
5
|
export { createFunctionSpy, errorHandler } from './chunk-3AWKPZCE.js';
|
|
6
6
|
import './chunk-J5O72UHX.js';
|
|
7
7
|
import { mock } from 'node:test';
|
package/dist/react.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { vitestMockAdapter } from './chunk-MG5EAMZR.js';
|
|
2
|
-
export { asInstance, asInstances, asSpy, assertMocked, captureArg, compareTestRuns, createFixture, createFixtureFactory, createMock, createSpyClass, describeDuplicateCopies, diffByField, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, flushEventLoop, flushEventLoopUntil, formatTestRunComparison, getPackageCopies, intersectionEntry, mockConstructor, mockDeep, moduleNamespace, mutationRecord, narrow, resizeEntry, setEmissionTimeout, settleDynamicImport, stubAbortController, stubConstructor, stubIntersectionObserver, stubMediaElement, stubMutationObserver, stubObserver, stubResizeObserver, summarizeTestRun, withOverrides } from './chunk-
|
|
2
|
+
export { asInstance, asInstances, asSpy, assertMocked, captureArg, compareTestRuns, createFixture, createFixtureFactory, createMock, createSpyClass, describeDuplicateCopies, diffByField, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, flushEventLoop, flushEventLoopUntil, formatTestRunComparison, getPackageCopies, intersectionEntry, mockConstructor, mockDeep, moduleNamespace, mutationRecord, narrow, resizeEntry, setEmissionTimeout, settleDynamicImport, stubAbortController, stubConstructor, stubIntersectionObserver, stubMediaElement, stubMutationObserver, stubObserver, stubResizeObserver, summarizeTestRun, withOverrides } from './chunk-ZBVBJFNW.js';
|
|
3
3
|
export { countMockedProps, mockAccessorsProp, mockReadonlyProp, mockReadonlyPropGetter, mockValueProp, restoreMockedProps } from './chunk-R4EWAG7Y.js';
|
|
4
|
-
export { autoMocked, clearAutoSpy, createAutoMock, createSpyFromClass, resetAutoSpy } from './chunk-
|
|
4
|
+
export { autoMocked, clearAutoSpy, createAutoMock, createSpyFromClass, resetAutoSpy } from './chunk-7YTPHYP7.js';
|
|
5
5
|
export { createFunctionSpy, errorHandler } from './chunk-3AWKPZCE.js';
|
|
6
6
|
import './chunk-J5O72UHX.js';
|
|
7
7
|
import { registerMockAdapter } from './shared-state.js';
|
package/dist/svelte.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { vitestMockAdapter } from './chunk-MG5EAMZR.js';
|
|
2
|
-
export { asInstance, asInstances, asSpy, assertMocked, captureArg, compareTestRuns, createFixture, createFixtureFactory, createMock, createSpyClass, describeDuplicateCopies, diffByField, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, flushEventLoop, flushEventLoopUntil, formatTestRunComparison, getPackageCopies, intersectionEntry, mockConstructor, mockDeep, moduleNamespace, mutationRecord, narrow, resizeEntry, setEmissionTimeout, settleDynamicImport, stubAbortController, stubConstructor, stubIntersectionObserver, stubMediaElement, stubMutationObserver, stubObserver, stubResizeObserver, summarizeTestRun, withOverrides } from './chunk-
|
|
2
|
+
export { asInstance, asInstances, asSpy, assertMocked, captureArg, compareTestRuns, createFixture, createFixtureFactory, createMock, createSpyClass, describeDuplicateCopies, diffByField, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, flushEventLoop, flushEventLoopUntil, formatTestRunComparison, getPackageCopies, intersectionEntry, mockConstructor, mockDeep, moduleNamespace, mutationRecord, narrow, resizeEntry, setEmissionTimeout, settleDynamicImport, stubAbortController, stubConstructor, stubIntersectionObserver, stubMediaElement, stubMutationObserver, stubObserver, stubResizeObserver, summarizeTestRun, withOverrides } from './chunk-ZBVBJFNW.js';
|
|
3
3
|
export { countMockedProps, mockAccessorsProp, mockReadonlyProp, mockReadonlyPropGetter, mockValueProp, restoreMockedProps } from './chunk-R4EWAG7Y.js';
|
|
4
|
-
export { autoMocked, clearAutoSpy, createAutoMock, createSpyFromClass, resetAutoSpy } from './chunk-
|
|
4
|
+
export { autoMocked, clearAutoSpy, createAutoMock, createSpyFromClass, resetAutoSpy } from './chunk-7YTPHYP7.js';
|
|
5
5
|
export { createFunctionSpy, errorHandler } from './chunk-3AWKPZCE.js';
|
|
6
6
|
import './chunk-J5O72UHX.js';
|
|
7
7
|
import { registerMockAdapter } from './shared-state.js';
|
package/dist/vue.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { vitestMockAdapter } from './chunk-MG5EAMZR.js';
|
|
2
|
-
export { asInstance, asInstances, asSpy, assertMocked, captureArg, compareTestRuns, createFixture, createFixtureFactory, createMock, createSpyClass, describeDuplicateCopies, diffByField, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, flushEventLoop, flushEventLoopUntil, formatTestRunComparison, getPackageCopies, intersectionEntry, mockConstructor, mockDeep, moduleNamespace, mutationRecord, narrow, resizeEntry, setEmissionTimeout, settleDynamicImport, stubAbortController, stubConstructor, stubIntersectionObserver, stubMediaElement, stubMutationObserver, stubObserver, stubResizeObserver, summarizeTestRun, withOverrides } from './chunk-
|
|
2
|
+
export { asInstance, asInstances, asSpy, assertMocked, captureArg, compareTestRuns, createFixture, createFixtureFactory, createMock, createSpyClass, describeDuplicateCopies, diffByField, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, flushEventLoop, flushEventLoopUntil, formatTestRunComparison, getPackageCopies, intersectionEntry, mockConstructor, mockDeep, moduleNamespace, mutationRecord, narrow, resizeEntry, setEmissionTimeout, settleDynamicImport, stubAbortController, stubConstructor, stubIntersectionObserver, stubMediaElement, stubMutationObserver, stubObserver, stubResizeObserver, summarizeTestRun, withOverrides } from './chunk-ZBVBJFNW.js';
|
|
3
3
|
export { countMockedProps, mockAccessorsProp, mockReadonlyProp, mockReadonlyPropGetter, mockValueProp, restoreMockedProps } from './chunk-R4EWAG7Y.js';
|
|
4
|
-
import { createSpyFromClass } from './chunk-
|
|
5
|
-
export { autoMocked, clearAutoSpy, createAutoMock, createSpyFromClass, resetAutoSpy } from './chunk-
|
|
4
|
+
import { createSpyFromClass } from './chunk-7YTPHYP7.js';
|
|
5
|
+
export { autoMocked, clearAutoSpy, createAutoMock, createSpyFromClass, resetAutoSpy } from './chunk-7YTPHYP7.js';
|
|
6
6
|
export { createFunctionSpy, errorHandler } from './chunk-3AWKPZCE.js';
|
|
7
7
|
import './chunk-J5O72UHX.js';
|
|
8
8
|
import { registerMockAdapter } from './shared-state.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest-auto-spy",
|
|
3
|
-
"version": "3.12.
|
|
3
|
+
"version": "3.12.1",
|
|
4
4
|
"description": "Auto-generate fully-typed test spies from a class — across Vitest, Bun and node:test, with Angular/NestJS/React/Vue/Svelte recipes. Drop-in replacement for jest-auto-spies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"auto-mock",
|