# vitest-auto-spy > Auto-generate fully-typed test spies from a class, a type or nothing at all — one API across > Vitest, `bun test` and `node:test`, plus Angular/NestJS/React/Vue/Svelte adapters. A drop-in > successor to `jest-auto-spies`. Zero runtime dependencies. - Install: `npm i -D vitest-auto-spy` - Repository: https://github.com/ASDAlexey/vitest-auto-spy - Documentation: https://asdalexey.github.io/vitest-auto-spy/ - Offline agent cheat sheet, shipped inside the package: `node_modules/vitest-auto-spy/AGENTS.md` - Everything below inlined as one file: https://asdalexey.github.io/vitest-auto-spy/llms-full.txt The one-line orientation: `createSpyFromClass(Class)` when a class exists, `createAutoMock()` when only a type does, `createMock(partial)` when the double is read rather than called. Each spied method earns helpers from its return type — `calledWith`/`mustBeCalledWith` always, `resolveWith`/`rejectWith` for a `Promise`, `nextWith`/`throwWith` for an `Observable`. ## Core - [Introduction](https://asdalexey.github.io/vitest-auto-spy/core/introduction): What vitest-auto-spy does — a typed spy of every method of a class, on Vitest, Bun or node:test. - [Installation](https://asdalexey.github.io/vitest-auto-spy/core/installation): Install vitest-auto-spy, pick the entry point that matches your runner, and wire it into Vitest, Bun or node:test. - [How it works](https://asdalexey.github.io/vitest-auto-spy/core/how-it-works): The two ideas behind vitest-auto-spy — a prototype-chain walk at runtime, and conditional types that pick helpers from a method's return type. - [createSpyFromClass](https://asdalexey.github.io/vitest-auto-spy/core/create-spy-from-class): Build a fully-typed Spy from a class — configuration, the Spy shape, accessor spies and the edge cases. - [Control helpers](https://asdalexey.github.io/vitest-auto-spy/core/control-helpers): calledWith, mustBeCalledWith, resolveWith, nextWith and the rest — the helpers each spied method earns from its return type. - [Auto-mock by type](https://asdalexey.github.io/vitest-auto-spy/core/auto-mock-by-type): createAutoMock, mockDeep and createMock — build a double from a type or interface, with no class at runtime. - [Observable assertions](https://asdalexey.github.io/vitest-auto-spy/core/observable-assertions): expectEmission, expectEmissions, expectNoEmission and expectCompletion — assertions that fail when the stream stays silent. - [Bridging Spy and T](https://asdalexey.github.io/vitest-auto-spy/core/spy-typing): Why Spy is not assignable to T, and the two named views — asInstance and asSpy — that cross the gap without an `as`. - [Performance](https://asdalexey.github.io/vitest-auto-spy/core/performance): What each factory costs, which one to reach for, and why none of them is where a slow suite spends its time. ## Spec patterns - [Patterns that hold up](https://asdalexey.github.io/vitest-auto-spy/recipes): The shapes a large Angular suite actually converged on — provideAutoSpy configuration, signal mocking, observable properties, and the traps that only surface at scale. ## Runtimes - [Vitest](https://asdalexey.github.io/vitest-auto-spy/runtimes/vitest): The default zero-config entry — setup-file wiring, the rxjs and Angular subpaths, and what shared-environment runs need. - [Bun](https://asdalexey.github.io/vitest-auto-spy/runtimes/bun): Run vitest-auto-spy on Bun's bun:test, including Bun 1.4's --isolate, --parallel, --shard and --changed. - [Angular on Bun](https://asdalexey.github.io/vitest-auto-spy/runtimes/bun-angular): Run Angular's TestBed under bun test — DOM, JIT templates and zoneless change detection from one preload. - [node:test](https://asdalexey.github.io/vitest-auto-spy/runtimes/node): Run vitest-auto-spy on Node's built-in test runner — a runnable example and how node:test's native mock surface differs. - [RxJS](https://asdalexey.github.io/vitest-auto-spy/runtimes/rxjs): The opt-in observable layer — nextWith, nextWithValues, nextWithPerCall, returnSubject, and how delays behave. ## Utilities - [Console spies](https://asdalexey.github.io/vitest-auto-spy/utilities/console): Silent, typed spies over the global console — installed on import, restored on demand. - [Test-run hygiene](https://asdalexey.github.io/vitest-auto-spy/utilities/setup): setupAutoSpy() — property restore, mock-registry reset, duplicate-copy detection, stray timers and rejections, and global-patch guarding in one call. - [Fake timers](https://asdalexey.github.io/vitest-auto-spy/utilities/fake-timers): setupFakeTimers pairs install with restore, and advanceTimers drains the microtasks a bare advance leaves pending. - [Observer stubs](https://asdalexey.github.io/vitest-auto-spy/utilities/observer-stubs): stubIntersectionObserver and friends — replace an observer the component constructs itself with one the spec drives, and get the real global back automatically. - [Constructor doubles](https://asdalexey.github.io/vitest-auto-spy/utilities/constructor-doubles): mockConstructor and stubConstructor — a test double the code under test can call with `new`, because a vi.fn() cannot be one. - [Media element stub](https://asdalexey.github.io/vitest-auto-spy/utilities/media-element): stubMediaElement — a