vitest-auto-spy 3.17.0 → 3.18.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 CHANGED
@@ -2020,6 +2020,56 @@ and type the value against the member's **own** type. For a signal-valued member
2020
2020
  `mockSignalProp(service, 'state', initial)` over `gettersToSpyOn`: a spied getter returns `undefined`
2021
2021
  until configured, a real signal keeps everything downstream reactive.
2022
2022
 
2023
+ **A spec importing `@ngneat/spectator`** is on a package whose repository is a 404 and which does not
2024
+ resolve on Angular 22 (it imports `@angular/platform-browser-dynamic/testing` without declaring it).
2025
+ `createSpyObject` → `createSpyFromClass`, `mockProvider` → `provideAutoSpy`, `spectator.inject` →
2026
+ `injectSpy`, `SpyObject<T>` → `Spy<T>`, `createComponentFactory` → `renderShallow`. There is no
2027
+ replacement here for `spectator.query`, the event helpers or the DOM matchers — leave those on
2028
+ `@testing-library/angular` rather than inventing an equivalent. Full mapping:
2029
+ [Migrating from @ngneat/spectator](https://asdalexey.github.io/vitest-auto-spy/migrating-spectator).
2030
+
2031
+ A suite coming off [`@suites/unit`](https://github.com/suites-dev/suites) maps one to one:
2032
+ `TestBed.solitary(S).compile()` → `createNestUnit(S)`, `TestBed.sociable(S).expose(D).compile()` →
2033
+ `createNestUnit(S, { expose: [D] })`, `unitRef.get` → `spies.get`, `.final(v)` →
2034
+ `{ provide, useValue }`, and the `await` goes away because the graph is built synchronously. The one
2035
+ thing to check by hand after the swap: Suites' double answers every property name, so a spec that
2036
+ stubbed a since-renamed method was passing over nothing and will now fail. Full mapping:
2037
+ <https://asdalexey.github.io/vitest-auto-spy/migrating-suites>.
2038
+
2039
+ - **`renderShallow` has no single speed number, and quoting one is a bug.** Per render it ranges
2040
+ from 1.2× (no children) to 16.2× (400 child instances) — `docs-site/core/performance.md`,
2041
+ measured 2026-08-26. Per spec file, where imports and the `TestBed` module are also on the clock,
2042
+ the published conversion is 1.7× over three specs with one of them a 0.8× regression. The two are
2043
+ not interchangeable: the per-render ratio is the upper bound on what a file can gain. Any surface
2044
+ that mentions the helper's speed quotes the range and links to
2045
+ `/core/performance#_2-rendering-the-child-subtree`. A figure of **4.1×** appears in
2046
+ `PRIORITIES.md` and is backed by nothing in this repository — do not publish it until someone
2047
+ produces the measurement.
2048
+ - **Competitor defects are quoted from the published tarball, with a file, a line and a date.** The
2049
+ `@testing-library/angular` `createMock` claims in `docs-site/comparison.md` are pinned to
2050
+ `fesm2022/testing-library-angular-vitest-utils.mjs` lines 14 and 18 at 19.4.2. Re-`npm pack` and
2051
+ re-read before restating them against a new version; the "Where the numbers come from" box records
2052
+ each re-verification date rather than replacing the previous one.
2053
+
2054
+ `node:test` keeps every `mock.fn()` in one process-wide `MockTracker` for the life of the process.
2055
+ On a long suite that is real memory — 20 000 spies of a 10-method class retained 124.5 MB on
2056
+ Node v24.19.0. `trackNodeMocks()` puts this library's spies on a tracker it owns and replaces it per
2057
+ test: 5.9 MB for the same run, against a 5.4 MB baseline.
2058
+
2059
+ \```ts
2060
+ import { before } from 'node:test';
2061
+ import { trackNodeMocks } from 'vitest-auto-spy/node';
2062
+
2063
+ before(() => trackNodeMocks()); // opt-in, idempotent, returns the undo
2064
+
2065
+ // by hand, for a concurrent suite: pruneNodeMocks() → how many were dropped; countNodeMocks() → how many are held
2066
+ \```
2067
+
2068
+ It never calls `mock.reset()` — that would restore and forget the `mock.fn()` the spec made itself —
2069
+ and it never throws: the class is reached through the undocumented `mock.constructor`, so the
2070
+ constructed tracker is probed first and any failure leaves spies on `node:test`'s own tracker.
2071
+ Spies created **before** the call stay there too. `mock.reset()` in `afterEach` is the fallback.
2072
+
2023
2073
  ---
2024
2074
 
2025
2075
  ## 14. `fakeAsync` needs `vitest-auto-spy/zone`
package/README.md CHANGED
@@ -49,13 +49,19 @@ identical API, with **RxJS** spies and **Angular / NestJS / React / Vue·Pinia /
49
49
  - 🎯 Return-type-aware helpers — sync, `Promise`, and `Observable` all get the right API
50
50
  - 🔀 `calledWith` / `mustBeCalledWith` argument dispatch
51
51
  - 📡 First-class RxJS `Observable` spying (`nextWith`, `nextWithValues`, `throwWith`, …)
52
- - ⚙️ Getter / setter spies via `accessorSpies`
52
+ - ⚙️ Getter / setter spies via `accessorSpies` — **including on Bun**, where `bun:test`'s own `spyOn(obj, 'prop', 'get')` throws _"does not support accessor properties yet"_ (verified on Bun 1.4.0); no library that generates a double from a class or a type has accessor spies on any runner
53
53
  - 🧰 DI & mocking utilities — `provideAutoSpy` / `injectSpy` (Angular, NestJS, Vue), `createFunctionSpy`, `mockReadonlyProp` for signals
54
- - ⚡ Angular speed & zoneless helpers — `renderShallow` (**1.7×** on real component specs), `createWithAutoSpies`, `stable` / `flushEffects`, `settleResource` for `httpResource()`, `toHaveSignalValue`, per-file `TestBed` timings
54
+ - ⚡ Angular speed & zoneless helpers — `renderShallow` (**1.7×** across three converted specs of a real suite; per render, **1.2×** on a childless leaf up to **16.2×** on a 400-child tree — [both measurements below](#shallow-component-rendering)), `createWithAutoSpies`, `stable` / `flushEffects`, `settleResource` for `httpResource()`, `toHaveSignalValue`, per-file `TestBed` timings
55
+ - **`node:test` stops retaining every spy.** Node's built-in runner keeps every `mock.fn()` in one
56
+ process-wide `MockTracker` and has no way to drop a single entry, so a long suite accumulates every
57
+ spy it ever made along with every argument they recorded. `trackNodeMocks()` gives this library a
58
+ tracker of its own and replaces it after each test — 124.5 MB retained down to 5.9 MB on 20 000
59
+ spies of a 10-method class (Node v24.19.0, `--expose-gc`, 5.4 MB baseline). It never calls
60
+ `mock.reset()`, so a `mock.fn()` your spec made by hand is untouched.
55
61
  - 🌐 `httpResource()` and `HttpClient` in two lines — `provideHttpTesting()` + `await expectRequest(url).flush(body)` does the tick, the controller, the `expectOne`, the flush **and the settling**, so `resource.value()` reads on the next line; `@angular/common` stays an optional peer, confined to the `/angular-http` entry
56
62
  - 🪆 NestJS units from their own DI metadata — `createNestUnit(Target, { expose, providers })`, the solitary / sociable model of `@suites/unit` with the real prototype behind every spy and no `@nestjs` dependency
57
63
  - 🧱 The providers a testing module cannot reach — `overrideComponentProvider` (which verifies the override actually applied), `provideAutoSpyForToken`, `assertNgModuleScopes`, `assertComponentDefIntact`, `createDirectiveHost`
58
- - 🚨 Failures that used to be silence — `enableAngularDiagnostics()` for dead NgModule imports, dead `schemas`, an unspied provider and unflushed HTTP requests; `trackInjections` for which collaborators the code actually asked for
64
+ - 🚨 Failures that used to be silence — `enableAngularDiagnostics()` for dead NgModule imports, dead `schemas`, an unspied provider and unflushed HTTP requests; `trackInjections` for which collaborators the code actually asked for. `injectSpy` already warns once per token when DI handed back a real instance, naming the token and the missing `provideAutoSpy` — where Spectator's `inject<T>(token): SpyObject<T>` types **every** token as a spy whether it was mocked or not, so the compiler hides the same mistake
59
65
  - 🔒 [Strict doubles](#strict-doubles--fail-on-a-method-nobody-configured) — `strict: true` / `onUnstubbedCall` fail on a method nobody configured, naming the class, the method and the arguments instead of answering `undefined`
60
66
  - ♻️ `using spy = createSpyFromClass(X)` — every double carries `[Symbol.dispose]`, so the `afterEach` that only reset one spy can go
61
67
  - 📡 Observable assertions that fail on silence — `expectEmission` / `expectEmissions` / `expectNoEmission` / `expectCompletion` / `expectError`, no rxjs required, Angular `output()` included
@@ -112,8 +118,10 @@ identical API, with **RxJS** spies and **Angular / NestJS / React / Vue·Pinia /
112
118
  - [Runtimes](#runtimes)
113
119
  - [Angular on Bun (`bun:test`)](#angular-on-bun-buntest)
114
120
  - [Comparison](#comparison)
121
+ - [@testing-library/angular /vitest-utils](#testing-libraryangular-vitest-utils)
115
122
  - [Migrating from jest-auto-spies](#migrating-from-jest-auto-spies)
116
123
  - [Migrating from jasmine-auto-spies](#migrating-from-jasmine-auto-spies)
124
+ - [Migrating from @ngneat/spectator](https://asdalexey.github.io/vitest-auto-spy/migrating-spectator)
117
125
  - [Configuration](#configuration)
118
126
  - [Spying instance-assigned callables (`signal()`, arrow props, `signalStore()`)](#spying-instance-assigned-callables-signal-arrow-props-signalstore)
119
127
  - [Strict doubles — fail on a method nobody configured](#strict-doubles--fail-on-a-method-nobody-configured)
@@ -929,7 +937,7 @@ Node / Bun / React / Vue project pulls **neither rxjs nor Angular into its runti
929
937
  | `vitest-auto-spy/angular-http` | `provideHttpTesting`, `expectRequest`, `expectNoRequest`, `verifyNoPendingRequests` — the `httpResource()` / `HttpClient` recipe in two lines, settling included | `@angular/common` | ✅ |
930
938
  | `vitest-auto-spy/bun` | the same core, driven by Bun's `bun:test` mocks | `bun:test` | ✅ |
931
939
  | `vitest-auto-spy/bun-angular` | Angular's `TestBed` under `bun test` — DOM, JIT `templateUrl` resolution and a zoneless environment, from one preload | `bun:test`, `@angular/core` | ✅ |
932
- | `vitest-auto-spy/node` | the same core, driven by `node:test`'s `mock.fn()` | `node:test` | ✅ |
940
+ | `vitest-auto-spy/node` | the same core, driven by `node:test`'s `mock.fn()`, plus `trackNodeMocks()` — a private `MockTracker` so dropped spies are actually freed | `node:test` | ✅ |
933
941
  | `vitest-auto-spy/nestjs` | `provideAutoSpy`, `injectSpy` for `Test.createTestingModule` | — (your `@nestjs/*`) | ✅ |
934
942
  | `vitest-auto-spy/react` | the core, with a natural import for React Testing Library suites | — (your `react`) | ✅ |
935
943
  | `vitest-auto-spy/vue` | `provideAutoSpy` for `global.provide` + Pinia store spying | — (your `vue`/`pinia`) | ✅ |
@@ -1070,6 +1078,7 @@ Full recipe, including building your own preload:
1070
1078
  | [@bugsplat/vitest-auto-spies](https://www.npmjs.com/package/@bugsplat/vitest-auto-spies) | ✅ | ✅ | Vitest only | Same class-based API **plus** Bun & `node:test`, [type-only `createAutoMock`](#auto-mock-by-type-no-class-needed), framework recipes (Angular/NestJS/React/Vue/Svelte), console spies, and **zero runtime deps** (it depends on `@hirez_io/auto-spies-core`) |
1071
1079
  | [vitest-mock-extended](https://www.npmjs.com/package/vitest-mock-extended) | ❌ (Proxy) | ❌ | Vitest | Return-type ergonomics **and** reading a real class (we also ship a Proxy mode: [`createAutoMock`](#auto-mock-by-type-no-class-needed)) |
1072
1080
  | [@golevelup/ts-vitest](https://www.npmjs.com/package/@golevelup/ts-vitest) | partial | ❌ | Vitest | Typed `Promise`/`Observable` helpers + explicit class→spy + `mustBeCalledWith` |
1081
+ | [@testing-library/angular](https://www.npmjs.com/package/@testing-library/angular) | ✅ | ❌ | Vitest · Jest | Its `/vitest-utils` `createMock` is the same eager prototype walk, minus two things — verified in the 19.4.2 tarball on 2026-09-02, [below](#testing-libraryangular-vitest-utils) |
1073
1082
  | [sinon](https://www.npmjs.com/package/sinon) | ❌ (manual) | ❌ | Any | Auto-generated + fully typed vs. manual + loosely typed |
1074
1083
 
1075
1084
  **The pitch:** the only auto-spy library that reads a **class** and gives a **fully-typed** spy of
@@ -1079,6 +1088,26 @@ across any Vitest-compatible runtime and framework.
1079
1088
  Feature-by-feature breakdown, and where another library is the better answer:
1080
1089
  [Comparison](https://asdalexey.github.io/vitest-auto-spy/comparison).
1081
1090
 
1091
+ ### @testing-library/angular /vitest-utils
1092
+
1093
+ Usually filed as complementary — its rendering API genuinely is a different discipline — but its
1094
+ `/vitest-utils` entry point exports `createMock` / `provideMock`, which do the same job as
1095
+ `createSpyFromClass` / `provideAutoSpy`. Reading the published 19.4.2 tarball on **2026-09-02**,
1096
+ `fesm2022/testing-library-angular-vitest-utils.mjs`:
1097
+
1098
+ - **Accessors are skipped silently** (line 14): the walk assigns a mock only when
1099
+ `typeof descriptor?.value === 'function'`, and a getter's descriptor has no `value`. So a
1100
+ service's `get isLoggedIn()` is simply absent from the double, while its `Mock<T>` type —
1101
+ `T & { [K in keyof T]: T[K] & Mock }` — types it as callable anyway.
1102
+ - **No `Object.prototype` guard** (line 18): `mockFunctions(Object.getPrototypeOf(proto))` recurses
1103
+ until the prototype is `null`, so `hasOwnProperty`, `toString`, `valueOf` and `isPrototypeOf` end
1104
+ up as `vi.fn()` on the double.
1105
+
1106
+ It is also the only library in this field with **zoneless support** — a `./zoneless` entry point
1107
+ since 19.2.0 (2026-03-17), present in the tarball's `exports` map. That is a real point in its
1108
+ favour. Full write-up, including ng-mocks and Spectator:
1109
+ [Comparison → Angular](https://asdalexey.github.io/vitest-auto-spy/comparison#angular).
1110
+
1082
1111
  ## Migrating from jest-auto-spies
1083
1112
 
1084
1113
  The public API is intentionally identical. In most projects the migration is a
@@ -1188,6 +1217,19 @@ arrives with a `{ get: vi.fn(), post: vi.fn() }` literal per double and up to th
1188
1217
  [After Angular's refactor-jasmine-vitest](https://asdalexey.github.io/vitest-auto-spy/migrating-angular-schematic),
1189
1218
  with the schematic's real output beside `createSpyFromClass(Api)`.
1190
1219
 
1220
+ A suite coming off [`@ngneat/spectator`](https://www.npmjs.com/package/@ngneat/spectator) — 739 852
1221
+ downloads a month on a package whose repository returns 404 and which fails to resolve on a clean
1222
+ Angular 22 install — has its own page,
1223
+ [Migrating from @ngneat/spectator](https://asdalexey.github.io/vitest-auto-spy/migrating-spectator),
1224
+ with the `createSpyObject` → `createSpyFromClass` and `mockProvider` → `provideAutoSpy` mapping, and
1225
+ an honest account of the component-rendering half this library does not replace.
1226
+
1227
+ Coming from [`@suites/unit`](https://github.com/suites-dev/suites)? `TestBed.solitary(S).compile()`
1228
+ is `createNestUnit(S)` and `TestBed.sociable(S).expose(D).compile()` is
1229
+ `createNestUnit(S, { expose: [D] })`, minus the `await` — the whole mapping, including what each side
1230
+ refuses, is in
1231
+ [Migrating from @suites/unit](https://asdalexey.github.io/vitest-auto-spy/migrating-suites).
1232
+
1191
1233
  ## Configuration
1192
1234
 
1193
1235
  ```ts
@@ -1662,6 +1704,26 @@ pays where there is a real child tree to skip** — the seven untouched files in
1662
1704
  by ±10%, which is this suite's run-to-run noise, so the two wins are outside it and the one
1663
1705
  regression is only just outside.
1664
1706
 
1707
+ **Why 1.7× and not more.** That row is a whole spec file's wall clock — imports, the `TestBed`
1708
+ module, the assertions — of which rendering is only a part. Isolated to the render itself, the
1709
+ saving tracks the size of the subtree removed, measured on 2026-08-26 on a component holding two
1710
+ `@for` tables whose row count is varied:
1711
+
1712
+ | Child instances | `TestBed.createComponent` | `renderShallow` | Ratio |
1713
+ | --------------: | ------------------------: | --------------: | ----: |
1714
+ | 0 | 0.65 ms | 0.55 ms | 1.2× |
1715
+ | 10 | 1.00 ms | 0.55 ms | 1.8× |
1716
+ | 100 | 2.72 ms | 0.48 ms | 5.7× |
1717
+ | 400 | 8.52 ms | 0.53 ms | 16.2× |
1718
+
1719
+ `renderShallow` is flat at ~0.5 ms because it never builds the subtree; `createComponent` scales
1720
+ linearly with it. So there is no single "renderShallow is N× faster" number — a leaf component has
1721
+ nothing to save, and a table or a dashboard is an order of magnitude. Treat the ratios as the
1722
+ result, not the absolute times, and pick files to convert with the diagnostics below rather than by
1723
+ guessing. `keepTemplate: true` is the middle rung — the component's own template with an empty
1724
+ subtree, 1.933 ms → 1.074 ms (1.8×), measured 2026-08-30. Full write-up:
1725
+ [Performance](https://asdalexey.github.io/vitest-auto-spy/core/performance#_2-rendering-the-child-subtree).
1726
+
1665
1727
  Use [the diagnostics](#where-a-spec-spends-its-time) to find the files worth converting rather than
1666
1728
  guessing: across those ten files `TestBed` accounted for 820 ms of 3231 ms (25%), but per file the
1667
1729
  share ranged from 13% to 66%.
@@ -2118,6 +2180,7 @@ single-purpose utility you can pick up independently — they all ride on the sa
2118
2180
  | `setupAngularTestEnv(opts)` | `/angular` | Zone and zoneless spec files in one worker, switching platforms per file |
2119
2181
  | `restoreTimerGlobals()` | `/setup` | Put back timer globals that uninstalling the fakes deleted rather than restored |
2120
2182
  | `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)) |
2183
+ | `trackNodeMocks()` / `pruneNodeMocks()` / `countNodeMocks()` | `/node` | Give this library its own `node:test` `MockTracker` so a dropped spy is freed — 21× less retained heap; sweep by hand, and read the count back |
2121
2184
  | `errorHandler` | core | The `mustBeCalledWith` argument-mismatch reporter — swap it to customize failure output |
2122
2185
 
2123
2186
  A taste of the DI pair — provide the spy, inject it back fully typed:
@@ -2339,6 +2402,30 @@ grows by hundreds of megabytes with no plateau, the first evaluation writes one
2339
2402
  naming the version, both exits and the opt-out (`angularBuildHint: false`) — see
2340
2403
  [the Angular page](https://asdalexey.github.io/vitest-auto-spy/adapters/angular#when-the-unit-test-build-has-code-splitting-off).
2341
2404
 
2405
+ #### `node:test` retains every mock
2406
+
2407
+ Node's runner registers every `mock.fn()` in a module-level `MockTracker` and keeps it for the life
2408
+ of the process; nothing removes one entry, and `mock.reset()` — the only thing that empties the list
2409
+ — restores and forgets the mocks your spec made by hand along with the library's.
2410
+
2411
+ `trackNodeMocks()` sidesteps that. The library creates its spies on a `MockTracker` it owns and
2412
+ replaces that tracker after every test, so the retired one is collected with everything in it.
2413
+ Measured on Node v24.19.0, 20 000 spies of a 10-method class across 20 tests: **124.5 MB → 5.9 MB**
2414
+ (5.4 MB baseline). It is opt-in, idempotent, reversible, and a no-op on any runtime that will not
2415
+ give up the class — spies keep going where they go today.
2416
+
2417
+ ```js
2418
+ import { before } from 'node:test';
2419
+ import { trackNodeMocks } from 'vitest-auto-spy/node';
2420
+
2421
+ before(() => {
2422
+ trackNodeMocks();
2423
+ });
2424
+ ```
2425
+
2426
+ `mock.reset()` in `afterEach` remains the fallback for a suite that would rather not call anything.
2427
+ Vitest and Bun drop their own registries between files, so none of this applies to them.
2428
+
2342
2429
  ## Fake timers
2343
2430
 
2344
2431
  ```ts
package/dist/angular.d.ts CHANGED
@@ -1,10 +1,10 @@
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-T3bgwkwb.js';
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-D_hHdObW.js';
2
2
  import { InjectionToken, Provider, Type, Signal, WritableSignal } from '@angular/core';
3
3
  import { TestAPI } from 'vitest';
4
- import { C as ClassType, S as Spy, c as ClassSpyConfiguration, O as OnlyMethodKeysOf, j as AddSpyMethodsByReturnTypes } from './types-jaazRXzU.js';
5
- export { I as InjectionLog, T as TrackInjectionsOptions, a as TrackedProvider, t as trackInjections } from './track-injections-B3FT649L.js';
6
- 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-BMs7lihn.js';
7
- 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-CQkhGiYJ.js';
4
+ import { C as ClassType, S as Spy, j as ClassSpyConfiguration, O as OnlyMethodKeysOf, g as AddSpyMethodsByReturnTypes } from './types-BvbrSBUX.js';
5
+ export { I as InjectionLog, T as TrackInjectionsOptions, a as TrackedProvider, t as trackInjections } from './track-injections-CzzXQwTl.js';
6
+ 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-DDtfdw9e.js';
7
+ 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-C-IjL1J2.js';
8
8
  import '@angular/core/testing';
9
9
  import 'rxjs';
10
10
 
@@ -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 AddThrowHelper, l as AddVoidReturnHelpers, c as ClassSpyConfiguration, C as ClassType, a as CompleteValueConfig, D as DeepMockProxy, m as DeepPartial, E as ErrorValueConfig, F as Func, M as MethodReturns, n as Mutable, N as NextValueConfig, O as OnlyMethodKeysOf, o as OnlyObservablePropsOf, p as OnlyPropsOf, q as Overload, r as Overloads, P as PropStubValue, S as Spy, s as SpyDisposable, t as SpyOptions, u as StrictSpyConfiguration, U as UnstubbedCall, v as UnstubbedCallHandler, V as ValueConfig, b as ValueConfigPerCall, W as WithMockReturnValue } from './types-jaazRXzU.js';
1
+ export { A as AccessorKeysOf, a as AddAccessorsSpies, b as AddCalledWithObservable, c as AddCalledWithPromise, d as AddCalledWithSpyMethods, e as AddObservableSpyMethods, f as AddPromiseSpyMethods, g as AddSpyMethodsByReturnTypes, h as AddThrowHelper, i as AddVoidReturnHelpers, j as ClassSpyConfiguration, C as ClassType, k 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, v as ValueConfigPerCall, W as WithMockReturnValue } from './types-BvbrSBUX.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-CQkhGiYJ.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-BMs7lihn.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-C-IjL1J2.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-DDtfdw9e.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-T3bgwkwb.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-D_hHdObW.js';
7
7
  import 'rxjs';
8
8
  import 'vitest';
9
9
  import '@angular/core';
package/dist/bun.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { t as SpyOptions, C as ClassType, c as ClassSpyConfiguration, O as OnlyMethodKeysOf, S as Spy, m as DeepPartial, D as DeepMockProxy, F as Func, v as UnstubbedCallHandler, j as AddSpyMethodsByReturnTypes } from './types-jaazRXzU.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 AddThrowHelper, l as AddVoidReturnHelpers, a as CompleteValueConfig, E as ErrorValueConfig, M as MethodReturns, n as Mutable, N as NextValueConfig, o as OnlyObservablePropsOf, p as OnlyPropsOf, q as Overload, r as Overloads, P as PropStubValue, s as SpyDisposable, u as StrictSpyConfiguration, U as UnstubbedCall, V as ValueConfig, b as ValueConfigPerCall, W as WithMockReturnValue } from './types-jaazRXzU.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-CQkhGiYJ.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-BMs7lihn.js';
1
+ import { s as SpyOptions, C as ClassType, j as ClassSpyConfiguration, O as OnlyMethodKeysOf, S as Spy, l as DeepPartial, D as DeepMockProxy, F as Func, u as UnstubbedCallHandler, g as AddSpyMethodsByReturnTypes } from './types-BvbrSBUX.js';
2
+ export { A as AccessorKeysOf, a as AddAccessorsSpies, b as AddCalledWithObservable, c as AddCalledWithPromise, d as AddCalledWithSpyMethods, e as AddObservableSpyMethods, f as AddPromiseSpyMethods, h as AddThrowHelper, i as AddVoidReturnHelpers, k 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, v as ValueConfigPerCall, W as WithMockReturnValue } from './types-BvbrSBUX.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-C-IjL1J2.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-DDtfdw9e.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';
package/dist/console.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { j as AddSpyMethodsByReturnTypes } from './types-jaazRXzU.js';
1
+ import { g as AddSpyMethodsByReturnTypes } from './types-BvbrSBUX.js';
2
2
  import 'rxjs';
3
3
  import 'vitest';
4
4
 
@@ -1,4 +1,4 @@
1
- import { u as StrictSpyConfiguration, o as OnlyObservablePropsOf, M as MethodReturns, m as DeepPartial, S as Spy, t as SpyOptions } from './types-jaazRXzU.js';
1
+ import { t as StrictSpyConfiguration, n as OnlyObservablePropsOf, M as MethodReturns, l as DeepPartial, S as Spy, s as SpyOptions } from './types-BvbrSBUX.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 AddThrowHelper, l as AddVoidReturnHelpers, c as ClassSpyConfiguration, C as ClassType, a as CompleteValueConfig, D as DeepMockProxy, m as DeepPartial, E as ErrorValueConfig, F as Func, M as MethodReturns, n as Mutable, N as NextValueConfig, O as OnlyMethodKeysOf, o as OnlyObservablePropsOf, p as OnlyPropsOf, q as Overload, r as Overloads, P as PropStubValue, S as Spy, s as SpyDisposable, t as SpyOptions, u as StrictSpyConfiguration, U as UnstubbedCall, v as UnstubbedCallHandler, V as ValueConfig, b as ValueConfigPerCall, W as WithMockReturnValue } from './types-jaazRXzU.js';
1
+ export { A as AccessorKeysOf, a as AddAccessorsSpies, b as AddCalledWithObservable, c as AddCalledWithPromise, d as AddCalledWithSpyMethods, e as AddObservableSpyMethods, f as AddPromiseSpyMethods, g as AddSpyMethodsByReturnTypes, h as AddThrowHelper, i as AddVoidReturnHelpers, j as ClassSpyConfiguration, C as ClassType, k 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, v as ValueConfigPerCall, W as WithMockReturnValue } from './types-BvbrSBUX.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-CQkhGiYJ.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-BMs7lihn.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-C-IjL1J2.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-DDtfdw9e.js';
5
5
  export { d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-B1pqa-Sh.js';
6
6
  import 'rxjs';
7
7
  import 'vitest';
@@ -1,6 +1,6 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { Mock } from 'vitest';
3
- import { F as Func, j as AddSpyMethodsByReturnTypes, i as AddPromiseSpyMethods, A as AddObservableSpyMethods, s as SpyDisposable } from './types-jaazRXzU.js';
3
+ import { F as Func, g as AddSpyMethodsByReturnTypes, f as AddPromiseSpyMethods, e as AddObservableSpyMethods, r as SpyDisposable } from './types-BvbrSBUX.js';
4
4
 
5
5
  /**
6
6
  * Install the `.and`, `.calls` and `.withArgs` namespaces on every spy built afterwards.
package/dist/jasmine.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { JasmineSpy, JasmineMethodSpy } from './jasmine-compat.js';
2
2
  export { JasmineAccessorSpies, JasmineAccessorSpy, JasmineAnd, JasmineCallInfo, JasmineCalls, JasmineNamespaces, JasmineStrategies, JasmineWithArgsAnd, JasmineWithArgsSync, enableJasmineCompat } from './jasmine-compat.js';
3
- import { C as ClassType, c as ClassSpyConfiguration, O as OnlyMethodKeysOf, F as Func } from './types-jaazRXzU.js';
4
- export { o as OnlyObservablePropsOf, p as OnlyPropsOf } from './types-jaazRXzU.js';
3
+ import { C as ClassType, j as ClassSpyConfiguration, O as OnlyMethodKeysOf, F as Func } from './types-BvbrSBUX.js';
4
+ export { n as OnlyObservablePropsOf, o as OnlyPropsOf } from './types-BvbrSBUX.js';
5
5
  import { expect } from 'vitest';
6
6
  import 'rxjs';
7
7
 
package/dist/nestjs.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as ClassType, S as Spy, c as ClassSpyConfiguration, O as OnlyMethodKeysOf } from './types-jaazRXzU.js';
2
- export { I as InjectionLog, T as TrackInjectionsOptions, a as TrackedProvider, t as trackInjections } from './track-injections-B3FT649L.js';
1
+ import { C as ClassType, S as Spy, j as ClassSpyConfiguration, O as OnlyMethodKeysOf } from './types-BvbrSBUX.js';
2
+ export { I as InjectionLog, T as TrackInjectionsOptions, a as TrackedProvider, t as trackInjections } from './track-injections-CzzXQwTl.js';
3
3
  import 'rxjs';
4
4
  import 'vitest';
5
5
 
package/dist/node.cjs CHANGED
@@ -214,6 +214,99 @@ function createNodeMockAdapter(nodeTest) {
214
214
  );
215
215
  }
216
216
 
217
+ // src/lib/node-mock-tracker.ts
218
+ var host;
219
+ var owned;
220
+ var created = 0;
221
+ var sweepInstalled = false;
222
+ function asNodeTestApi(tracker) {
223
+ return tracker;
224
+ }
225
+ function probeTracker(candidate) {
226
+ const create = Reflect.get(candidate, "fn");
227
+ if (typeof create !== "function") {
228
+ return void 0;
229
+ }
230
+ const probe = Reflect.apply(create, candidate, []);
231
+ if (typeof probe !== "function") {
232
+ return void 0;
233
+ }
234
+ probe();
235
+ const calls = Reflect.get(Object(Reflect.get(probe, "mock")), "calls");
236
+ return Array.isArray(calls) && calls.length === 1 ? asNodeTestApi(candidate) : void 0;
237
+ }
238
+ function constructPrivateTracker() {
239
+ const runtime = host;
240
+ if (runtime === void 0) {
241
+ return void 0;
242
+ }
243
+ try {
244
+ const Tracker = Reflect.get(runtime.mock, "constructor");
245
+ return typeof Tracker === "function" ? probeTracker(Object(Reflect.construct(Tracker, []))) : void 0;
246
+ } catch {
247
+ return void 0;
248
+ }
249
+ }
250
+ var stopTracking = () => {
251
+ owned = void 0;
252
+ created = 0;
253
+ };
254
+ var stopNothing = () => void 0;
255
+ function installSweep() {
256
+ const runtime = host;
257
+ if (sweepInstalled || runtime?.afterEach === void 0) {
258
+ return;
259
+ }
260
+ sweepInstalled = true;
261
+ runtime.afterEach(() => {
262
+ pruneNodeMocks();
263
+ });
264
+ }
265
+ function createSwappableNodeTracker(nodeTest) {
266
+ host = nodeTest;
267
+ owned = void 0;
268
+ created = 0;
269
+ return {
270
+ fn: (implementation) => {
271
+ const tracker = owned;
272
+ if (tracker === void 0) {
273
+ return nodeTest.mock.fn(implementation);
274
+ }
275
+ created += 1;
276
+ return tracker.fn(implementation);
277
+ }
278
+ };
279
+ }
280
+ function pruneNodeMocks() {
281
+ if (owned === void 0) {
282
+ return 0;
283
+ }
284
+ const fresh = constructPrivateTracker();
285
+ if (fresh === void 0) {
286
+ return 0;
287
+ }
288
+ const dropped = created;
289
+ owned = fresh;
290
+ created = 0;
291
+ return dropped;
292
+ }
293
+ function trackNodeMocks() {
294
+ if (owned !== void 0) {
295
+ return stopTracking;
296
+ }
297
+ const tracker = constructPrivateTracker();
298
+ if (tracker === void 0) {
299
+ return stopNothing;
300
+ }
301
+ owned = tracker;
302
+ created = 0;
303
+ installSweep();
304
+ return stopTracking;
305
+ }
306
+ function countNodeMocks() {
307
+ return owned === void 0 ? 0 : created;
308
+ }
309
+
217
310
  // src/lib/spy-mark.ts
218
311
  var AUTO_SPY_MARK = /* @__PURE__ */ Symbol.for("vitest-auto-spy.mock");
219
312
  var DEEP_CHILDREN = /* @__PURE__ */ Symbol.for("vitest-auto-spy.deepChildren");
@@ -278,13 +371,13 @@ function createAccessorsSpies(autoSpy, gettersToSpyOn, settersToSpyOn) {
278
371
 
279
372
  // src/lib/dispose-symbol.ts
280
373
  var NODE_DISPOSE_KEY = "nodejs.dispose";
281
- function installDisposeSymbol(host) {
282
- const existing = Reflect.get(host, "dispose");
374
+ function installDisposeSymbol(host2) {
375
+ const existing = Reflect.get(host2, "dispose");
283
376
  if (typeof existing === "symbol") {
284
377
  return existing;
285
378
  }
286
379
  const shim = Symbol.for(NODE_DISPOSE_KEY);
287
- Object.defineProperty(host, "dispose", { value: shim, enumerable: false, configurable: true, writable: false });
380
+ Object.defineProperty(host2, "dispose", { value: shim, enumerable: false, configurable: true, writable: false });
288
381
  return shim;
289
382
  }
290
383
  var DISPOSE = installDisposeSymbol(Symbol);
@@ -538,8 +631,8 @@ function readDefiner(candidate) {
538
631
  }
539
632
  return define;
540
633
  }
541
- function findHelperDefiner(host) {
542
- const index = Reflect.get(host, "__vitest_index__");
634
+ function findHelperDefiner(host2) {
635
+ const index = Reflect.get(host2, "__vitest_index__");
543
636
  const namespace = typeof index === "object" && index !== null ? Reflect.get(index, "vi") : void 0;
544
637
  return readDefiner(namespace);
545
638
  }
@@ -783,15 +876,15 @@ function ensureCalledWithObject(state, chain) {
783
876
  if (existing) {
784
877
  return existing;
785
878
  }
786
- const created = { argsToValuesMap: new ArgsMap() };
787
- state[chain] = created;
788
- return created;
879
+ const created2 = { argsToValuesMap: new ArgsMap() };
880
+ state[chain] = created2;
881
+ return created2;
789
882
  }
790
883
  var FunctionSpyInternals = class {
791
- constructor(state, valueContainer, host, dispatch, recorder) {
884
+ constructor(state, valueContainer, host2, dispatch, recorder) {
792
885
  this.state = state;
793
886
  this.valueContainer = valueContainer;
794
- this.host = host;
887
+ this.host = host2;
795
888
  this.dispatch = dispatch;
796
889
  this.recorder = recorder;
797
890
  this.observable = void 0;
@@ -2270,9 +2363,9 @@ function stateOf(element, duration) {
2270
2363
  if (existing) {
2271
2364
  return existing;
2272
2365
  }
2273
- const created = { ...DEFAULT_STATE, duration };
2274
- states.set(element, created);
2275
- return created;
2366
+ const created2 = { ...DEFAULT_STATE, duration };
2367
+ states.set(element, created2);
2368
+ return created2;
2276
2369
  }
2277
2370
  var ANNOUNCEMENTS = [
2278
2371
  (next) => next.duration === void 0 ? void 0 : "durationchange",
@@ -2527,7 +2620,7 @@ function resizeEntry(target, rect = {}) {
2527
2620
  }
2528
2621
 
2529
2622
  // src/node.ts
2530
- registerMockAdapter(createNodeMockAdapter(node_test.mock));
2623
+ registerMockAdapter(createNodeMockAdapter(createSwappableNodeTracker({ mock: node_test.mock, afterEach: node_test.afterEach })));
2531
2624
 
2532
2625
  exports.asInstance = asInstance;
2533
2626
  exports.asInstances = asInstances;
@@ -2538,6 +2631,7 @@ exports.captureArg = captureArg;
2538
2631
  exports.clearAutoSpy = clearAutoSpy;
2539
2632
  exports.compareTestRuns = compareTestRuns;
2540
2633
  exports.countMockedProps = countMockedProps;
2634
+ exports.countNodeMocks = countNodeMocks;
2541
2635
  exports.createAutoMock = createAutoMock;
2542
2636
  exports.createFixture = createFixture;
2543
2637
  exports.createFixtureFactory = createFixtureFactory;
@@ -2567,6 +2661,7 @@ exports.mockValueProp = mockValueProp;
2567
2661
  exports.moduleNamespace = moduleNamespace;
2568
2662
  exports.mutationRecord = mutationRecord;
2569
2663
  exports.narrow = narrow;
2664
+ exports.pruneNodeMocks = pruneNodeMocks;
2570
2665
  exports.resetAutoSpy = resetAutoSpy;
2571
2666
  exports.resizeEntry = resizeEntry;
2572
2667
  exports.restoreMockedProps = restoreMockedProps;
@@ -2580,4 +2675,5 @@ exports.stubMutationObserver = stubMutationObserver;
2580
2675
  exports.stubObserver = stubObserver;
2581
2676
  exports.stubResizeObserver = stubResizeObserver;
2582
2677
  exports.summarizeTestRun = summarizeTestRun;
2678
+ exports.trackNodeMocks = trackNodeMocks;
2583
2679
  exports.withOverrides = withOverrides;
package/dist/node.d.cts CHANGED
@@ -17,6 +17,7 @@ export declare const captureArg: typeof Entry.captureArg;
17
17
  export declare const clearAutoSpy: typeof Entry.clearAutoSpy;
18
18
  export declare const compareTestRuns: typeof Entry.compareTestRuns;
19
19
  export declare const countMockedProps: typeof Entry.countMockedProps;
20
+ export declare const countNodeMocks: typeof Entry.countNodeMocks;
20
21
  export declare const createAutoMock: typeof Entry.createAutoMock;
21
22
  export declare const createFixture: typeof Entry.createFixture;
22
23
  export declare const createFixtureFactory: typeof Entry.createFixtureFactory;
@@ -46,6 +47,7 @@ export declare const mockValueProp: typeof Entry.mockValueProp;
46
47
  export declare const moduleNamespace: typeof Entry.moduleNamespace;
47
48
  export declare const mutationRecord: typeof Entry.mutationRecord;
48
49
  export declare const narrow: typeof Entry.narrow;
50
+ export declare const pruneNodeMocks: typeof Entry.pruneNodeMocks;
49
51
  export declare const resetAutoSpy: typeof Entry.resetAutoSpy;
50
52
  export declare const resizeEntry: typeof Entry.resizeEntry;
51
53
  export declare const restoreMockedProps: typeof Entry.restoreMockedProps;
@@ -59,4 +61,5 @@ export declare const stubMutationObserver: typeof Entry.stubMutationObserver;
59
61
  export declare const stubObserver: typeof Entry.stubObserver;
60
62
  export declare const stubResizeObserver: typeof Entry.stubResizeObserver;
61
63
  export declare const summarizeTestRun: typeof Entry.summarizeTestRun;
64
+ export declare const trackNodeMocks: typeof Entry.trackNodeMocks;
62
65
  export declare const withOverrides: typeof Entry.withOverrides;
package/dist/node.d.ts CHANGED
@@ -1,7 +1,101 @@
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 AddThrowHelper, l as AddVoidReturnHelpers, c as ClassSpyConfiguration, C as ClassType, a as CompleteValueConfig, D as DeepMockProxy, m as DeepPartial, E as ErrorValueConfig, F as Func, M as MethodReturns, n as Mutable, N as NextValueConfig, O as OnlyMethodKeysOf, o as OnlyObservablePropsOf, p as OnlyPropsOf, q as Overload, r as Overloads, P as PropStubValue, S as Spy, s as SpyDisposable, t as SpyOptions, u as StrictSpyConfiguration, U as UnstubbedCall, v as UnstubbedCallHandler, V as ValueConfig, b as ValueConfigPerCall, W as WithMockReturnValue } from './types-jaazRXzU.js';
1
+ export { A as AccessorKeysOf, a as AddAccessorsSpies, b as AddCalledWithObservable, c as AddCalledWithPromise, d as AddCalledWithSpyMethods, e as AddObservableSpyMethods, f as AddPromiseSpyMethods, g as AddSpyMethodsByReturnTypes, h as AddThrowHelper, i as AddVoidReturnHelpers, j as ClassSpyConfiguration, C as ClassType, k 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, v as ValueConfigPerCall, W as WithMockReturnValue } from './types-BvbrSBUX.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-CQkhGiYJ.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-BMs7lihn.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-C-IjL1J2.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-DDtfdw9e.js';
5
5
  export { d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-B1pqa-Sh.js';
6
6
  import 'rxjs';
7
7
  import 'vitest';
8
+
9
+ /**
10
+ * Keeping `node:test`'s process-wide `MockTracker` from holding every spy the library ever made.
11
+ *
12
+ * `node:test` exports one lazily-built `MockTracker` as `mock`, and every `mock.fn()` is pushed onto
13
+ * its private `#mocks` array so that `mock.reset()` can restore them later. Nothing is ever spliced
14
+ * out: `restoreAll()` walks the array without emptying it, `reset()` is the only line that assigns
15
+ * `#mocks = []`, and there is no per-entry removal. So a spy stays reachable from a module-level
16
+ * object for the life of the process even after the spec that made it is gone, and with it
17
+ * everything the spy closed over — its recorded arguments, and through them whole object graphs.
18
+ * Measured on Node v24.19.0: 200 000 spies created and dropped, then forced collections, held
19
+ * **148.5 MB**.
20
+ *
21
+ * The registry cannot be pruned the way {@link ../lib/mock-registry} prunes `@vitest/spy`'s. That
22
+ * one works because `vi.clearAllMocks()` iterates a plain `Set` and `Set.prototype.forEach` hands
23
+ * the set to its callback; `#mocks` is a hard private field appended through the **primordial**
24
+ * `ArrayPrototypePush`, which ignores prototype patches, and no public method removes one entry.
25
+ *
26
+ * What is available instead is a boundary. `MockTracker` is an ordinary class — `mock.constructor`
27
+ * **is** it — and `createNodeMockAdapter()` already takes the tracker as a parameter, so the library
28
+ * can own an instance the user never shares and simply let go of it. That is the whole mechanism:
29
+ * spies are created on a private tracker, and per test the tracker is **replaced** with a fresh one.
30
+ * The retired instance and its array become garbage together. Measured the same way, on the same
31
+ * machine: 600 000 spies routed through private trackers left **4.7 MB** against a 4.4 MB baseline.
32
+ *
33
+ * **Replace rather than `reset()`, and that is the point of the design.** `MockTracker#reset()`
34
+ * always runs `restoreAll()` first — the two cannot be separated through the public surface — so a
35
+ * `mockImplementation()` a spec applied to a spy that is still in use would be undone underneath it.
36
+ * Dropping the tracker instead touches no spy at all: a `node:test` mock keeps recording calls and
37
+ * keeps its implementation after its tracker is gone, because the tracker exists only for
38
+ * restore/reset. That is also why none of `mock-registry.ts`'s long-lived classification is needed
39
+ * here — there is no way for a dropped spy to start misbehaving, so there is nothing to exempt.
40
+ *
41
+ * **Why it is opt-in, and why every step is guarded.** `mock.constructor` is the constructor of a
42
+ * value a public API returns, not documented API. It has been `MockTracker` at v22.21.0, v24.19.0
43
+ * and v26.8.1, but it is not a contract, and this module is reached by every `vitest-auto-spy/node`
44
+ * consumer on import. So a tracker is constructed only when {@link trackNodeMocks} asks for one, the
45
+ * construction is probed before a single spy is routed at it, and every failure — a constructor that
46
+ * is not one, a throw, a runtime that is not `node:test` at all — leaves spies going to the
47
+ * runtime's own `mock` exactly as they do today. A slower run beats a broken one.
48
+ */
49
+
50
+ /** Undo {@link trackNodeMocks}: spies go back to the runtime's own tracker from the next one on. */
51
+ type StopTrackingNodeMocks = () => void;
52
+ /**
53
+ * Drop the private tracker and start a fresh one, and report how many spies went with it.
54
+ *
55
+ * Answers `0` when tracking is off, and when a replacement could not be built — in which case the
56
+ * current tracker is kept, because a tracker that grows is better than no tracker at all.
57
+ *
58
+ * Installed on `afterEach` by {@link trackNodeMocks}; call it directly to sweep at some other
59
+ * moment, such as the end of a file in a suite that runs its tests concurrently.
60
+ */
61
+ declare function pruneNodeMocks(): number;
62
+ /**
63
+ * Give this library a `MockTracker` of its own, so its spies never enter the process-wide one.
64
+ *
65
+ * Opt-in: a `node:test` suite that does nothing keeps today's behaviour exactly. Idempotent — a
66
+ * second call installs nothing further and hands back the same stop — and reversible, which is the
67
+ * shape `trackStrayTimers()` and `trackMockRegistry()` already use.
68
+ *
69
+ * Spies created **before** this call stay on the runtime's tracker; call it once, as early as the
70
+ * file's imports allow.
71
+ *
72
+ * If the runtime will not give up its `MockTracker` class, this is a no-op that reports itself as
73
+ * one by handing back a stop that does nothing — spies keep going to `node:test`'s own tracker, and
74
+ * `mock.reset()` keeps freeing them.
75
+ *
76
+ * @returns The undo. Spies created after it go back to the runtime's tracker.
77
+ *
78
+ * @example
79
+ * ```js
80
+ * import { before, describe } from 'node:test';
81
+ * import { trackNodeMocks } from 'vitest-auto-spy/node';
82
+ *
83
+ * before(() => {
84
+ * trackNodeMocks();
85
+ * });
86
+ * ```
87
+ */
88
+ declare function trackNodeMocks(): StopTrackingNodeMocks;
89
+ /**
90
+ * How many spies the private tracker is currently holding, or `0` when tracking is off.
91
+ *
92
+ * For diagnostics and for a suite that wants the sweep to fail loudly rather than quietly — the
93
+ * number `pruneNodeMocks()` is about to return.
94
+ *
95
+ * It counts spy *functions*, not spy objects, and a `createSpyFromClass()` spy materialises its
96
+ * methods on first access — so a spy whose methods a test never touched contributes nothing, which
97
+ * is also why it costs nothing.
98
+ */
99
+ declare function countNodeMocks(): number;
100
+
101
+ export { type StopTrackingNodeMocks, countNodeMocks, pruneNodeMocks, trackNodeMocks };
package/dist/node.js CHANGED
@@ -6,7 +6,7 @@ import './chunk-PC3FAZT3.js';
6
6
  export { createFunctionSpy, errorHandler } from './chunk-3QJUFL2N.js';
7
7
  import './chunk-XRVVZXOM.js';
8
8
  import './chunk-B45HLBA4.js';
9
- import { mock } from 'node:test';
9
+ import { afterEach, mock } from 'node:test';
10
10
  import { registerMockAdapter, guardAccessorSpies } from './shared-state.js';
11
11
 
12
12
  function asNodeMock(mockFn) {
@@ -32,5 +32,100 @@ function createNodeMockAdapter(nodeTest) {
32
32
  );
33
33
  }
34
34
 
35
+ // src/lib/node-mock-tracker.ts
36
+ var host;
37
+ var owned;
38
+ var created = 0;
39
+ var sweepInstalled = false;
40
+ function asNodeTestApi(tracker) {
41
+ return tracker;
42
+ }
43
+ function probeTracker(candidate) {
44
+ const create = Reflect.get(candidate, "fn");
45
+ if (typeof create !== "function") {
46
+ return void 0;
47
+ }
48
+ const probe = Reflect.apply(create, candidate, []);
49
+ if (typeof probe !== "function") {
50
+ return void 0;
51
+ }
52
+ probe();
53
+ const calls = Reflect.get(Object(Reflect.get(probe, "mock")), "calls");
54
+ return Array.isArray(calls) && calls.length === 1 ? asNodeTestApi(candidate) : void 0;
55
+ }
56
+ function constructPrivateTracker() {
57
+ const runtime = host;
58
+ if (runtime === void 0) {
59
+ return void 0;
60
+ }
61
+ try {
62
+ const Tracker = Reflect.get(runtime.mock, "constructor");
63
+ return typeof Tracker === "function" ? probeTracker(Object(Reflect.construct(Tracker, []))) : void 0;
64
+ } catch {
65
+ return void 0;
66
+ }
67
+ }
68
+ var stopTracking = () => {
69
+ owned = void 0;
70
+ created = 0;
71
+ };
72
+ var stopNothing = () => void 0;
73
+ function installSweep() {
74
+ const runtime = host;
75
+ if (sweepInstalled || runtime?.afterEach === void 0) {
76
+ return;
77
+ }
78
+ sweepInstalled = true;
79
+ runtime.afterEach(() => {
80
+ pruneNodeMocks();
81
+ });
82
+ }
83
+ function createSwappableNodeTracker(nodeTest) {
84
+ host = nodeTest;
85
+ owned = void 0;
86
+ created = 0;
87
+ return {
88
+ fn: (implementation) => {
89
+ const tracker = owned;
90
+ if (tracker === void 0) {
91
+ return nodeTest.mock.fn(implementation);
92
+ }
93
+ created += 1;
94
+ return tracker.fn(implementation);
95
+ }
96
+ };
97
+ }
98
+ function pruneNodeMocks() {
99
+ if (owned === void 0) {
100
+ return 0;
101
+ }
102
+ const fresh = constructPrivateTracker();
103
+ if (fresh === void 0) {
104
+ return 0;
105
+ }
106
+ const dropped = created;
107
+ owned = fresh;
108
+ created = 0;
109
+ return dropped;
110
+ }
111
+ function trackNodeMocks() {
112
+ if (owned !== void 0) {
113
+ return stopTracking;
114
+ }
115
+ const tracker = constructPrivateTracker();
116
+ if (tracker === void 0) {
117
+ return stopNothing;
118
+ }
119
+ owned = tracker;
120
+ created = 0;
121
+ installSweep();
122
+ return stopTracking;
123
+ }
124
+ function countNodeMocks() {
125
+ return owned === void 0 ? 0 : created;
126
+ }
127
+
35
128
  // src/node.ts
36
- registerMockAdapter(createNodeMockAdapter(mock));
129
+ registerMockAdapter(createNodeMockAdapter(createSwappableNodeTracker({ mock, afterEach })));
130
+
131
+ export { countNodeMocks, pruneNodeMocks, trackNodeMocks };
@@ -1,4 +1,4 @@
1
- import { P as PropStubValue } from './types-jaazRXzU.js';
1
+ import { P as PropStubValue } from './types-BvbrSBUX.js';
2
2
 
3
3
  /** Undoes a single `mock*Prop` patch; calling it more than once is a no-op. */
4
4
  type RestoreProp = () => void;
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 AddThrowHelper, l as AddVoidReturnHelpers, c as ClassSpyConfiguration, C as ClassType, a as CompleteValueConfig, D as DeepMockProxy, m as DeepPartial, E as ErrorValueConfig, F as Func, M as MethodReturns, n as Mutable, N as NextValueConfig, O as OnlyMethodKeysOf, o as OnlyObservablePropsOf, p as OnlyPropsOf, q as Overload, r as Overloads, P as PropStubValue, S as Spy, s as SpyDisposable, t as SpyOptions, u as StrictSpyConfiguration, U as UnstubbedCall, v as UnstubbedCallHandler, V as ValueConfig, b as ValueConfigPerCall, W as WithMockReturnValue } from './types-jaazRXzU.js';
1
+ export { A as AccessorKeysOf, a as AddAccessorsSpies, b as AddCalledWithObservable, c as AddCalledWithPromise, d as AddCalledWithSpyMethods, e as AddObservableSpyMethods, f as AddPromiseSpyMethods, g as AddSpyMethodsByReturnTypes, h as AddThrowHelper, i as AddVoidReturnHelpers, j as ClassSpyConfiguration, C as ClassType, k 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, v as ValueConfigPerCall, W as WithMockReturnValue } from './types-BvbrSBUX.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-CQkhGiYJ.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-BMs7lihn.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-C-IjL1J2.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-DDtfdw9e.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/rxjs.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Observable, ReplaySubject } from 'rxjs';
2
- import { V as ValueConfig } from './types-jaazRXzU.js';
3
- export { A as AddObservableSpyMethods, a as CompleteValueConfig, E as ErrorValueConfig, N as NextValueConfig, b as ValueConfigPerCall } from './types-jaazRXzU.js';
2
+ import { V as ValueConfig } from './types-BvbrSBUX.js';
3
+ export { e as AddObservableSpyMethods, k as CompleteValueConfig, E as ErrorValueConfig, N as NextValueConfig, v as ValueConfigPerCall } from './types-BvbrSBUX.js';
4
4
  import 'vitest';
5
5
 
6
6
  /**
package/dist/setup.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { vi } from 'vitest';
2
- import { v as UnstubbedCallHandler } from './types-jaazRXzU.js';
3
- import { R as RestoreProp } from './prop-mock-BMs7lihn.js';
2
+ import { u as UnstubbedCallHandler } from './types-BvbrSBUX.js';
3
+ import { R as RestoreProp } from './prop-mock-DDtfdw9e.js';
4
4
  export { d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-B1pqa-Sh.js';
5
5
  import 'rxjs';
6
6
 
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 AddThrowHelper, l as AddVoidReturnHelpers, c as ClassSpyConfiguration, C as ClassType, a as CompleteValueConfig, D as DeepMockProxy, m as DeepPartial, E as ErrorValueConfig, F as Func, M as MethodReturns, n as Mutable, N as NextValueConfig, O as OnlyMethodKeysOf, o as OnlyObservablePropsOf, p as OnlyPropsOf, q as Overload, r as Overloads, P as PropStubValue, S as Spy, s as SpyDisposable, t as SpyOptions, u as StrictSpyConfiguration, U as UnstubbedCall, v as UnstubbedCallHandler, V as ValueConfig, b as ValueConfigPerCall, W as WithMockReturnValue } from './types-jaazRXzU.js';
1
+ export { A as AccessorKeysOf, a as AddAccessorsSpies, b as AddCalledWithObservable, c as AddCalledWithPromise, d as AddCalledWithSpyMethods, e as AddObservableSpyMethods, f as AddPromiseSpyMethods, g as AddSpyMethodsByReturnTypes, h as AddThrowHelper, i as AddVoidReturnHelpers, j as ClassSpyConfiguration, C as ClassType, k 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, v as ValueConfigPerCall, W as WithMockReturnValue } from './types-BvbrSBUX.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-CQkhGiYJ.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-BMs7lihn.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-C-IjL1J2.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-DDtfdw9e.js';
5
5
  export { d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-B1pqa-Sh.js';
6
6
  import 'rxjs';
7
7
  import 'vitest';
@@ -1,4 +1,4 @@
1
- import { C as ClassType, S as Spy } from './types-jaazRXzU.js';
1
+ import { C as ClassType, S as Spy } from './types-BvbrSBUX.js';
2
2
 
3
3
  /**
4
4
  * The provider shape Angular and NestJS agree on: `{ provide, useFactory }`, with the dependency
@@ -630,4 +630,4 @@ interface ClassSpyConfiguration<T> extends StrictSpyConfiguration {
630
630
  lazySpies?: boolean | 'proxy';
631
631
  }
632
632
 
633
- export type { AddObservableSpyMethods as A, ClassType as C, DeepMockProxy as D, ErrorValueConfig as E, Func as F, MethodReturns as M, NextValueConfig as N, OnlyMethodKeysOf as O, PropStubValue as P, Spy as S, UnstubbedCall as U, ValueConfig as V, WithMockReturnValue as W, CompleteValueConfig as a, ValueConfigPerCall as b, ClassSpyConfiguration as c, AccessorKeysOf as d, AddAccessorsSpies as e, AddCalledWithObservable as f, AddCalledWithPromise as g, AddCalledWithSpyMethods as h, AddPromiseSpyMethods as i, AddSpyMethodsByReturnTypes as j, AddThrowHelper as k, AddVoidReturnHelpers as l, DeepPartial as m, Mutable as n, OnlyObservablePropsOf as o, OnlyPropsOf as p, Overload as q, Overloads as r, SpyDisposable as s, SpyOptions as t, StrictSpyConfiguration as u, UnstubbedCallHandler as v };
633
+ export type { AccessorKeysOf as A, ClassType as C, DeepMockProxy as D, ErrorValueConfig as E, Func as F, MethodReturns as M, NextValueConfig as N, OnlyMethodKeysOf as O, PropStubValue as P, Spy as S, UnstubbedCall as U, ValueConfig as V, WithMockReturnValue as W, AddAccessorsSpies as a, AddCalledWithObservable as b, AddCalledWithPromise as c, AddCalledWithSpyMethods as d, AddObservableSpyMethods as e, AddPromiseSpyMethods as f, AddSpyMethodsByReturnTypes as g, AddThrowHelper as h, AddVoidReturnHelpers as i, ClassSpyConfiguration as j, CompleteValueConfig as k, DeepPartial as l, Mutable as m, OnlyObservablePropsOf as n, OnlyPropsOf as o, Overload as p, Overloads as q, SpyDisposable as r, SpyOptions as s, StrictSpyConfiguration as t, UnstubbedCallHandler as u, ValueConfigPerCall as v };
package/dist/vue.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { S as Spy, C as ClassType, c as ClassSpyConfiguration, O as OnlyMethodKeysOf } from './types-jaazRXzU.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 AddThrowHelper, l as AddVoidReturnHelpers, a as CompleteValueConfig, D as DeepMockProxy, m as DeepPartial, E as ErrorValueConfig, F as Func, M as MethodReturns, n as Mutable, N as NextValueConfig, o as OnlyObservablePropsOf, p as OnlyPropsOf, q as Overload, r as Overloads, P as PropStubValue, s as SpyDisposable, t as SpyOptions, u as StrictSpyConfiguration, U as UnstubbedCall, v as UnstubbedCallHandler, V as ValueConfig, b as ValueConfigPerCall, W as WithMockReturnValue } from './types-jaazRXzU.js';
1
+ import { S as Spy, C as ClassType, j as ClassSpyConfiguration, O as OnlyMethodKeysOf } from './types-BvbrSBUX.js';
2
+ export { A as AccessorKeysOf, a as AddAccessorsSpies, b as AddCalledWithObservable, c as AddCalledWithPromise, d as AddCalledWithSpyMethods, e as AddObservableSpyMethods, f as AddPromiseSpyMethods, g as AddSpyMethodsByReturnTypes, h as AddThrowHelper, i as AddVoidReturnHelpers, k 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, v as ValueConfigPerCall, W as WithMockReturnValue } from './types-BvbrSBUX.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-CQkhGiYJ.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-BMs7lihn.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-C-IjL1J2.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-DDtfdw9e.js';
6
6
  export { d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-B1pqa-Sh.js';
7
7
  import 'rxjs';
8
8
  import 'vitest';
@@ -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-CQkhGiYJ.js';
3
- import { S as Spy, C as ClassType, t as SpyOptions, c as ClassSpyConfiguration, O as OnlyMethodKeysOf, m as DeepPartial } from './types-jaazRXzU.js';
4
- import './prop-mock-BMs7lihn.js';
2
+ import { A as AutoMockConfiguration } from './expect-emission-C-IjL1J2.js';
3
+ import { S as Spy, C as ClassType, s as SpyOptions, j as ClassSpyConfiguration, O as OnlyMethodKeysOf, l as DeepPartial } from './types-BvbrSBUX.js';
4
+ import './prop-mock-DDtfdw9e.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.17.0",
3
+ "version": "3.18.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 and jasmine-auto-spies.",
5
5
  "keywords": [
6
6
  "auto-mock",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: vitest-auto-spy
3
- description: Write or fix tests that use vitest-auto-spy — typed spies from a class or a type on Vitest, bun:test and node:test. Use when a spec imports `vitest-auto-spy` or any of its subpaths (`/angular`, `/angular-http`, `/bun-angular`, `/bun`, `/node`, `/rxjs`, `/nestjs`, `/jasmine`, `/jasmine-compat`, `/observer-spy`, `/setup`, `/zone`, `/eslint-plugin`), when the user mentions createSpyFromClass, createAutoMock, createMock, mockDeep, createFunctionSpy, createSpyObj, enableJasmineCompat, subscribeSpyTo, provideAutoSpy, provideHttpTesting, expectRequest, injectSpy, createNestUnit, extendWithAutoSpies, renderShallow, createWithAutoSpies, createDirectiveHost, overrideComponentProvider, enableAngularDiagnostics, assertNgModuleScopes, trackInjections, runEffect, settleResource, httpResource, mockResourceProp, mockSignalProp, mockReadonlyProp, captureArg, expectEmission, expectError, setupAutoSpy, stubIntersectionObserver, assertMocked, Spy<T>, calledWith, mustBeCalledWith, onlyMethodsToSpyOn, instanceMethodsToSpyOn, observablePropsToSpyOn, strict, onUnstubbedCall, resolveWith or nextWith, when migrating a suite off jest-auto-spies or jasmine-auto-spies (`npx vitest-auto-spy codemod --from jasmine`), or when a test fails with "No mock adapter registered", "Observable spies require rxjs", "not found on the class prototype", "strict mode is on", "the override did not apply", "is not a constructor", "Expected to be running in 'ProxyZone'", "jasmine is not defined", "no HttpTestingController" or "Spy<T> is not assignable".
3
+ description: Write or fix tests that use vitest-auto-spy — typed spies from a class or a type on Vitest, bun:test and node:test. Use when a spec imports `vitest-auto-spy` or any of its subpaths (`/angular`, `/angular-http`, `/bun-angular`, `/bun`, `/node`, `/rxjs`, `/nestjs`, `/jasmine`, `/jasmine-compat`, `/observer-spy`, `/setup`, `/zone`, `/eslint-plugin`), when the user mentions createSpyFromClass, createAutoMock, createMock, mockDeep, createFunctionSpy, createSpyObj, enableJasmineCompat, subscribeSpyTo, provideAutoSpy, provideHttpTesting, expectRequest, injectSpy, createNestUnit, extendWithAutoSpies, renderShallow, createWithAutoSpies, createDirectiveHost, overrideComponentProvider, enableAngularDiagnostics, assertNgModuleScopes, trackInjections, runEffect, settleResource, httpResource, mockResourceProp, mockSignalProp, mockReadonlyProp, captureArg, expectEmission, expectError, setupAutoSpy, assertMocked, Spy<T>, calledWith, mustBeCalledWith, onlyMethodsToSpyOn, strict, onUnstubbedCall, resolveWith or nextWith, when migrating a suite off jest-auto-spies, jasmine-auto-spies or @ngneat/spectator (createSpyObject, mockProvider, SpectatorService) (`npx vitest-auto-spy codemod --from jasmine`), or when a test fails with "No mock adapter registered", "Observable spies require rxjs", "not found on the class prototype", "strict mode is on", "the override did not apply", "is not a constructor", "Expected to be running in 'ProxyZone'", "jasmine is not defined", "no HttpTestingController" or "Spy<T> is not assignable".
4
4
  ---
5
5
 
6
6
  # vitest-auto-spy
@@ -127,6 +127,7 @@ it('loads', async () => {
127
127
  | a `signal()` / `computed()` field on the class under test | `mockSignalProp(obj, prop, initial)` — returns the writable |
128
128
  | a resource field, when the HTTP round trip is not the point | `mockResourceProp(obj, prop, initial)` — `set` / `fail` / `loading` |
129
129
  | the HTTP round trip _is_ the point | `expectRequest(url).flush(body)` — `/angular-http`, settling included |
130
+ | a node:test suite whose heap grows all run | `trackNodeMocks()` — `/node`, a private MockTracker |
130
131
  | a Nest provider whose constructor keeps changing | `createNestUnit(Target, { expose })` — built from its DI metadata |
131
132
  | asserting a resource's value _and_ status together | `registerResourceMatchers()` → `toHaveResourceValue` / `toBeLoading` |
132
133
  | a callback or config object the code under test built | `captureArg<T>()` in the assertion, then read `.value` |