export { A as AccessorKeysOf, a as AddAccessorsSpies, b as AddCalledWithAny, c as AddCalledWithObservable, d as AddCalledWithPromise, e as AddCalledWithSpyMethods, f as AddObservableSpyMethods, g as AddPromiseSpyMethods, h as AddSpyMethodsByReturnTypes, i as AddThrowHelper, j as AddVoidReturnHelpers, k as AnyReturnHelpers, l as AutoSpyRxjsTypes, m as ClassSpyConfiguration, C as ClassType, n as CompleteValueConfig, D as DeepMockProxy, o as DeepPartial, E as ErrorValueConfig, F as Func, I as InstanceSpyConfiguration, M as MethodReturns, p as Mutable, N as NextValueConfig, O as ObservableLike, q as OnlyMethodKeysOf, r as OnlyObservablePropsOf, s as OnlyPropsOf, t as Overload, u as OverloadChoice, v as Overloads, P as PropStubValue, S as Spy, w as SpyDisposable, x as SpyOptions, y as StrictSpyConfiguration, z as SubjectLike, B as SubjectOf, U as UnstubbedCall, G as UnstubbedCallHandler, H as UnstubbedRead, J as UnstubbedReadHandler, V as ValueConfig, K as ValueConfigPerCall, W as WithMockReturnValue } from './types-BM3BcWj1.js'; export { AdoptMockOptions, AdoptedMock, ArgCaptor, AsInstances, AssertMockedOptions, CallLog, CaptureArgOptions, ConstructorMock, ConstructorSpy, FixtureFactory, FlushUntilOptions, MockDeepOptions, ModuleNamespace, ModuleNamespaceOptions, SpyClassOptions, adoptMock, asInstance, asInstances, asSpy, assertMocked, captureArg, clearAutoSpy, createFixture, createFixtureFactory, createLog, createMock, createSpyClass, createSpyFromClass, createSpyFromInstance, errorHandler, flushEventLoop, flushEventLoopUntil, mockConstructor, mockDeep, moduleNamespace, narrow, resetAutoSpy, restoreSpiedInstance, settleDynamicImport, stubConstructor, withOverrides } from './bun.js'; export { A as AutoMockConfiguration, a as AutoSpyDefaultEntry, C as CallbackSubscribable, E as EmissionObserver, b as EmissionOptions, c as EmissionSource, S as SubscribableLike, d as autoMocked, e as clearAutoSpyDefaults, f as createAutoMock, g as expectCompletion, h as expectEmission, i as expectEmissions, j as expectError, k as expectNoEmission, r as registerAutoSpyDefaults, s as setEmissionTimeout } from './expect-emission-S5asJaJP.js'; export { c as createFunctionSpy, d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-Cn7yncmJ.js'; export { A as AccessorImplementations, O as OutsideHookReaction, R as RestoreProp, c as countMockedProps, m as mockAccessorsProp, a as mockReadonlyProp, b as mockReadonlyPropGetter, d as mockValueProp, r as reportPropsOutsideHooks, e as restoreMockedProps } from './prop-mock-C--a8rpU.js'; import 'vitest'; /** * Keeping `node:test`'s process-wide `MockTracker` from holding every spy the library ever made. * * `node:test` exports one lazily-built `MockTracker` as `mock`, and every `mock.fn()` is pushed onto * its private `#mocks` array so that `mock.reset()` can restore them later. Nothing is ever spliced * out: `restoreAll()` walks the array without emptying it, `reset()` is the only line that assigns * `#mocks = []`, and there is no per-entry removal. So a spy stays reachable from a module-level * object for the life of the process even after the spec that made it is gone, and with it * everything the spy closed over — its recorded arguments, and through them whole object graphs. * Measured on Node v24.19.0: 200 000 spies created and dropped, then forced collections, held * **148.5 MB**. * * The registry cannot be pruned the way {@link ../lib/mock-registry} prunes `@vitest/spy`'s. That * one works because `vi.clearAllMocks()` iterates a plain `Set` and `Set.prototype.forEach` hands * the set to its callback; `#mocks` is a hard private field appended through the **primordial** * `ArrayPrototypePush`, which ignores prototype patches, and no public method removes one entry. * * What is available instead is a boundary. `MockTracker` is an ordinary class — `mock.constructor` * **is** it — and `createNodeMockAdapter()` already takes the tracker as a parameter, so the library * can own an instance the user never shares and simply let go of it. That is the whole mechanism: * spies are created on a private tracker, and per test the tracker is **replaced** with a fresh one. * The retired instance and its array become garbage together. Measured the same way, on the same * machine: 600 000 spies routed through private trackers left **4.7 MB** against a 4.4 MB baseline. * * **Replace rather than `reset()`, and that is the point of the design.** `MockTracker#reset()` * always runs `restoreAll()` first — the two cannot be separated through the public surface — so a * `mockImplementation()` a spec applied to a spy that is still in use would be undone underneath it. * Dropping the tracker instead touches no spy at all: a `node:test` mock keeps recording calls and * keeps its implementation after its tracker is gone, because the tracker exists only for * restore/reset. That is also why none of `mock-registry.ts`'s long-lived classification is needed * here — there is no way for a dropped spy to start misbehaving, so there is nothing to exempt. * * **Why it is opt-in, and why every step is guarded.** `mock.constructor` is the constructor of a * value a public API returns, not documented API. It has been `MockTracker` at v22.21.0, v24.19.0 * and v26.8.1, but it is not a contract, and this module is reached by every `vitest-auto-spy/node` * consumer on import. So a tracker is constructed only when {@link trackNodeMocks} asks for one, the * construction is probed before a single spy is routed at it, and every failure — a constructor that * is not one, a throw, a runtime that is not `node:test` at all — leaves spies going to the * runtime's own `mock` exactly as they do today. A slower run beats a broken one. */ /** Undo {@link trackNodeMocks}: spies go back to the runtime's own tracker from the next one on. */ type StopTrackingNodeMocks = () => void; /** * Drop the private tracker and start a fresh one, and report how many spies went with it. * * Answers `0` when tracking is off, and when a replacement could not be built — in which case the * current tracker is kept, because a tracker that grows is better than no tracker at all. * * Installed on `afterEach` by {@link trackNodeMocks}; call it directly to sweep at some other * moment, such as the end of a file in a suite that runs its tests concurrently. */ declare function pruneNodeMocks(): number; /** * Give this library a `MockTracker` of its own, so its spies never enter the process-wide one. * * Opt-in: a `node:test` suite that does nothing keeps today's behaviour exactly. Idempotent — a * second call installs nothing further and hands back the same stop — and reversible, which is the * shape `trackStrayTimers()` and `trackMockRegistry()` already use. * * Spies created **before** this call stay on the runtime's tracker; call it once, as early as the * file's imports allow. * * If the runtime will not give up its `MockTracker` class, this is a no-op that reports itself as * one by handing back a stop that does nothing — spies keep going to `node:test`'s own tracker, and * `mock.reset()` keeps freeing them. * * @returns The undo. Spies created after it go back to the runtime's tracker. * * @example * ```js * import { before, describe } from 'node:test'; * import { trackNodeMocks } from 'vitest-auto-spy/node'; * * before(() => { * trackNodeMocks(); * }); * ``` */ declare function trackNodeMocks(): StopTrackingNodeMocks; /** * How many spies the private tracker is currently holding, or `0` when tracking is off. * * For diagnostics and for a suite that wants the sweep to fail loudly rather than quietly — the * number `pruneNodeMocks()` is about to return. * * It counts spy *functions*, not spy objects, and a `createSpyFromClass()` spy materialises its * methods on first access — so a spy whose methods a test never touched contributes nothing, which * is also why it costs nothing. */ declare function countNodeMocks(): number; export { type StopTrackingNodeMocks, countNodeMocks, pruneNodeMocks, trackNodeMocks };