vitest-auto-spy 3.12.0 → 3.13.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.
- package/AGENTS.md +21 -2
- package/README.md +17 -7
- package/dist/angular.d.ts +5 -5
- package/dist/angular.js +31 -3
- package/dist/bun-angular.d.ts +10 -4
- package/dist/bun-angular.js +33 -5
- package/dist/bun.d.ts +9 -4
- package/dist/bun.js +2 -2
- package/dist/{chunk-B7PDIHEG.js → chunk-7YTPHYP7.js} +16 -4
- package/dist/{chunk-FKAXOKP5.js → chunk-IKH4OTMV.js} +10 -2
- package/dist/{chunk-LVLSMH6T.js → chunk-JV5XRAS4.js} +1 -1
- package/dist/console.d.ts +1 -1
- package/dist/{expect-emission-CuGjE0YR.d.ts → expect-emission-DMx5uXie.d.ts} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +25 -4
- package/dist/nestjs.d.ts +2 -2
- package/dist/nestjs.js +2 -2
- package/dist/node.cjs +25 -4
- package/dist/node.d.ts +3 -3
- package/dist/node.js +2 -2
- package/dist/{prop-mock-IgCwv_40.d.ts → prop-mock-DyjtZVoA.d.ts} +1 -1
- package/dist/react.d.ts +3 -3
- package/dist/react.js +2 -2
- package/dist/rxjs.d.ts +2 -2
- package/dist/rxjs.js +9 -2
- package/dist/setup.d.ts +22 -3
- package/dist/setup.js +40 -1
- package/dist/svelte.d.ts +3 -3
- package/dist/svelte.js +2 -2
- package/dist/{track-injections-BAzV5ITq.d.ts → track-injections-BQndbppn.d.ts} +1 -1
- package/dist/{types-it6CnDkI.d.ts → types-Br-Usge9.d.ts} +13 -2
- package/dist/vue.d.ts +4 -4
- package/dist/vue.js +3 -3
- package/dist/{zoneless-BUNSBSIP.d.ts → zoneless-CEhs7o9p.d.ts} +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)
|
|
@@ -950,8 +958,19 @@ by a dynamic `import()` inside a test — and says so explicitly:
|
|
|
950
958
|
export const navigation = { setFocus: keepMockRegistered(vi.fn()) };
|
|
951
959
|
```
|
|
952
960
|
|
|
953
|
-
|
|
954
|
-
|
|
961
|
+
The mocks it keeps, it also guards. Staying registered means `vi.resetAllMocks()` reaches them too —
|
|
962
|
+
it walks the same set and calls `mockReset()`, which puts an implementation back only when it was
|
|
963
|
+
passed to `vi.fn(implementation)`; behaviour chained on with `.mockReturnValue(…)` or
|
|
964
|
+
`.mockReturnThis()` is simply lost. Under `isolate: false` that surfaces in a *different* file later
|
|
965
|
+
in the same worker, inside application code, as `Cannot read properties of undefined` against a
|
|
966
|
+
shared double that spec never touched — and `vi.restoreAllMocks()` does not cause it (Vitest 4 walks
|
|
967
|
+
`MOCK_RESTORE` there, which only `vi.spyOn` writes to), so probing with that one comes back green and
|
|
968
|
+
sends the search the wrong way. The implementation a long-lived mock carried when it was classified
|
|
969
|
+
is therefore remembered and put back, in `beforeEach`, but only when it has gone missing.
|
|
970
|
+
|
|
971
|
+
`trackMockRegistry()` installs the hooks on its own, `pruneMockRegistry()` is the one-shot sweep (it
|
|
972
|
+
returns how many went), `restoreLongLivedImplementations()` is that repair (it returns how many it
|
|
973
|
+
put back) and `getMockRegistrySize()` reports what is left.
|
|
955
974
|
|
|
956
975
|
Two more switches, both about the environment rather than the spies:
|
|
957
976
|
|
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
|
|
|
@@ -1897,7 +1901,7 @@ single-purpose utility you can pick up independently — they all ride on the sa
|
|
|
1897
1901
|
| `installPerTest(install)` | `/setup` | Re-install a stub before every test of the block — a `describe`-level stub is restored away after the first |
|
|
1898
1902
|
| `setupAngularTestEnv(opts)` | `/angular` | Zone and zoneless spec files in one worker, switching platforms per file |
|
|
1899
1903
|
| `restoreTimerGlobals()` | `/setup` | Put back timer globals that uninstalling the fakes deleted rather than restored |
|
|
1900
|
-
| `trackMockRegistry()` / `keepMockRegistered(mock)`
|
|
1904
|
+
| `trackMockRegistry()` / `keepMockRegistered(mock)` / `restoreLongLivedImplementations()` | `/setup` | Keep @vitest/spy's mock registry to the mocks that outlive a file; mark one the split would miss; put back an implementation a cross-file `vi.resetAllMocks()` dropped ([details](#test-run-hygiene)) |
|
|
1901
1905
|
| `errorHandler` | core | The `mustBeCalledWith` argument-mismatch reporter — swap it to customize failure output |
|
|
1902
1906
|
|
|
1903
1907
|
A taste of the DI pair — provide the spy, inject it back fully typed:
|
|
@@ -2061,7 +2065,12 @@ expensive to diagnose when it is missing. The first three are on by default:
|
|
|
2061
2065
|
component trees. Pruning it is easy to get wrong in one specific way: drop the module-level
|
|
2062
2066
|
`vi.fn()` that six spec files import from a shared `*.mock.ts` and nothing clears it any more, so
|
|
2063
2067
|
its calls accumulate and the file that happens to run second fails on calls its predecessor made.
|
|
2064
|
-
`pruneMockRegistry` keeps what a file inherited and drops only what it added.
|
|
2068
|
+
`pruneMockRegistry` keeps what a file inherited and drops only what it added. Keeping a mock
|
|
2069
|
+
registered also means `vi.resetAllMocks()` can reach it — `mockReset` drops an implementation
|
|
2070
|
+
that came from a chained `.mockReturnValue(…)`, which under `isolate: false` kills a *later*
|
|
2071
|
+
file's test on a double it never touched — so `trackMockRegistry()` remembers the implementation
|
|
2072
|
+
each long-lived mock carried and puts it back before a test that has lost it
|
|
2073
|
+
(`restoreLongLivedImplementations()` is that repair on its own, and returns how many it put back).
|
|
2065
2074
|
9. **A hook that ran out of a budget nobody meant to give it.** On by default, because it only ever
|
|
2066
2075
|
appends a sentence to a test that has already failed. Jest applies one `testTimeout` to a hook and
|
|
2067
2076
|
to a test body alike; Vitest resolves `hookTimeout` separately and defaults it to 10 000 ms, so a
|
|
@@ -2391,6 +2400,7 @@ names are unfindable from these messages otherwise — no `TS2739` text contains
|
|
|
2391
2400
|
| `TS2345: Argument of type 'Spy<X>' is not assignable to parameter of type 'X'` | the same, in an argument | `asInstance(spy)`, or `asInstances(a, b, c)` |
|
|
2392
2401
|
| `TS2322: Type 'Spy<X>' is not assignable to type 'Mocked<X>' …` | the variable was declared `Mocked<T>` | declare it `Spy<T>` |
|
|
2393
2402
|
| `'AddPromiseSpyMethods<unknown>' is missing … from type 'WithMockReturnValue<…>'` | a generic class inferred as `Service<any>` | `asSpy<Service>(…)` / `injectSpy<Service>(…)` |
|
|
2403
|
+
| `TS2345` / `TS2554` **on a call to a spied method** (wrong arguments) | the arguments the real method rejects — the double's call signature is the method's own; it used to accept anything | fix the call; don't re-widen the spy |
|
|
2394
2404
|
| `TS2739 … 'Spy<X>' is missing …` **on a line with `injectSpy`** | the provider handed back the real object | `provideAutoSpy(X)`, or an honest `TestBed.inject` |
|
|
2395
2405
|
|
|
2396
2406
|
Two notes that cost real time when they are missing.
|
package/dist/angular.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { l as AngularTokenProvider, A as AngularValueProvider, a as AutoSpiedInstance, C as ComponentInputs, b as CreateWithAutoSpiesOptions, R as RenderShallowOptions, c as ResourceStatusLike, S as SettleResourceOptions, d as ShallowRender, e as SpyRegistry, f as StableOptions, g as createWithAutoSpies, h as flushEffects, i as injectSpy, p as provideAutoSpy, m as provideAutoSpyForToken, r as renderShallow, j as runEffect, s as settleResource, k as stable } from './zoneless-
|
|
1
|
+
export { l as AngularTokenProvider, A as AngularValueProvider, a as AutoSpiedInstance, C as ComponentInputs, b as CreateWithAutoSpiesOptions, R as RenderShallowOptions, c as ResourceStatusLike, S as SettleResourceOptions, d as ShallowRender, e as SpyRegistry, f as StableOptions, g as createWithAutoSpies, h as flushEffects, i as injectSpy, p as provideAutoSpy, m as provideAutoSpyForToken, r as renderShallow, j as runEffect, s as settleResource, k as stable } from './zoneless-CEhs7o9p.js';
|
|
2
2
|
import { Type, Signal, WritableSignal } from '@angular/core';
|
|
3
|
-
import { S as Spy, C as ClassType, a as ClassSpyConfiguration, O as OnlyMethodKeysOf, j as AddSpyMethodsByReturnTypes } from './types-
|
|
4
|
-
export { I as InjectionLog, T as TrackInjectionsOptions, a as TrackedProvider, t as trackInjections } from './track-injections-
|
|
5
|
-
export { A as AccessorImplementations, R as RestoreProp, c as countMockedProps, m as mockAccessorsProp, a as mockReadonlyProp, b as mockReadonlyPropGetter, d as mockValueProp, r as restoreMockedProps } from './prop-mock-
|
|
6
|
-
export { C as CallbackSubscribable, E as EmissionObserver, a as EmissionOptions, b as EmissionSource, S as SubscribableLike, e as expectCompletion, f as expectEmission, g as expectEmissions, h as expectError, i as expectNoEmission, s as setEmissionTimeout } from './expect-emission-
|
|
3
|
+
import { S as Spy, C as ClassType, a as ClassSpyConfiguration, O as OnlyMethodKeysOf, j as AddSpyMethodsByReturnTypes } from './types-Br-Usge9.js';
|
|
4
|
+
export { I as InjectionLog, T as TrackInjectionsOptions, a as TrackedProvider, t as trackInjections } from './track-injections-BQndbppn.js';
|
|
5
|
+
export { A as AccessorImplementations, R as RestoreProp, c as countMockedProps, m as mockAccessorsProp, a as mockReadonlyProp, b as mockReadonlyPropGetter, d as mockValueProp, r as restoreMockedProps } from './prop-mock-DyjtZVoA.js';
|
|
6
|
+
export { C as CallbackSubscribable, E as EmissionObserver, a as EmissionOptions, b as EmissionSource, S as SubscribableLike, e as expectCompletion, f as expectEmission, g as expectEmissions, h as expectError, i as expectNoEmission, s as setEmissionTimeout } from './expect-emission-DMx5uXie.js';
|
|
7
7
|
import '@angular/core/testing';
|
|
8
8
|
import 'rxjs';
|
|
9
9
|
import 'vitest';
|
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)) {
|
|
@@ -1783,7 +1796,14 @@ var AutoSpyInjector = class extends Injector {
|
|
|
1783
1796
|
tokens() {
|
|
1784
1797
|
return [...this.#spies.keys()];
|
|
1785
1798
|
}
|
|
1799
|
+
knows(token) {
|
|
1800
|
+
return this.#spies.has(token);
|
|
1801
|
+
}
|
|
1786
1802
|
};
|
|
1803
|
+
function describeToken(token) {
|
|
1804
|
+
const name = Reflect.get(Object(token), "name");
|
|
1805
|
+
return typeof name === "string" ? name : String(token);
|
|
1806
|
+
}
|
|
1787
1807
|
function factoryOf(target) {
|
|
1788
1808
|
const factory = Reflect.get(target, "\u0275fac");
|
|
1789
1809
|
return typeof factory === "function" ? factory : void 0;
|
|
@@ -1798,6 +1818,14 @@ function createWithAutoSpies(target, options = {}) {
|
|
|
1798
1818
|
injector,
|
|
1799
1819
|
spies: {
|
|
1800
1820
|
get: (token) => {
|
|
1821
|
+
if (!autoSpies.knows(token) && injector.get(token, null, { optional: true }) === null) {
|
|
1822
|
+
throw new Error(
|
|
1823
|
+
withDocs(
|
|
1824
|
+
`[vitest-auto-spy] createWithAutoSpies(${describeToken(target)}).spies.get(${describeToken(token)}): the instance never asked for that token, and nothing in \`providers\` supplies it, so the spy you would get back is not the one it uses. Auto-spied tokens: ${autoSpies.tokens().map(describeToken).join(", ") || "(none)"}.`,
|
|
1825
|
+
DOCS_LINKS.angular
|
|
1826
|
+
)
|
|
1827
|
+
);
|
|
1828
|
+
}
|
|
1801
1829
|
return injector.get(token);
|
|
1802
1830
|
},
|
|
1803
1831
|
autoSpiedTokens: () => autoSpies.tokens()
|
package/dist/bun-angular.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { d as AccessorKeysOf, e as AddAccessorsSpies, f as AddCalledWithObservable, g as AddCalledWithPromise, h as AddCalledWithSpyMethods, A as AddObservableSpyMethods, i as AddPromiseSpyMethods, j as AddSpyMethodsByReturnTypes, k as AddVoidReturnHelpers, a as ClassSpyConfiguration, C as ClassType, b as CompleteValueConfig, D as DeepMockProxy, l as DeepPartial, E as ErrorValueConfig, F as Func, M as MethodReturns, m as Mutable, N as NextValueConfig, O as OnlyMethodKeysOf, n as OnlyObservablePropsOf, o as OnlyPropsOf, p as Overload, q as Overloads, P as PropStubValue, S as Spy, r as SpyDisposable, s as SpyOptions, t as StrictSpyConfiguration, U as UnstubbedCall, u as UnstubbedCallHandler, V as ValueConfig, c as ValueConfigPerCall, W as WithMockReturnValue } from './types-
|
|
1
|
+
export { d as AccessorKeysOf, e as AddAccessorsSpies, f as AddCalledWithObservable, g as AddCalledWithPromise, h as AddCalledWithSpyMethods, A as AddObservableSpyMethods, i as AddPromiseSpyMethods, j as AddSpyMethodsByReturnTypes, k as AddVoidReturnHelpers, a as ClassSpyConfiguration, C as ClassType, b as CompleteValueConfig, D as DeepMockProxy, l as DeepPartial, E as ErrorValueConfig, F as Func, M as MethodReturns, m as Mutable, N as NextValueConfig, O as OnlyMethodKeysOf, n as OnlyObservablePropsOf, o as OnlyPropsOf, p as Overload, q as Overloads, P as PropStubValue, S as Spy, r as SpyDisposable, s as SpyOptions, t as StrictSpyConfiguration, U as UnstubbedCall, u as UnstubbedCallHandler, V as ValueConfig, c as ValueConfigPerCall, W as WithMockReturnValue } from './types-Br-Usge9.js';
|
|
2
2
|
export { ArgCaptor, AsInstances, AssertMockedOptions, ConstructorMock, ConstructorSpy, FixtureFactory, FlushUntilOptions, IntersectionObserverStubOptions, MediaElementState, MediaElementStub, MediaElementStubOptions, MockDeepOptions, ModuleNamespace, ModuleNamespaceOptions, MutationRecordInit, ObserverGlobal, ObserverInstance, ObserverStub, ObserverStubOptions, ResizeEntryRect, TestRunComparison, TestRunReport, TestRunSummary, asInstance, asInstances, asSpy, assertMocked, captureArg, clearAutoSpy, compareTestRuns, createFixture, createFixtureFactory, createFunctionSpy, createMock, createSpyClass, createSpyFromClass, diffByField, errorHandler, flushEventLoop, flushEventLoopUntil, formatTestRunComparison, intersectionEntry, mockConstructor, mockDeep, moduleNamespace, mutationRecord, narrow, resetAutoSpy, resizeEntry, settleDynamicImport, stubAbortController, stubConstructor, stubIntersectionObserver, stubMediaElement, stubMutationObserver, stubObserver, stubResizeObserver, summarizeTestRun, withOverrides } from './bun.js';
|
|
3
|
-
export { A as AutoMockConfiguration, C as CallbackSubscribable, E as EmissionObserver, a as EmissionOptions, b as EmissionSource, S as SubscribableLike, c as autoMocked, d as createAutoMock, e as expectCompletion, f as expectEmission, g as expectEmissions, h as expectError, i as expectNoEmission, s as setEmissionTimeout } from './expect-emission-
|
|
4
|
-
export { A as AccessorImplementations, R as RestoreProp, c as countMockedProps, m as mockAccessorsProp, a as mockReadonlyProp, b as mockReadonlyPropGetter, d as mockValueProp, r as restoreMockedProps } from './prop-mock-
|
|
3
|
+
export { A as AutoMockConfiguration, C as CallbackSubscribable, E as EmissionObserver, a as EmissionOptions, b as EmissionSource, S as SubscribableLike, c as autoMocked, d as createAutoMock, e as expectCompletion, f as expectEmission, g as expectEmissions, h as expectError, i as expectNoEmission, s as setEmissionTimeout } from './expect-emission-DMx5uXie.js';
|
|
4
|
+
export { A as AccessorImplementations, R as RestoreProp, c as countMockedProps, m as mockAccessorsProp, a as mockReadonlyProp, b as mockReadonlyPropGetter, d as mockValueProp, r as restoreMockedProps } from './prop-mock-DyjtZVoA.js';
|
|
5
5
|
export { d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-B1pqa-Sh.js';
|
|
6
|
-
export { A as AngularValueProvider, a as AutoSpiedInstance, C as ComponentInputs, b as CreateWithAutoSpiesOptions, R as RenderShallowOptions, c as ResourceStatusLike, S as SettleResourceOptions, d as ShallowRender, e as SpyRegistry, f as StableOptions, g as createWithAutoSpies, h as flushEffects, i as injectSpy, p as provideAutoSpy, r as renderShallow, j as runEffect, s as settleResource, k as stable } from './zoneless-
|
|
6
|
+
export { A as AngularValueProvider, a as AutoSpiedInstance, C as ComponentInputs, b as CreateWithAutoSpiesOptions, R as RenderShallowOptions, c as ResourceStatusLike, S as SettleResourceOptions, d as ShallowRender, e as SpyRegistry, f as StableOptions, g as createWithAutoSpies, h as flushEffects, i as injectSpy, p as provideAutoSpy, r as renderShallow, j as runEffect, s as settleResource, k as stable } from './zoneless-CEhs7o9p.js';
|
|
7
7
|
import 'rxjs';
|
|
8
8
|
import 'vitest';
|
|
9
9
|
import '@angular/core';
|
|
@@ -72,6 +72,12 @@ declare function registerDomGlobals(options?: RegisterDomGlobalsOptions): Promis
|
|
|
72
72
|
* implementation. A property the target refuses to accept is skipped rather than fatal — a locked
|
|
73
73
|
* global is not worth failing a whole test run over.
|
|
74
74
|
*
|
|
75
|
+
* Skipped, but **not** in silence when it is one of {@link FORCED_GLOBALS}: those are the five the
|
|
76
|
+
* DOM is useless without, so a refused `document` means the environment came up half-installed and
|
|
77
|
+
* the first spec that touches it reports `document is not defined` — naming neither this helper nor
|
|
78
|
+
* the property that refused. The rest stay quiet, because a host built-in keeping its own
|
|
79
|
+
* implementation is the documented outcome rather than a problem.
|
|
80
|
+
*
|
|
75
81
|
* @example
|
|
76
82
|
* ```ts
|
|
77
83
|
* copyWindowGlobals(dom.window as unknown as Record<string, unknown>, globalThis as Record<string, unknown>);
|
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-IKH4OTMV.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';
|
|
@@ -160,6 +160,7 @@ ${failures.join("\n") || " - (no registrars were configured)"}`,
|
|
|
160
160
|
}
|
|
161
161
|
function copyWindowGlobals(source, target) {
|
|
162
162
|
const keys = [...FORCED_GLOBALS, ...Object.getOwnPropertyNames(source)];
|
|
163
|
+
const refused = [];
|
|
163
164
|
for (const key of keys) {
|
|
164
165
|
if (key.startsWith("_")) {
|
|
165
166
|
continue;
|
|
@@ -170,9 +171,21 @@ function copyWindowGlobals(source, target) {
|
|
|
170
171
|
}
|
|
171
172
|
try {
|
|
172
173
|
Object.defineProperty(target, key, { value, configurable: true, writable: true, enumerable: true });
|
|
173
|
-
} catch {
|
|
174
|
+
} catch (error) {
|
|
175
|
+
if (FORCED_GLOBALS.includes(key)) {
|
|
176
|
+
refused.push(`${key} (${describeError(error)})`);
|
|
177
|
+
}
|
|
174
178
|
}
|
|
175
179
|
}
|
|
180
|
+
if (refused.length === 0) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
console.warn(
|
|
184
|
+
withDocs(
|
|
185
|
+
`[vitest-auto-spy] copyWindowGlobals: the host refused to redefine ${refused.join(", ")}. The DOM is only half-installed, and the failure will arrive later as "document is not defined" or an unrelated jsdom assertion, naming neither this helper nor the property. Something sealed that global before the preload ran.`,
|
|
186
|
+
DOCS_LINKS.bunAngular
|
|
187
|
+
)
|
|
188
|
+
);
|
|
176
189
|
}
|
|
177
190
|
function createJsdomRegistrar(options) {
|
|
178
191
|
return {
|
|
@@ -237,7 +250,14 @@ var AutoSpyInjector = class extends Injector {
|
|
|
237
250
|
tokens() {
|
|
238
251
|
return [...this.#spies.keys()];
|
|
239
252
|
}
|
|
253
|
+
knows(token) {
|
|
254
|
+
return this.#spies.has(token);
|
|
255
|
+
}
|
|
240
256
|
};
|
|
257
|
+
function describeToken(token) {
|
|
258
|
+
const name = Reflect.get(Object(token), "name");
|
|
259
|
+
return typeof name === "string" ? name : String(token);
|
|
260
|
+
}
|
|
241
261
|
function factoryOf(target) {
|
|
242
262
|
const factory = Reflect.get(target, "\u0275fac");
|
|
243
263
|
return typeof factory === "function" ? factory : void 0;
|
|
@@ -252,6 +272,14 @@ function createWithAutoSpies(target, options = {}) {
|
|
|
252
272
|
injector,
|
|
253
273
|
spies: {
|
|
254
274
|
get: (token) => {
|
|
275
|
+
if (!autoSpies.knows(token) && injector.get(token, null, { optional: true }) === null) {
|
|
276
|
+
throw new Error(
|
|
277
|
+
withDocs(
|
|
278
|
+
`[vitest-auto-spy] createWithAutoSpies(${describeToken(target)}).spies.get(${describeToken(token)}): the instance never asked for that token, and nothing in \`providers\` supplies it, so the spy you would get back is not the one it uses. Auto-spied tokens: ${autoSpies.tokens().map(describeToken).join(", ") || "(none)"}.`,
|
|
279
|
+
DOCS_LINKS.angular
|
|
280
|
+
)
|
|
281
|
+
);
|
|
282
|
+
}
|
|
255
283
|
return injector.get(token);
|
|
256
284
|
},
|
|
257
285
|
autoSpiedTokens: () => autoSpies.tokens()
|
package/dist/bun.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { s as SpyOptions, C as ClassType, a as ClassSpyConfiguration, O as OnlyMethodKeysOf, S as Spy, l as DeepPartial, D as DeepMockProxy, F as Func, u as UnstubbedCallHandler, j as AddSpyMethodsByReturnTypes } from './types-
|
|
2
|
-
export { d as AccessorKeysOf, e as AddAccessorsSpies, f as AddCalledWithObservable, g as AddCalledWithPromise, h as AddCalledWithSpyMethods, A as AddObservableSpyMethods, i as AddPromiseSpyMethods, k as AddVoidReturnHelpers, b as CompleteValueConfig, E as ErrorValueConfig, M as MethodReturns, m as Mutable, N as NextValueConfig, n as OnlyObservablePropsOf, o as OnlyPropsOf, p as Overload, q as Overloads, P as PropStubValue, r as SpyDisposable, t as StrictSpyConfiguration, U as UnstubbedCall, V as ValueConfig, c as ValueConfigPerCall, W as WithMockReturnValue } from './types-
|
|
3
|
-
export { A as AutoMockConfiguration, C as CallbackSubscribable, E as EmissionObserver, a as EmissionOptions, b as EmissionSource, S as SubscribableLike, c as autoMocked, d as createAutoMock, e as expectCompletion, f as expectEmission, g as expectEmissions, h as expectError, i as expectNoEmission, s as setEmissionTimeout } from './expect-emission-
|
|
4
|
-
export { A as AccessorImplementations, R as RestoreProp, c as countMockedProps, m as mockAccessorsProp, a as mockReadonlyProp, b as mockReadonlyPropGetter, d as mockValueProp, r as restoreMockedProps } from './prop-mock-
|
|
1
|
+
import { s as SpyOptions, C as ClassType, a as ClassSpyConfiguration, O as OnlyMethodKeysOf, S as Spy, l as DeepPartial, D as DeepMockProxy, F as Func, u as UnstubbedCallHandler, j as AddSpyMethodsByReturnTypes } from './types-Br-Usge9.js';
|
|
2
|
+
export { d as AccessorKeysOf, e as AddAccessorsSpies, f as AddCalledWithObservable, g as AddCalledWithPromise, h as AddCalledWithSpyMethods, A as AddObservableSpyMethods, i as AddPromiseSpyMethods, k as AddVoidReturnHelpers, b as CompleteValueConfig, E as ErrorValueConfig, M as MethodReturns, m as Mutable, N as NextValueConfig, n as OnlyObservablePropsOf, o as OnlyPropsOf, p as Overload, q as Overloads, P as PropStubValue, r as SpyDisposable, t as StrictSpyConfiguration, U as UnstubbedCall, V as ValueConfig, c as ValueConfigPerCall, W as WithMockReturnValue } from './types-Br-Usge9.js';
|
|
3
|
+
export { A as AutoMockConfiguration, C as CallbackSubscribable, E as EmissionObserver, a as EmissionOptions, b as EmissionSource, S as SubscribableLike, c as autoMocked, d as createAutoMock, e as expectCompletion, f as expectEmission, g as expectEmissions, h as expectError, i as expectNoEmission, s as setEmissionTimeout } from './expect-emission-DMx5uXie.js';
|
|
4
|
+
export { A as AccessorImplementations, R as RestoreProp, c as countMockedProps, m as mockAccessorsProp, a as mockReadonlyProp, b as mockReadonlyPropGetter, d as mockValueProp, r as restoreMockedProps } from './prop-mock-DyjtZVoA.js';
|
|
5
5
|
export { d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-B1pqa-Sh.js';
|
|
6
6
|
import { Mock } from 'vitest';
|
|
7
7
|
import 'rxjs';
|
|
@@ -790,6 +790,11 @@ interface AssertMockedOptions {
|
|
|
790
790
|
*
|
|
791
791
|
* Worth naming when the factory stubs part of a module and re-exports the rest: without a list,
|
|
792
792
|
* a factory that lost the one export the test drives still looks mocked.
|
|
793
|
+
*
|
|
794
|
+
* An **empty** list is rejected rather than accepted: `exports: []` — which is what
|
|
795
|
+
* `Object.keys(stubs)` or a filtered constant produces when it comes out empty — used to take the
|
|
796
|
+
* named-exports branch, find nothing to check and return, so the one call in the file whose job
|
|
797
|
+
* is to prove the mock applied proved nothing.
|
|
793
798
|
*/
|
|
794
799
|
exports?: readonly string[];
|
|
795
800
|
}
|
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-IKH4OTMV.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)) {
|
|
@@ -442,6 +442,14 @@ var SILENT_NO_OP_CAUSES = "A `vi.mock()` that does not apply reports nothing: un
|
|
|
442
442
|
var assertMocked = defineHelper((namespace, options = {}) => {
|
|
443
443
|
const target = describeTarget(options.specifier);
|
|
444
444
|
const required = options.exports;
|
|
445
|
+
if (required?.length === 0) {
|
|
446
|
+
throw new Error(
|
|
447
|
+
withDocs(
|
|
448
|
+
`[vitest-auto-spy] assertMocked(${target}): the \`exports\` list is empty, so this call cannot fail and proves nothing. Drop the option to check that at least one export is a mock, or name the exports the test drives.`,
|
|
449
|
+
DOCS_LINKS.moduleMocks
|
|
450
|
+
)
|
|
451
|
+
);
|
|
452
|
+
}
|
|
445
453
|
if (required) {
|
|
446
454
|
const real = required.filter((name) => !isRunnerMock(Reflect.get(namespace, name)));
|
|
447
455
|
if (real.length > 0) {
|
package/dist/console.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as StrictSpyConfiguration, n as OnlyObservablePropsOf, M as MethodReturns, l as DeepPartial, S as Spy, s as SpyOptions } from './types-
|
|
1
|
+
import { t as StrictSpyConfiguration, n as OnlyObservablePropsOf, M as MethodReturns, l as DeepPartial, S as Spy, s as SpyOptions } from './types-Br-Usge9.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Create a fully-typed auto-mock of `T` from its type alone (no class).
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { d as AccessorKeysOf, e as AddAccessorsSpies, f as AddCalledWithObservable, g as AddCalledWithPromise, h as AddCalledWithSpyMethods, A as AddObservableSpyMethods, i as AddPromiseSpyMethods, j as AddSpyMethodsByReturnTypes, k as AddVoidReturnHelpers, a as ClassSpyConfiguration, C as ClassType, b as CompleteValueConfig, D as DeepMockProxy, l as DeepPartial, E as ErrorValueConfig, F as Func, M as MethodReturns, m as Mutable, N as NextValueConfig, O as OnlyMethodKeysOf, n as OnlyObservablePropsOf, o as OnlyPropsOf, p as Overload, q as Overloads, P as PropStubValue, S as Spy, r as SpyDisposable, s as SpyOptions, t as StrictSpyConfiguration, U as UnstubbedCall, u as UnstubbedCallHandler, V as ValueConfig, c as ValueConfigPerCall, W as WithMockReturnValue } from './types-
|
|
1
|
+
export { d as AccessorKeysOf, e as AddAccessorsSpies, f as AddCalledWithObservable, g as AddCalledWithPromise, h as AddCalledWithSpyMethods, A as AddObservableSpyMethods, i as AddPromiseSpyMethods, j as AddSpyMethodsByReturnTypes, k as AddVoidReturnHelpers, a as ClassSpyConfiguration, C as ClassType, b as CompleteValueConfig, D as DeepMockProxy, l as DeepPartial, E as ErrorValueConfig, F as Func, M as MethodReturns, m as Mutable, N as NextValueConfig, O as OnlyMethodKeysOf, n as OnlyObservablePropsOf, o as OnlyPropsOf, p as Overload, q as Overloads, P as PropStubValue, S as Spy, r as SpyDisposable, s as SpyOptions, t as StrictSpyConfiguration, U as UnstubbedCall, u as UnstubbedCallHandler, V as ValueConfig, c as ValueConfigPerCall, W as WithMockReturnValue } from './types-Br-Usge9.js';
|
|
2
2
|
export { ArgCaptor, AsInstances, AssertMockedOptions, ConstructorMock, ConstructorSpy, FixtureFactory, FlushUntilOptions, IntersectionObserverStubOptions, MediaElementState, MediaElementStub, MediaElementStubOptions, MockDeepOptions, ModuleNamespace, ModuleNamespaceOptions, MutationRecordInit, ObserverGlobal, ObserverInstance, ObserverStub, ObserverStubOptions, ResizeEntryRect, TestRunComparison, TestRunReport, TestRunSummary, asInstance, asInstances, asSpy, assertMocked, captureArg, clearAutoSpy, compareTestRuns, createFixture, createFixtureFactory, createFunctionSpy, createMock, createSpyClass, createSpyFromClass, diffByField, errorHandler, flushEventLoop, flushEventLoopUntil, formatTestRunComparison, intersectionEntry, mockConstructor, mockDeep, moduleNamespace, mutationRecord, narrow, resetAutoSpy, resizeEntry, settleDynamicImport, stubAbortController, stubConstructor, stubIntersectionObserver, stubMediaElement, stubMutationObserver, stubObserver, stubResizeObserver, summarizeTestRun, withOverrides } from './bun.js';
|
|
3
|
-
export { A as AutoMockConfiguration, C as CallbackSubscribable, E as EmissionObserver, a as EmissionOptions, b as EmissionSource, S as SubscribableLike, c as autoMocked, d as createAutoMock, e as expectCompletion, f as expectEmission, g as expectEmissions, h as expectError, i as expectNoEmission, s as setEmissionTimeout } from './expect-emission-
|
|
4
|
-
export { A as AccessorImplementations, R as RestoreProp, c as countMockedProps, m as mockAccessorsProp, a as mockReadonlyProp, b as mockReadonlyPropGetter, d as mockValueProp, r as restoreMockedProps } from './prop-mock-
|
|
3
|
+
export { A as AutoMockConfiguration, C as CallbackSubscribable, E as EmissionObserver, a as EmissionOptions, b as EmissionSource, S as SubscribableLike, c as autoMocked, d as createAutoMock, e as expectCompletion, f as expectEmission, g as expectEmissions, h as expectError, i as expectNoEmission, s as setEmissionTimeout } from './expect-emission-DMx5uXie.js';
|
|
4
|
+
export { A as AccessorImplementations, R as RestoreProp, c as countMockedProps, m as mockAccessorsProp, a as mockReadonlyProp, b as mockReadonlyPropGetter, d as mockValueProp, r as restoreMockedProps } from './prop-mock-DyjtZVoA.js';
|
|
5
5
|
export { d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-B1pqa-Sh.js';
|
|
6
6
|
import 'rxjs';
|
|
7
7
|
import 'vitest';
|
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)) {
|
|
@@ -1608,6 +1621,14 @@ var SILENT_NO_OP_CAUSES = "A `vi.mock()` that does not apply reports nothing: un
|
|
|
1608
1621
|
var assertMocked = defineHelper((namespace, options = {}) => {
|
|
1609
1622
|
const target = describeTarget2(options.specifier);
|
|
1610
1623
|
const required = options.exports;
|
|
1624
|
+
if (required?.length === 0) {
|
|
1625
|
+
throw new Error(
|
|
1626
|
+
withDocs(
|
|
1627
|
+
`[vitest-auto-spy] assertMocked(${target}): the \`exports\` list is empty, so this call cannot fail and proves nothing. Drop the option to check that at least one export is a mock, or name the exports the test drives.`,
|
|
1628
|
+
DOCS_LINKS.moduleMocks
|
|
1629
|
+
)
|
|
1630
|
+
);
|
|
1631
|
+
}
|
|
1611
1632
|
if (required) {
|
|
1612
1633
|
const real = required.filter((name) => !isRunnerMock(Reflect.get(namespace, name)));
|
|
1613
1634
|
if (real.length > 0) {
|
package/dist/nestjs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ClassType, S as Spy, a as ClassSpyConfiguration, O as OnlyMethodKeysOf } from './types-
|
|
2
|
-
export { I as InjectionLog, T as TrackInjectionsOptions, a as TrackedProvider, t as trackInjections } from './track-injections-
|
|
1
|
+
import { C as ClassType, S as Spy, a as ClassSpyConfiguration, O as OnlyMethodKeysOf } from './types-Br-Usge9.js';
|
|
2
|
+
export { I as InjectionLog, T as TrackInjectionsOptions, a as TrackedProvider, t as trackInjections } from './track-injections-BQndbppn.js';
|
|
3
3
|
import 'rxjs';
|
|
4
4
|
import 'vitest';
|
|
5
5
|
|
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)) {
|
|
@@ -1948,6 +1961,14 @@ var SILENT_NO_OP_CAUSES = "A `vi.mock()` that does not apply reports nothing: un
|
|
|
1948
1961
|
var assertMocked = defineHelper((namespace, options = {}) => {
|
|
1949
1962
|
const target = describeTarget2(options.specifier);
|
|
1950
1963
|
const required = options.exports;
|
|
1964
|
+
if (required?.length === 0) {
|
|
1965
|
+
throw new Error(
|
|
1966
|
+
withDocs(
|
|
1967
|
+
`[vitest-auto-spy] assertMocked(${target}): the \`exports\` list is empty, so this call cannot fail and proves nothing. Drop the option to check that at least one export is a mock, or name the exports the test drives.`,
|
|
1968
|
+
DOCS_LINKS.moduleMocks
|
|
1969
|
+
)
|
|
1970
|
+
);
|
|
1971
|
+
}
|
|
1951
1972
|
if (required) {
|
|
1952
1973
|
const real = required.filter((name) => !isRunnerMock(Reflect.get(namespace, name)));
|
|
1953
1974
|
if (real.length > 0) {
|
package/dist/node.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { d as AccessorKeysOf, e as AddAccessorsSpies, f as AddCalledWithObservable, g as AddCalledWithPromise, h as AddCalledWithSpyMethods, A as AddObservableSpyMethods, i as AddPromiseSpyMethods, j as AddSpyMethodsByReturnTypes, k as AddVoidReturnHelpers, a as ClassSpyConfiguration, C as ClassType, b as CompleteValueConfig, D as DeepMockProxy, l as DeepPartial, E as ErrorValueConfig, F as Func, M as MethodReturns, m as Mutable, N as NextValueConfig, O as OnlyMethodKeysOf, n as OnlyObservablePropsOf, o as OnlyPropsOf, p as Overload, q as Overloads, P as PropStubValue, S as Spy, r as SpyDisposable, s as SpyOptions, t as StrictSpyConfiguration, U as UnstubbedCall, u as UnstubbedCallHandler, V as ValueConfig, c as ValueConfigPerCall, W as WithMockReturnValue } from './types-
|
|
1
|
+
export { d as AccessorKeysOf, e as AddAccessorsSpies, f as AddCalledWithObservable, g as AddCalledWithPromise, h as AddCalledWithSpyMethods, A as AddObservableSpyMethods, i as AddPromiseSpyMethods, j as AddSpyMethodsByReturnTypes, k as AddVoidReturnHelpers, a as ClassSpyConfiguration, C as ClassType, b as CompleteValueConfig, D as DeepMockProxy, l as DeepPartial, E as ErrorValueConfig, F as Func, M as MethodReturns, m as Mutable, N as NextValueConfig, O as OnlyMethodKeysOf, n as OnlyObservablePropsOf, o as OnlyPropsOf, p as Overload, q as Overloads, P as PropStubValue, S as Spy, r as SpyDisposable, s as SpyOptions, t as StrictSpyConfiguration, U as UnstubbedCall, u as UnstubbedCallHandler, V as ValueConfig, c as ValueConfigPerCall, W as WithMockReturnValue } from './types-Br-Usge9.js';
|
|
2
2
|
export { ArgCaptor, AsInstances, AssertMockedOptions, ConstructorMock, ConstructorSpy, FixtureFactory, FlushUntilOptions, IntersectionObserverStubOptions, MediaElementState, MediaElementStub, MediaElementStubOptions, MockDeepOptions, ModuleNamespace, ModuleNamespaceOptions, MutationRecordInit, ObserverGlobal, ObserverInstance, ObserverStub, ObserverStubOptions, ResizeEntryRect, TestRunComparison, TestRunReport, TestRunSummary, asInstance, asInstances, asSpy, assertMocked, captureArg, clearAutoSpy, compareTestRuns, createFixture, createFixtureFactory, createFunctionSpy, createMock, createSpyClass, createSpyFromClass, diffByField, errorHandler, flushEventLoop, flushEventLoopUntil, formatTestRunComparison, intersectionEntry, mockConstructor, mockDeep, moduleNamespace, mutationRecord, narrow, resetAutoSpy, resizeEntry, settleDynamicImport, stubAbortController, stubConstructor, stubIntersectionObserver, stubMediaElement, stubMutationObserver, stubObserver, stubResizeObserver, summarizeTestRun, withOverrides } from './bun.js';
|
|
3
|
-
export { A as AutoMockConfiguration, C as CallbackSubscribable, E as EmissionObserver, a as EmissionOptions, b as EmissionSource, S as SubscribableLike, c as autoMocked, d as createAutoMock, e as expectCompletion, f as expectEmission, g as expectEmissions, h as expectError, i as expectNoEmission, s as setEmissionTimeout } from './expect-emission-
|
|
4
|
-
export { A as AccessorImplementations, R as RestoreProp, c as countMockedProps, m as mockAccessorsProp, a as mockReadonlyProp, b as mockReadonlyPropGetter, d as mockValueProp, r as restoreMockedProps } from './prop-mock-
|
|
3
|
+
export { A as AutoMockConfiguration, C as CallbackSubscribable, E as EmissionObserver, a as EmissionOptions, b as EmissionSource, S as SubscribableLike, c as autoMocked, d as createAutoMock, e as expectCompletion, f as expectEmission, g as expectEmissions, h as expectError, i as expectNoEmission, s as setEmissionTimeout } from './expect-emission-DMx5uXie.js';
|
|
4
|
+
export { A as AccessorImplementations, R as RestoreProp, c as countMockedProps, m as mockAccessorsProp, a as mockReadonlyProp, b as mockReadonlyPropGetter, d as mockValueProp, r as restoreMockedProps } from './prop-mock-DyjtZVoA.js';
|
|
5
5
|
export { d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-B1pqa-Sh.js';
|
|
6
6
|
import 'rxjs';
|
|
7
7
|
import 'vitest';
|
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-IKH4OTMV.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.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { d as AccessorKeysOf, e as AddAccessorsSpies, f as AddCalledWithObservable, g as AddCalledWithPromise, h as AddCalledWithSpyMethods, A as AddObservableSpyMethods, i as AddPromiseSpyMethods, j as AddSpyMethodsByReturnTypes, k as AddVoidReturnHelpers, a as ClassSpyConfiguration, C as ClassType, b as CompleteValueConfig, D as DeepMockProxy, l as DeepPartial, E as ErrorValueConfig, F as Func, M as MethodReturns, m as Mutable, N as NextValueConfig, O as OnlyMethodKeysOf, n as OnlyObservablePropsOf, o as OnlyPropsOf, p as Overload, q as Overloads, P as PropStubValue, S as Spy, r as SpyDisposable, s as SpyOptions, t as StrictSpyConfiguration, U as UnstubbedCall, u as UnstubbedCallHandler, V as ValueConfig, c as ValueConfigPerCall, W as WithMockReturnValue } from './types-
|
|
1
|
+
export { d as AccessorKeysOf, e as AddAccessorsSpies, f as AddCalledWithObservable, g as AddCalledWithPromise, h as AddCalledWithSpyMethods, A as AddObservableSpyMethods, i as AddPromiseSpyMethods, j as AddSpyMethodsByReturnTypes, k as AddVoidReturnHelpers, a as ClassSpyConfiguration, C as ClassType, b as CompleteValueConfig, D as DeepMockProxy, l as DeepPartial, E as ErrorValueConfig, F as Func, M as MethodReturns, m as Mutable, N as NextValueConfig, O as OnlyMethodKeysOf, n as OnlyObservablePropsOf, o as OnlyPropsOf, p as Overload, q as Overloads, P as PropStubValue, S as Spy, r as SpyDisposable, s as SpyOptions, t as StrictSpyConfiguration, U as UnstubbedCall, u as UnstubbedCallHandler, V as ValueConfig, c as ValueConfigPerCall, W as WithMockReturnValue } from './types-Br-Usge9.js';
|
|
2
2
|
export { ArgCaptor, AsInstances, AssertMockedOptions, ConstructorMock, ConstructorSpy, FixtureFactory, FlushUntilOptions, IntersectionObserverStubOptions, MediaElementState, MediaElementStub, MediaElementStubOptions, MockDeepOptions, ModuleNamespace, ModuleNamespaceOptions, MutationRecordInit, ObserverGlobal, ObserverInstance, ObserverStub, ObserverStubOptions, ResizeEntryRect, TestRunComparison, TestRunReport, TestRunSummary, asInstance, asInstances, asSpy, assertMocked, captureArg, clearAutoSpy, compareTestRuns, createFixture, createFixtureFactory, createFunctionSpy, createMock, createSpyClass, createSpyFromClass, diffByField, errorHandler, flushEventLoop, flushEventLoopUntil, formatTestRunComparison, intersectionEntry, mockConstructor, mockDeep, moduleNamespace, mutationRecord, narrow, resetAutoSpy, resizeEntry, settleDynamicImport, stubAbortController, stubConstructor, stubIntersectionObserver, stubMediaElement, stubMutationObserver, stubObserver, stubResizeObserver, summarizeTestRun, withOverrides } from './bun.js';
|
|
3
|
-
export { A as AutoMockConfiguration, C as CallbackSubscribable, E as EmissionObserver, a as EmissionOptions, b as EmissionSource, S as SubscribableLike, c as autoMocked, d as createAutoMock, e as expectCompletion, f as expectEmission, g as expectEmissions, h as expectError, i as expectNoEmission, s as setEmissionTimeout } from './expect-emission-
|
|
4
|
-
export { A as AccessorImplementations, R as RestoreProp, c as countMockedProps, m as mockAccessorsProp, a as mockReadonlyProp, b as mockReadonlyPropGetter, d as mockValueProp, r as restoreMockedProps } from './prop-mock-
|
|
3
|
+
export { A as AutoMockConfiguration, C as CallbackSubscribable, E as EmissionObserver, a as EmissionOptions, b as EmissionSource, S as SubscribableLike, c as autoMocked, d as createAutoMock, e as expectCompletion, f as expectEmission, g as expectEmissions, h as expectError, i as expectNoEmission, s as setEmissionTimeout } from './expect-emission-DMx5uXie.js';
|
|
4
|
+
export { A as AccessorImplementations, R as RestoreProp, c as countMockedProps, m as mockAccessorsProp, a as mockReadonlyProp, b as mockReadonlyPropGetter, d as mockValueProp, r as restoreMockedProps } from './prop-mock-DyjtZVoA.js';
|
|
5
5
|
export { d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-B1pqa-Sh.js';
|
|
6
6
|
import 'rxjs';
|
|
7
7
|
import 'vitest';
|
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-IKH4OTMV.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/rxjs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Observable, ReplaySubject } from 'rxjs';
|
|
2
|
-
import { V as ValueConfig } from './types-
|
|
3
|
-
export { A as AddObservableSpyMethods, b as CompleteValueConfig, E as ErrorValueConfig, N as NextValueConfig, c as ValueConfigPerCall } from './types-
|
|
2
|
+
import { V as ValueConfig } from './types-Br-Usge9.js';
|
|
3
|
+
export { A as AddObservableSpyMethods, b as CompleteValueConfig, E as ErrorValueConfig, N as NextValueConfig, c as ValueConfigPerCall } from './types-Br-Usge9.js';
|
|
4
4
|
import 'vitest';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/rxjs.js
CHANGED
|
@@ -40,11 +40,18 @@ function mergeSubjectWithDefaultValues(subject, valuesConfigs) {
|
|
|
40
40
|
return true;
|
|
41
41
|
}),
|
|
42
42
|
// Map each remaining entry to its emission: a value, an error, or nothing.
|
|
43
|
+
//
|
|
44
|
+
// The guards test *presence* (`'value' in config`), and that is the whole check: an entry that
|
|
45
|
+
// carries the key is an emission whatever the value is. Adding `&& config.value` on top — which
|
|
46
|
+
// is what stood here — silently dropped `{ value: false }`, `{ value: 0 }`, `{ value: '' }` and
|
|
47
|
+
// `{ value: null }`, i.e. an ordinary boolean or counter stream. Nothing was emitted, nothing
|
|
48
|
+
// was reported, and the symptom arrived a test away as a timed-out `expectEmission` or as a
|
|
49
|
+
// component still holding its initial state.
|
|
43
50
|
concatMap((config) => {
|
|
44
|
-
if (isNextValueConfig(config)
|
|
51
|
+
if (isNextValueConfig(config)) {
|
|
45
52
|
return config.delay ? of(config.value).pipe(delay(config.delay)) : of(config.value);
|
|
46
53
|
}
|
|
47
|
-
if (isErrorConfig(config)
|
|
54
|
+
if (isErrorConfig(config)) {
|
|
48
55
|
return config.delay ? timer(config.delay).pipe(switchMap(() => throwError(() => config.errorValue))) : throwError(() => config.errorValue);
|
|
49
56
|
}
|
|
50
57
|
return EMPTY;
|
package/dist/setup.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { vi } from 'vitest';
|
|
2
|
-
import { u as UnstubbedCallHandler } from './types-
|
|
3
|
-
import { R as RestoreProp } from './prop-mock-
|
|
2
|
+
import { u as UnstubbedCallHandler } from './types-Br-Usge9.js';
|
|
3
|
+
import { R as RestoreProp } from './prop-mock-DyjtZVoA.js';
|
|
4
4
|
export { d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-B1pqa-Sh.js';
|
|
5
5
|
import 'rxjs';
|
|
6
6
|
|
|
@@ -348,6 +348,14 @@ interface SetupAutoSpyOptions {
|
|
|
348
348
|
* and through those whole component trees. Turning this on prunes what each file added once the
|
|
349
349
|
* file is over, and keeps what the file inherited. See {@link trackMockRegistry}, and
|
|
350
350
|
* {@link keepMockRegistered} for the one case the split gets wrong on its own.
|
|
351
|
+
*
|
|
352
|
+
* It also guards the mocks it keeps. A registered mock is reachable by `vi.resetAllMocks()` as
|
|
353
|
+
* well as by `vi.clearAllMocks()`, and `mockReset` puts an implementation back only when it was
|
|
354
|
+
* passed to `vi.fn(implementation)` — a chained `.mockReturnValue(…)` or `.mockReturnThis()` is
|
|
355
|
+
* simply lost. With `isolate: false` that surfaces as a failure in a later file, inside
|
|
356
|
+
* application code, blaming a component for a shared double some other spec reset. The
|
|
357
|
+
* implementation each long-lived mock carried when it was classified is therefore remembered and
|
|
358
|
+
* put back before a test that has lost it. See {@link restoreLongLivedImplementations}.
|
|
351
359
|
*/
|
|
352
360
|
pruneMockRegistry?: boolean;
|
|
353
361
|
/**
|
|
@@ -573,6 +581,17 @@ declare function captureMockRegistry(): Set<unknown> | undefined;
|
|
|
573
581
|
* ```
|
|
574
582
|
*/
|
|
575
583
|
declare function keepMockRegistered<T>(mock: T): T;
|
|
584
|
+
/**
|
|
585
|
+
* Put back the implementation of every long-lived mock that has lost one, and report how many.
|
|
586
|
+
*
|
|
587
|
+
* The repair for a `vi.resetAllMocks()` — or a `mockReset: true` — reaching across files: it walks
|
|
588
|
+
* only the mocks that carried an implementation when they were classified, and only replaces one
|
|
589
|
+
* that is now missing, so a mock a test deliberately re-implements is left as the test left it.
|
|
590
|
+
*
|
|
591
|
+
* Installed on `beforeEach` by {@link trackMockRegistry}; call it directly to repair at some other
|
|
592
|
+
* moment.
|
|
593
|
+
*/
|
|
594
|
+
declare function restoreLongLivedImplementations(): number;
|
|
576
595
|
/**
|
|
577
596
|
* Mark everything currently in the registry as long-lived.
|
|
578
597
|
*
|
|
@@ -747,4 +766,4 @@ declare function restoreTimerGlobals(): void;
|
|
|
747
766
|
/** The names this module watches — exported for the diagnostics that report what went missing. */
|
|
748
767
|
declare function getWatchedTimerGlobals(): string[];
|
|
749
768
|
|
|
750
|
-
export { BLOCKED_FETCH_MESSAGE, BLOCKED_XHR_MESSAGE, type BlockNetworkOptions, type CountingClock, type CountingClockOptions, type DuplicateCopiesReaction, type FakeTimersConfig, type GlobalPatchReaction, type PerTestHandle, type RejectionHost, type SchedulerHost, type SetupAutoSpyOptions, type StopTrackingRejections, type StopTrackingTimers, type StrayRejection, type SystemTime, type XhrBlockMode, advanceTimers, blockNetwork, cancelStrayTimers, captureMockRegistry, countStrayRejections, countStrayTimers, flushStrayRejections, getMockRegistrySize, getWatchedTimerGlobals, guardGlobalPatches, installPerTest, keepMockRegistered, keepRegisteredMocks, mockNow, mockSystemTime, pruneMockRegistry, registerFocusMatchers, resetMockRegistryTracking, restoreTimerGlobals, setupAutoSpy, setupFakeTimers, trackMockRegistry, trackStrayRejections, trackStrayTimers, useCountingClock, withSystemTime };
|
|
769
|
+
export { BLOCKED_FETCH_MESSAGE, BLOCKED_XHR_MESSAGE, type BlockNetworkOptions, type CountingClock, type CountingClockOptions, type DuplicateCopiesReaction, type FakeTimersConfig, type GlobalPatchReaction, type PerTestHandle, type RejectionHost, type SchedulerHost, type SetupAutoSpyOptions, type StopTrackingRejections, type StopTrackingTimers, type StrayRejection, type SystemTime, type XhrBlockMode, advanceTimers, blockNetwork, cancelStrayTimers, captureMockRegistry, countStrayRejections, countStrayTimers, flushStrayRejections, getMockRegistrySize, getWatchedTimerGlobals, guardGlobalPatches, installPerTest, keepMockRegistered, keepRegisteredMocks, mockNow, mockSystemTime, pruneMockRegistry, registerFocusMatchers, resetMockRegistryTracking, restoreLongLivedImplementations, restoreTimerGlobals, setupAutoSpy, setupFakeTimers, trackMockRegistry, trackStrayRejections, trackStrayTimers, useCountingClock, withSystemTime };
|
package/dist/setup.js
CHANGED
|
@@ -205,9 +205,32 @@ ${describeHookTimeout(timeouts)}`);
|
|
|
205
205
|
var registry;
|
|
206
206
|
var captureAttempted = false;
|
|
207
207
|
var longLived = /* @__PURE__ */ new WeakSet();
|
|
208
|
+
var rememberedImplementations = [];
|
|
209
|
+
var implementationsChecked = /* @__PURE__ */ new WeakSet();
|
|
208
210
|
function isWeakKey(value) {
|
|
209
211
|
return typeof value === "function" || typeof value === "object" && value !== null;
|
|
210
212
|
}
|
|
213
|
+
function isMockImplementation(value) {
|
|
214
|
+
return typeof value === "function";
|
|
215
|
+
}
|
|
216
|
+
function hasImplementationControls(value) {
|
|
217
|
+
const getter = Reflect.get(value, "getMockImplementation");
|
|
218
|
+
const setter = Reflect.get(value, "mockImplementation");
|
|
219
|
+
return typeof getter === "function" && typeof setter === "function";
|
|
220
|
+
}
|
|
221
|
+
function rememberImplementation(mock) {
|
|
222
|
+
if (implementationsChecked.has(mock)) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
implementationsChecked.add(mock);
|
|
226
|
+
if (!hasImplementationControls(mock)) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
const implementation = mock.getMockImplementation();
|
|
230
|
+
if (isMockImplementation(implementation)) {
|
|
231
|
+
rememberedImplementations.push({ mock, implementation });
|
|
232
|
+
}
|
|
233
|
+
}
|
|
211
234
|
function captureMockRegistry() {
|
|
212
235
|
if (captureAttempted) {
|
|
213
236
|
return registry;
|
|
@@ -238,9 +261,20 @@ function captureMockRegistry() {
|
|
|
238
261
|
function keepMockRegistered(mock) {
|
|
239
262
|
if (isWeakKey(mock)) {
|
|
240
263
|
longLived.add(mock);
|
|
264
|
+
rememberImplementation(mock);
|
|
241
265
|
}
|
|
242
266
|
return mock;
|
|
243
267
|
}
|
|
268
|
+
function restoreLongLivedImplementations() {
|
|
269
|
+
let restored = 0;
|
|
270
|
+
for (const remembered of rememberedImplementations) {
|
|
271
|
+
if (remembered.mock.getMockImplementation() === void 0) {
|
|
272
|
+
remembered.mock.mockImplementation(remembered.implementation);
|
|
273
|
+
restored += 1;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return restored;
|
|
277
|
+
}
|
|
244
278
|
function keepRegisteredMocks() {
|
|
245
279
|
registry?.forEach((mock) => {
|
|
246
280
|
keepMockRegistered(mock);
|
|
@@ -264,6 +298,9 @@ function trackMockRegistry() {
|
|
|
264
298
|
captureMockRegistry();
|
|
265
299
|
keepRegisteredMocks();
|
|
266
300
|
});
|
|
301
|
+
beforeEach(() => {
|
|
302
|
+
restoreLongLivedImplementations();
|
|
303
|
+
});
|
|
267
304
|
afterAll(() => {
|
|
268
305
|
pruneMockRegistry();
|
|
269
306
|
});
|
|
@@ -275,6 +312,8 @@ function resetMockRegistryTracking() {
|
|
|
275
312
|
registry = void 0;
|
|
276
313
|
captureAttempted = false;
|
|
277
314
|
longLived = /* @__PURE__ */ new WeakSet();
|
|
315
|
+
rememberedImplementations = [];
|
|
316
|
+
implementationsChecked = /* @__PURE__ */ new WeakSet();
|
|
278
317
|
}
|
|
279
318
|
|
|
280
319
|
// src/lib/network-stub.ts
|
|
@@ -829,4 +868,4 @@ function registerFocusMatchers() {
|
|
|
829
868
|
}
|
|
830
869
|
useVitestAdapter();
|
|
831
870
|
|
|
832
|
-
export { BLOCKED_FETCH_MESSAGE, BLOCKED_XHR_MESSAGE, advanceTimers, blockNetwork, cancelStrayTimers, captureMockRegistry, countStrayRejections, countStrayTimers, flushStrayRejections, getMockRegistrySize, getWatchedTimerGlobals, guardGlobalPatches, installPerTest, keepMockRegistered, keepRegisteredMocks, mockNow, mockSystemTime, pruneMockRegistry, registerFocusMatchers, resetMockRegistryTracking, restoreTimerGlobals, setupAutoSpy, setupFakeTimers, trackMockRegistry, trackStrayRejections, trackStrayTimers, useCountingClock, withSystemTime };
|
|
871
|
+
export { BLOCKED_FETCH_MESSAGE, BLOCKED_XHR_MESSAGE, advanceTimers, blockNetwork, cancelStrayTimers, captureMockRegistry, countStrayRejections, countStrayTimers, flushStrayRejections, getMockRegistrySize, getWatchedTimerGlobals, guardGlobalPatches, installPerTest, keepMockRegistered, keepRegisteredMocks, mockNow, mockSystemTime, pruneMockRegistry, registerFocusMatchers, resetMockRegistryTracking, restoreLongLivedImplementations, restoreTimerGlobals, setupAutoSpy, setupFakeTimers, trackMockRegistry, trackStrayRejections, trackStrayTimers, useCountingClock, withSystemTime };
|
package/dist/svelte.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { d as AccessorKeysOf, e as AddAccessorsSpies, f as AddCalledWithObservable, g as AddCalledWithPromise, h as AddCalledWithSpyMethods, A as AddObservableSpyMethods, i as AddPromiseSpyMethods, j as AddSpyMethodsByReturnTypes, k as AddVoidReturnHelpers, a as ClassSpyConfiguration, C as ClassType, b as CompleteValueConfig, D as DeepMockProxy, l as DeepPartial, E as ErrorValueConfig, F as Func, M as MethodReturns, m as Mutable, N as NextValueConfig, O as OnlyMethodKeysOf, n as OnlyObservablePropsOf, o as OnlyPropsOf, p as Overload, q as Overloads, P as PropStubValue, S as Spy, r as SpyDisposable, s as SpyOptions, t as StrictSpyConfiguration, U as UnstubbedCall, u as UnstubbedCallHandler, V as ValueConfig, c as ValueConfigPerCall, W as WithMockReturnValue } from './types-
|
|
1
|
+
export { d as AccessorKeysOf, e as AddAccessorsSpies, f as AddCalledWithObservable, g as AddCalledWithPromise, h as AddCalledWithSpyMethods, A as AddObservableSpyMethods, i as AddPromiseSpyMethods, j as AddSpyMethodsByReturnTypes, k as AddVoidReturnHelpers, a as ClassSpyConfiguration, C as ClassType, b as CompleteValueConfig, D as DeepMockProxy, l as DeepPartial, E as ErrorValueConfig, F as Func, M as MethodReturns, m as Mutable, N as NextValueConfig, O as OnlyMethodKeysOf, n as OnlyObservablePropsOf, o as OnlyPropsOf, p as Overload, q as Overloads, P as PropStubValue, S as Spy, r as SpyDisposable, s as SpyOptions, t as StrictSpyConfiguration, U as UnstubbedCall, u as UnstubbedCallHandler, V as ValueConfig, c as ValueConfigPerCall, W as WithMockReturnValue } from './types-Br-Usge9.js';
|
|
2
2
|
export { ArgCaptor, AsInstances, AssertMockedOptions, ConstructorMock, ConstructorSpy, FixtureFactory, FlushUntilOptions, IntersectionObserverStubOptions, MediaElementState, MediaElementStub, MediaElementStubOptions, MockDeepOptions, ModuleNamespace, ModuleNamespaceOptions, MutationRecordInit, ObserverGlobal, ObserverInstance, ObserverStub, ObserverStubOptions, ResizeEntryRect, TestRunComparison, TestRunReport, TestRunSummary, asInstance, asInstances, asSpy, assertMocked, captureArg, clearAutoSpy, compareTestRuns, createFixture, createFixtureFactory, createFunctionSpy, createMock, createSpyClass, createSpyFromClass, diffByField, errorHandler, flushEventLoop, flushEventLoopUntil, formatTestRunComparison, intersectionEntry, mockConstructor, mockDeep, moduleNamespace, mutationRecord, narrow, resetAutoSpy, resizeEntry, settleDynamicImport, stubAbortController, stubConstructor, stubIntersectionObserver, stubMediaElement, stubMutationObserver, stubObserver, stubResizeObserver, summarizeTestRun, withOverrides } from './bun.js';
|
|
3
|
-
export { A as AutoMockConfiguration, C as CallbackSubscribable, E as EmissionObserver, a as EmissionOptions, b as EmissionSource, S as SubscribableLike, c as autoMocked, d as createAutoMock, e as expectCompletion, f as expectEmission, g as expectEmissions, h as expectError, i as expectNoEmission, s as setEmissionTimeout } from './expect-emission-
|
|
4
|
-
export { A as AccessorImplementations, R as RestoreProp, c as countMockedProps, m as mockAccessorsProp, a as mockReadonlyProp, b as mockReadonlyPropGetter, d as mockValueProp, r as restoreMockedProps } from './prop-mock-
|
|
3
|
+
export { A as AutoMockConfiguration, C as CallbackSubscribable, E as EmissionObserver, a as EmissionOptions, b as EmissionSource, S as SubscribableLike, c as autoMocked, d as createAutoMock, e as expectCompletion, f as expectEmission, g as expectEmissions, h as expectError, i as expectNoEmission, s as setEmissionTimeout } from './expect-emission-DMx5uXie.js';
|
|
4
|
+
export { A as AccessorImplementations, R as RestoreProp, c as countMockedProps, m as mockAccessorsProp, a as mockReadonlyProp, b as mockReadonlyPropGetter, d as mockValueProp, r as restoreMockedProps } from './prop-mock-DyjtZVoA.js';
|
|
5
5
|
export { d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-B1pqa-Sh.js';
|
|
6
6
|
import 'rxjs';
|
|
7
7
|
import 'vitest';
|
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-IKH4OTMV.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';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Observable, Subject } from 'rxjs';
|
|
2
|
-
import { Mock } from 'vitest';
|
|
2
|
+
import { Mock, MockInstance } from 'vitest';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Public type surface (mirrors `@hirez_io/auto-spies-core`).
|
|
@@ -177,8 +177,19 @@ interface AddVoidReturnHelpers {
|
|
|
177
177
|
* `ReturnType extends Promise<…>` distributes over the `infer`-bound parameter, and distributing
|
|
178
178
|
* over `never` yields `never` — the same collapse by a different route, for a method whose
|
|
179
179
|
* return type does resolve, to `never`.
|
|
180
|
+
* 3. **The mock surface is `MockInstance`, not `Mock`.** `Mock` is `Mock<Procedure>` here, and
|
|
181
|
+
* `Procedure` is `(...args: any[]) => any` — so it contributed a call signature that swallows
|
|
182
|
+
* anything. An intersection accepts a call matching *either* member, so on a double of
|
|
183
|
+
* `read(key: string)` all three of `read(1)`, `read('ok', 'extra')` and `read()` compiled, none
|
|
184
|
+
* of them compiles on the real instance, and the spec stayed green while calling the double the
|
|
185
|
+
* way production code never could. `MockInstance` is the same surface *without* the call and
|
|
186
|
+
* construct signatures, so the only call signature left is `Method`'s own. Nothing about
|
|
187
|
+
* configuring the double changed: `MockInstance` defaults to `Procedure` too, so
|
|
188
|
+
* `mockReturnValue` / `mockImplementation` stay as lenient as they were. Side effect worth
|
|
189
|
+
* knowing: with one call signature instead of two, `expectTypeOf(spy.method).parameters` and
|
|
190
|
+
* `.returns` resolve instead of collapsing to `never`.
|
|
180
191
|
*/
|
|
181
|
-
type AddSpyMethodsByReturnTypes<Method extends Func> = Method &
|
|
192
|
+
type AddSpyMethodsByReturnTypes<Method extends Func> = Method & MockInstance & (Method extends (...args: any[]) => infer ReturnType ? [ReturnType] extends [Promise<infer P>] ? AddCalledWithPromise<Method, P> & AddPromiseSpyMethods<P> : [ReturnType] extends [Observable<infer O>] ? AddCalledWithObservable<Method, O> & AddObservableSpyMethods<O> : [ReturnType] extends [void] ? AddCalledWithSpyMethods<Method> & AddVoidReturnHelpers : AddCalledWithSpyMethods<Method> : AddCalledWithSpyMethods<Method>);
|
|
182
193
|
/**
|
|
183
194
|
* Every call signature of `F`, in declaration order.
|
|
184
195
|
*
|
package/dist/vue.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { S as Spy, C as ClassType, a as ClassSpyConfiguration, O as OnlyMethodKeysOf } from './types-
|
|
2
|
-
export { d as AccessorKeysOf, e as AddAccessorsSpies, f as AddCalledWithObservable, g as AddCalledWithPromise, h as AddCalledWithSpyMethods, A as AddObservableSpyMethods, i as AddPromiseSpyMethods, j as AddSpyMethodsByReturnTypes, k as AddVoidReturnHelpers, b as CompleteValueConfig, D as DeepMockProxy, l as DeepPartial, E as ErrorValueConfig, F as Func, M as MethodReturns, m as Mutable, N as NextValueConfig, n as OnlyObservablePropsOf, o as OnlyPropsOf, p as Overload, q as Overloads, P as PropStubValue, r as SpyDisposable, s as SpyOptions, t as StrictSpyConfiguration, U as UnstubbedCall, u as UnstubbedCallHandler, V as ValueConfig, c as ValueConfigPerCall, W as WithMockReturnValue } from './types-
|
|
1
|
+
import { S as Spy, C as ClassType, a as ClassSpyConfiguration, O as OnlyMethodKeysOf } from './types-Br-Usge9.js';
|
|
2
|
+
export { d as AccessorKeysOf, e as AddAccessorsSpies, f as AddCalledWithObservable, g as AddCalledWithPromise, h as AddCalledWithSpyMethods, A as AddObservableSpyMethods, i as AddPromiseSpyMethods, j as AddSpyMethodsByReturnTypes, k as AddVoidReturnHelpers, b as CompleteValueConfig, D as DeepMockProxy, l as DeepPartial, E as ErrorValueConfig, F as Func, M as MethodReturns, m as Mutable, N as NextValueConfig, n as OnlyObservablePropsOf, o as OnlyPropsOf, p as Overload, q as Overloads, P as PropStubValue, r as SpyDisposable, s as SpyOptions, t as StrictSpyConfiguration, U as UnstubbedCall, u as UnstubbedCallHandler, V as ValueConfig, c as ValueConfigPerCall, W as WithMockReturnValue } from './types-Br-Usge9.js';
|
|
3
3
|
export { ArgCaptor, AsInstances, AssertMockedOptions, ConstructorMock, ConstructorSpy, FixtureFactory, FlushUntilOptions, IntersectionObserverStubOptions, MediaElementState, MediaElementStub, MediaElementStubOptions, MockDeepOptions, ModuleNamespace, ModuleNamespaceOptions, MutationRecordInit, ObserverGlobal, ObserverInstance, ObserverStub, ObserverStubOptions, ResizeEntryRect, TestRunComparison, TestRunReport, TestRunSummary, asInstance, asInstances, asSpy, assertMocked, captureArg, clearAutoSpy, compareTestRuns, createFixture, createFixtureFactory, createFunctionSpy, createMock, createSpyClass, createSpyFromClass, diffByField, errorHandler, flushEventLoop, flushEventLoopUntil, formatTestRunComparison, intersectionEntry, mockConstructor, mockDeep, moduleNamespace, mutationRecord, narrow, resetAutoSpy, resizeEntry, settleDynamicImport, stubAbortController, stubConstructor, stubIntersectionObserver, stubMediaElement, stubMutationObserver, stubObserver, stubResizeObserver, summarizeTestRun, withOverrides } from './bun.js';
|
|
4
|
-
export { A as AutoMockConfiguration, C as CallbackSubscribable, E as EmissionObserver, a as EmissionOptions, b as EmissionSource, S as SubscribableLike, c as autoMocked, d as createAutoMock, e as expectCompletion, f as expectEmission, g as expectEmissions, h as expectError, i as expectNoEmission, s as setEmissionTimeout } from './expect-emission-
|
|
5
|
-
export { A as AccessorImplementations, R as RestoreProp, c as countMockedProps, m as mockAccessorsProp, a as mockReadonlyProp, b as mockReadonlyPropGetter, d as mockValueProp, r as restoreMockedProps } from './prop-mock-
|
|
4
|
+
export { A as AutoMockConfiguration, C as CallbackSubscribable, E as EmissionObserver, a as EmissionOptions, b as EmissionSource, S as SubscribableLike, c as autoMocked, d as createAutoMock, e as expectCompletion, f as expectEmission, g as expectEmissions, h as expectError, i as expectNoEmission, s as setEmissionTimeout } from './expect-emission-DMx5uXie.js';
|
|
5
|
+
export { A as AccessorImplementations, R as RestoreProp, c as countMockedProps, m as mockAccessorsProp, a as mockReadonlyProp, b as mockReadonlyPropGetter, d as mockValueProp, r as restoreMockedProps } from './prop-mock-DyjtZVoA.js';
|
|
6
6
|
export { d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-B1pqa-Sh.js';
|
|
7
7
|
import 'rxjs';
|
|
8
8
|
import 'vitest';
|
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-IKH4OTMV.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';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InjectionToken, Injector, ProviderToken, Provider, Type, InputSignalWithTransform, InputSignal, ModelSignal, EnvironmentProviders, EffectRef } from '@angular/core';
|
|
2
|
-
import { A as AutoMockConfiguration } from './expect-emission-
|
|
3
|
-
import { S as Spy, C as ClassType, s as SpyOptions, a as ClassSpyConfiguration, O as OnlyMethodKeysOf, l as DeepPartial } from './types-
|
|
4
|
-
import './prop-mock-
|
|
2
|
+
import { A as AutoMockConfiguration } from './expect-emission-DMx5uXie.js';
|
|
3
|
+
import { S as Spy, C as ClassType, s as SpyOptions, a as ClassSpyConfiguration, O as OnlyMethodKeysOf, l as DeepPartial } from './types-Br-Usge9.js';
|
|
4
|
+
import './prop-mock-DyjtZVoA.js';
|
|
5
5
|
import { ComponentFixture } from '@angular/core/testing';
|
|
6
6
|
|
|
7
7
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest-auto-spy",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0",
|
|
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",
|