vitest-auto-spy 5.56.0 → 5.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/AGENTS.md +3 -1
  2. package/CHANGELOG.md +48 -1
  3. package/README.md +13 -13
  4. package/agent-docs/checklist.md +3 -2
  5. package/agent-docs/configuration.md +1 -1
  6. package/agent-docs/eslint.md +1 -1
  7. package/agent-docs/factories.md +6 -3
  8. package/dist/angular-diagnostics.js +2 -2
  9. package/dist/angular-doubles.d.ts +1 -1
  10. package/dist/angular-doubles.js +1 -1
  11. package/dist/angular-router.d.ts +1 -1
  12. package/dist/angular.d.ts +7 -7
  13. package/dist/bun-angular.d.ts +7 -7
  14. package/dist/bun-angular.js +7 -7
  15. package/dist/bun.d.ts +6 -6
  16. package/dist/bun.js +3 -3
  17. package/dist/{chunk-KHALREYP.js → chunk-3457Z3JE.js} +1 -1
  18. package/dist/{chunk-3IINYLDB.js → chunk-7MDSR745.js} +5 -2
  19. package/dist/{chunk-LKXOKRTC.js → chunk-IQVNZORF.js} +35 -7
  20. package/dist/{chunk-RAJTKMDV.js → chunk-OL2J4K4Z.js} +1 -1
  21. package/dist/cli.js +73 -28
  22. package/dist/console.d.ts +1 -1
  23. package/dist/core.d.ts +24 -6
  24. package/dist/dom-stubs.d.ts +2 -2
  25. package/dist/{emission-sync-CNbHIKGX.d.ts → emission-sync-Cv6VnggW.d.ts} +3 -2
  26. package/dist/eslint-plugin.cjs +40 -8
  27. package/dist/index.d.ts +5 -5
  28. package/dist/index.js +46 -15
  29. package/dist/jasmine-compat.d.ts +1 -1
  30. package/dist/jasmine.d.ts +2 -2
  31. package/dist/jasmine.js +1 -1
  32. package/dist/{nest-unit-DdJ251KZ.d.ts → nest-unit-DG-qxd6Q.d.ts} +1 -1
  33. package/dist/nestjs.d.ts +3 -3
  34. package/dist/nestjs.js +2 -2
  35. package/dist/node.cjs +45 -13
  36. package/dist/node.d.cts +1 -0
  37. package/dist/node.d.ts +6 -6
  38. package/dist/node.js +45 -14
  39. package/dist/observer-spy.d.ts +1 -1
  40. package/dist/{package-identity-Dhlx2i2x.d.ts → package-identity-DM9vHPzU.d.ts} +1 -1
  41. package/dist/{prop-mock-vydpb5c5.d.ts → prop-mock-CIWAmzz0.d.ts} +1 -1
  42. package/dist/react.d.ts +5 -5
  43. package/dist/react.js +1 -1
  44. package/dist/rstest.d.ts +5 -5
  45. package/dist/rstest.js +2 -2
  46. package/dist/rxjs.d.ts +3 -3
  47. package/dist/setup.d.ts +3 -3
  48. package/dist/svelte.d.ts +5 -5
  49. package/dist/svelte.js +1 -1
  50. package/dist/{track-injections-BkGvSEzV.d.ts → track-injections-xXSrGdpM.d.ts} +1 -1
  51. package/dist/{track-signal-runs-BDQ6MqwO.d.ts → track-signal-runs-Cw_x1b9n.d.ts} +3 -3
  52. package/dist/{types-NphKNopY.d.ts → types-CpBA3PjQ.d.ts} +11 -4
  53. package/dist/vue.d.ts +6 -6
  54. package/dist/vue.js +1 -1
  55. package/package.json +1 -1
  56. package/skills/vitest-auto-spy/SKILL.md +2 -1
package/AGENTS.md CHANGED
@@ -284,7 +284,9 @@ new ProfileFacade(asInstance(users)); // Spy<T> → T, for an API typed against
284
284
  const cart = asSpy(TestBed.inject(CartService)); // T → Spy<T>, for the helpers
285
285
  ```
286
286
 
287
- Both are the same object at runtime. `injectSpy(X)` already returns `Spy<X>`. Do **not** patch the
287
+ Both are the same object at runtime. `injectSpy(X)` already returns `Spy<X>`. The double a
288
+ `returnsClass` method answers is `innerDouble(outer, 'create')`, typed `Spy<Report>` and read
289
+ without recording a call on `create`. Do **not** patch the
288
290
  mismatch with `as any`, `as unknown as T` or `@ts-expect-error`.
289
291
 
290
292
  | Compiler message | Direction | Fix |
package/CHANGELOG.md CHANGED
@@ -10,6 +10,51 @@ The latest released version here must always match the one published on
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [5.58.0] - 2026-09-30
14
+
15
+ ### Added
16
+
17
+ - **`returnsClass` takes a pair, `{ method: [Class, options] }`.** `options` is the
18
+ `createSpyFromClass` configuration for the inner double, typed against that class. A factory method
19
+ whose result has a `void` method under `strict`
20
+ (`returnsClass: { openFromComponent: [MatSnackBarRef, { returnsUndefined: ['dismiss'] }] }`) now
21
+ moves to `returnsClass` too, instead of staying on `returns: { m: asInstance(ref) }`.
22
+ - **`innerDouble(double, 'method')` returns the double a `returnsClass` method answers, without
23
+ calling the method.** A spec that asserts `toHaveBeenCalledExactlyOnceWith` on the factory method,
24
+ or configures the inner double before the code under test runs, no longer needs the two-step
25
+ `createSpyFromClass` + `returns` form. It throws when the method has no `returnsClass` entry.
26
+
27
+ ### Fixed
28
+
29
+ - **`no-inline-test-data` no longer sends a value repeated only as an expected value to a
30
+ `*.mock.ts` file.** When every copy is the argument of an equality matcher (`toEqual`,
31
+ `toMatchObject`, `toHaveBeenCalledWith`…, through `.resolves` / `.rejects` / `.not`), the rule asks
32
+ for a spec-local `const` instead; a short expected object of up to three plain keys, such as
33
+ `{ name: 'HttpErrorResponse', status: 401 }`, is not reported at all.
34
+ - **`no-inline-test-data` names a smaller part of a long expected value.** It now names the smallest
35
+ nested part whose move alone brings the expectation under `maxLines`, a list of plain values or a
36
+ template string first. In a rule-config expectation it names the word list, not the
37
+ `['error', {...}]` tuple under test.
38
+ - **`shared-env-without-restore` reads frozen options and notes the ones it cannot read.**
39
+ `export const OPTS = Object.freeze({ restoreMocks: false, … }); setupAutoSpy(OPTS)` (or
40
+ `{ ...OPTS }`) used to pass silently. `Object.freeze(…)`, `as const`, `satisfies` and parentheses
41
+ are now read through, and a switch that stays unreadable (a call, a condition, an import from a
42
+ package) gets a note naming the file and the switches instead of a silent pass.
43
+ - **`tsconfig-ships-mock-file` reports a library build config with no `exclude`.** A `tsc`-built
44
+ library whose `tsconfig.lib.json` has only `"include": ["src/**/*.ts"]` ships its specs and
45
+ `*.mock.ts` files, yet got no warning until an `exclude` naming the specs was added. Suggested
46
+ globs now follow the existing excludes or the `include` directory (`src/**/*.mock.ts` beside
47
+ `src/**/*.spec.ts`) instead of always `**/*.mock.ts`.
48
+
49
+ ### Size
50
+
51
+ The root entry **29.99 → 30.27 kB** min+gzip (+0.28 kB, +0.9 %), and every runtime entry that carries
52
+ the core by about the same: the `returnsClass` pair and the per-double registry `innerDouble` reads.
53
+ `/eslint-plugin` 53.20 → 53.45 kB (+0.25 kB, +0.5 %) for the expected-value handling in
54
+ `no-inline-test-data`; a lint-time entry no test run imports.
55
+
56
+ ## [5.57.0] - 2026-09-30
57
+
13
58
  ## [5.56.0] - 2026-09-30
14
59
 
15
60
  ### Fixed
@@ -6748,7 +6793,9 @@ moved under 1 %: `/angular` +192 B (+1.0 %) for the override queue and the HTTP
6748
6793
  This copy ships with the package and carries 5.x only. Releases before 5.0.0 are in the
6749
6794
  [full changelog](https://github.com/ASDAlexey/vitest-auto-spy/blob/master/CHANGELOG.md).
6750
6795
 
6751
- [Unreleased]: https://github.com/ASDAlexey/vitest-auto-spy/compare/v5.56.0...HEAD
6796
+ [Unreleased]: https://github.com/ASDAlexey/vitest-auto-spy/compare/v5.58.0...HEAD
6797
+ [5.58.0]: https://github.com/ASDAlexey/vitest-auto-spy/compare/v5.57.0...v5.58.0
6798
+ [5.57.0]: https://github.com/ASDAlexey/vitest-auto-spy/compare/v5.56.0...v5.57.0
6752
6799
  [5.56.0]: https://github.com/ASDAlexey/vitest-auto-spy/compare/v5.55.0...v5.56.0
6753
6800
  [5.55.0]: https://github.com/ASDAlexey/vitest-auto-spy/compare/v5.54.0...v5.55.0
6754
6801
  [5.54.0]: https://github.com/ASDAlexey/vitest-auto-spy/compare/v5.53.0...v5.54.0
package/README.md CHANGED
@@ -15,7 +15,7 @@ replacement for [`jest-auto-spies`](https://www.npmjs.com/package/jest-auto-spie
15
15
  [![downloads per month](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.npmjs.org%2Fdownloads%2Fpoint%2Flast-month%2Fvitest-auto-spy&query=%24.downloads&color=brightgreen&logo=npm&label=downloads%2Fmonth)](https://www.npmjs.com/package/vitest-auto-spy)
16
16
  [![downloads over 18 months](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.npmjs.org%2Fdownloads%2Fpoint%2F2026-06-21%3A2030-01-01%2Fvitest-auto-spy&query=%24.downloads&color=brightgreen&logo=npm&label=downloads%2F18mo)](https://www.npmjs.com/package/vitest-auto-spy)
17
17
  [![CI](https://github.com/ASDAlexey/vitest-auto-spy/actions/workflows/ci.yml/badge.svg)](https://github.com/ASDAlexey/vitest-auto-spy/actions/workflows/ci.yml)
18
- [![minzipped size](https://img.shields.io/badge/minzip-30.0%20kB-brightgreen)](#install)
18
+ [![minzipped size](https://img.shields.io/badge/minzip-30.3%20kB-brightgreen)](#install)
19
19
  [![types](https://img.shields.io/npm/types/vitest-auto-spy?logo=typescript&logoColor=white)](https://www.npmjs.com/package/vitest-auto-spy)
20
20
  [![coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://github.com/ASDAlexey/vitest-auto-spy/actions/workflows/ci.yml)
21
21
  [![license](https://img.shields.io/npm/l/vitest-auto-spy?color=blue)](./LICENSE)
@@ -3806,18 +3806,18 @@ Helpers on each spied member, by return type:
3806
3806
 
3807
3807
  `ClassSpyConfiguration`, the second argument of `createSpyFromClass` and `provideAutoSpy`:
3808
3808
 
3809
- | Option | What it does |
3810
- | ----------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
3811
- | `methodsToSpyOn` | adds names to the discovered methods |
3812
- | `onlyMethodsToSpyOn` | spies only these; discovery is skipped |
3813
- | `instanceMethodsToSpyOn` | same as `methodsToSpyOn`, for callables on the instance (`signal()` fields, arrow props, `signalStore()` methods) |
3814
- | `observablePropsToSpyOn` | Observable properties to spy |
3815
- | `returnsUndefined` | methods that answer `undefined`, counted as configured under `strict` |
3816
- | `returnsClass` | `{ create: Report }`: the method answers one spy of that class per double, reached as `asSpy(double.create())` |
3817
- | `gettersToSpyOn` / `settersToSpyOn` | accessors to spy |
3818
- | `autoSpyAccessors` | spies every getter and setter on the prototype |
3819
- | `fillMissing` | answers a name the prototype never had with a spy (a partially abstract class) |
3820
- | `lazySpies` | unset: plain object below 8 methods, `'proxy'` from 8; `true` keeps a plain object; `false` builds every spy up front |
3809
+ | Option | What it does |
3810
+ | ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
3811
+ | `methodsToSpyOn` | adds names to the discovered methods |
3812
+ | `onlyMethodsToSpyOn` | spies only these; discovery is skipped |
3813
+ | `instanceMethodsToSpyOn` | same as `methodsToSpyOn`, for callables on the instance (`signal()` fields, arrow props, `signalStore()` methods) |
3814
+ | `observablePropsToSpyOn` | Observable properties to spy |
3815
+ | `returnsUndefined` | methods that answer `undefined`, counted as configured under `strict` |
3816
+ | `returnsClass` | `{ create: Report }` or `{ create: [Report, options] }`: the method answers one spy of that class per double, reached as `innerDouble(double, 'create')` without recording a call |
3817
+ | `gettersToSpyOn` / `settersToSpyOn` | accessors to spy |
3818
+ | `autoSpyAccessors` | spies every getter and setter on the prototype |
3819
+ | `fillMissing` | answers a name the prototype never had with a spy (a partially abstract class) |
3820
+ | `lazySpies` | unset: plain object below 8 methods, `'proxy'` from 8; `true` keeps a plain object; `false` builds every spy up front |
3821
3821
 
3822
3822
  `ValueConfig` (for `nextWithValues`): `{ value, delay? }` | `{ errorValue, delay? }` | `{ complete?, delay? }`.
3823
3823
 
@@ -85,10 +85,11 @@ Angular suites: `angular-testbed-split` (an Analog config without `server.deps.i
85
85
  which gives `/angular` a second `TestBed`), `angular-cache-off-in-ci` (the builder cache never reaches
86
86
  CI: +33 % per run on a 700-file suite), `shared-env-without-restore` (a shared environment without
87
87
  the `setupAutoSpy` restore options; each setup file is judged on its own calls, an options object declared,
88
- imported or spread counts, and a value it cannot read is never called off) and `mock-registry-capture-drops-sentinel` (a hand-rolled registry
88
+ imported, spread or wrapped in `Object.freeze` counts, and a value it cannot read is never called off but gets a "not statically readable" note) and `mock-registry-capture-drops-sentinel` (a hand-rolled registry
89
89
  pruner that can drop the `clearAllMocks` sweep). `tsconfig-ships-mock-file` warns about a build
90
90
  tsconfig whose `exclude` leaves out the specs but not the `*.mock.ts` / `*.fixtures.ts` / `__mocks__/`
91
- files beside them, so they ship in the package. The `tsconfig` checks do not judge a `../` entry,
91
+ files beside them, so they ship in the package, and about a `tsconfig.lib.json` / `tsconfig.build.json`
92
+ with no `exclude` at all, which ships the specs too. The `tsconfig` checks do not judge a `../` entry,
92
93
  a missing generated `.d.ts` in `files`, or `include` on a scan that hit its cap, and the import graph
93
94
  ignores specifiers in comments and strings and follows tsconfig `paths` / `baseUrl` through `extends`.
94
95
  It is worth one run after any large edit to a test suite — especially after a codemod, which is where
@@ -36,7 +36,7 @@ createSpyFromClass(MyService, {
36
36
  | `overrides` | Replaces **any member** with the value as written — a field, a signal, an `Observable` property. The member is no longer a spy, except a plain function seeded on a method (class factories only), which becomes its spy. Named in both, `overrides` wins. |
37
37
  | `selfReturning` | The named methods answer the double itself — a default like `returns`; a name in both answers `returns`. |
38
38
  | `returnsUndefined` | The list form of `returns: { m: undefined }` — `provideAutoSpy(CartStore, { strict: true, returnsUndefined: ['add', 'remove', 'clear'] })`; a name also in `returns` answers that. `createAutoMock`, `provideAutoSpyForToken` and `registerAutoSpyDefaults` take it too. |
39
- | `returnsClass` | `{ method: Class }` — the method answers a spy of that class, built once per double (`asSpy(double.m())` reaches it; that read is a call). The one-entry form of `returns: { m: asInstance(createSpyFromClass(Class)) }`; `returns` wins for the same name. Every factory that takes `returns` takes it. With nothing seeded, `createAutoMock<T>({ returnsUndefined: [...] })` takes the options first. |
39
+ | `returnsClass` | `{ method: Class }` or `{ method: [Class, options] }` — the method answers a spy of that class, built once per double with those `createSpyFromClass` options (typed against `Class`). `innerDouble(double, 'm')` reaches it without recording a call; `asSpy(double.m())` is a call. The one-entry form of `returns: { m: asInstance(createSpyFromClass(Class)) }`; `returns` wins for the same name. Every factory that takes `returns` takes it. With nothing seeded, `createAutoMock<T>({ returnsUndefined: [...] })` takes the options first. |
40
40
 
41
41
  ### `instanceMethodsToSpyOn` for members discovery cannot see
42
42
 
@@ -100,7 +100,7 @@ export default [
100
100
  | `no-outer-binding-in-mock-factory` | `error` | — | a `vi.mock(path, factory)` factory reading a top-level `const` / `let` / `var` / `class` declared outside `vi.hoisted` — the factory is hoisted above it, so the read is `Cannot access 'x' before initialization` → `const { user } = vi.hoisted(() => ({ user: … }))`. Only reads made while the factory runs count; function declarations, imports, type positions and `vi.doMock` are not reported |
101
101
  | `no-relative-mock-under-builder` | `error` | — | `vi.mock` / `doMock` / `importMock` / `unmock` / `doUnmock` with a specifier starting `.` or `/` in a spec `@angular/build:unit-test` runs — the builder throws on it → `provideAutoSpy(X)`, or `overrideComponentProvider` for a component's own provider. **Silent until** an `@angular/build:unit-test` / `@nx/angular:unit-test` target serving the file is found (the `no-redundant-mock-reset` search) or `{ builder: 'unit-test' }` says so; a tsconfig path alias to a workspace file is reported too (the builder bundles it, so the mock silently does nothing) unless every run's `buildTarget` lists it in `externalDependencies` |
102
102
  | `no-real-wait-in-test` | `warn` | — | a sleep on the real clock — `new Promise((r) => setTimeout(r, N))` in any spelling where `resolve` reaches the timer, `setTimeout(N)` from `node:timers/promises`; a `sleep(ms)` helper once, at its definition; a missing or `0` delay is left alone → `setupFakeTimers()` + `await advanceTimers(N)`, or wait for the outcome (`vi.waitFor`, `fixture.whenStable()`) |
103
- | `no-inline-test-data` | `warn` | — | test data inline in a spec — a data literal over `maxLines` (20) lines, or the same literal `repeats` (3) times in one file with at least `minValues` (2) values, one spelled out → export it once from `<name>.mock.ts` next to the spec (a `tsc`-built library must add `**/*.mock.ts` to its build tsconfig's `exclude`). A copy that reads a name the spec declares → a spec-local `const` instead. A long expected value (`toEqual`, `toMatchObject`, `toHaveBeenCalledWith`…) → keep its shape inline, move the largest part the message names. Never reported: module wiring (`providers`, `imports`…), `it.each` tables, `vi.mock` factories, literals holding a function, short tuples (`[1, 5]`, `['0', '1']`) and flag bags (≤ 3 boolean keys) as repeats, and files named `*.mock.ts` / `*.fixture.ts` / under `__mocks__/` |
103
+ | `no-inline-test-data` | `warn` | — | test data inline in a spec — a data literal over `maxLines` (20) lines, or the same literal `repeats` (3) times in one file with at least `minValues` (2) values, one spelled out → export it once from `<name>.mock.ts` next to the spec (a `tsc`-built library must add `**/*.mock.ts` to its build tsconfig's `exclude`). A copy that reads a name the spec declares → a spec-local `const` instead. A long expected value (`toEqual`, `toMatchObject`, `toHaveBeenCalledWith`…) → keep its shape inline, move the part the message names (the smallest one that gets it under `maxLines`, a plain-value list or template string first). A literal repeated only as an expected value (`.resolves` / `.rejects` / `.not` included) → a spec-local `const`; a short expected object (≤ 3 keys, plain values) is not a repeat. Never reported: module wiring (`providers`, `imports`…), `it.each` tables, `vi.mock` factories, literals holding a function, short tuples (`[1, 5]`, `['0', '1']`) and flag bags (≤ 3 boolean keys) as repeats, and files named `*.mock.ts` / `*.fixture.ts` / under `__mocks__/` |
104
104
  | `no-disabled-testbed-teardown` | `error` | — | `destroyAfterEach: false`, in `initTestEnvironment` or one `configureTestingModule` — every fixture outlives its test, `ngOnDestroy` never runs → delete it (Angular's default since v13) and fix the test that then fails. A config scoped to `**/*.spec.ts` must add the setup file to `files` |
105
105
  | `no-redundant-mock-reset` | `error` | `--fix` / suggest | a mock reset the runner already performs between tests — `vi.clearAllMocks()` / `resetAllMocks()` / `restoreAllMocks()`, `x.mockClear()` / `mockReset()` / `mockRestore()` — standing where nothing the file wrote ran since the runner's own: the first statement of a `beforeEach` no other `beforeEach` precedes, or a clear as the last statement of an `afterEach` → delete it, and the hook with it where that is all it held. A restore or reset in `afterEach` / `afterAll` is never reported: after the last test it is what takes a spy off before the `afterAll` hooks. **Silent** until the flags are known: options `{ clearMocks, restoreMocks, mockReset }` (or `{ configFile }` naming the runner config) first, then a `vitest.config.*` / `vite.config.*` searched upwards from the file and read as text; a config that leaves `clearMocks` out counts it on from Vitest 5 (its default). Where an `@angular/build:unit-test` / `@nx/angular:unit-test` target (found in `angular.json` / `project.json` above the file) also serves the spec, a config flag counts only if that target's `runnerConfig` applies it too — without `runnerConfig` the builder runs Vitest's defaults, so `restoreMocks` / `mockReset` from `vitest.config.ts` do not make a reset dead there, while a clear stays reported on Vitest 5; the rule's inline flags are not narrowed. A config built by a factory or `mergeConfig` from another module is not read through — name its flags as `{ configFile, configFlags: { clearMocks: true } }`, read as if the file set them, so the builder narrowing still applies (`configFlags` needs `configFile`; `doctor` notes the case as `mock-reset-config-unread`). `setupAutoSpy({ restoreMocks: true })` is not the runner's `restoreMocks` (it restores in an `afterEach`, after the test) — never pass the rule a flag only the setup file sets. Flag matches call, never family — `restoreMocks` walks only the spies `vi.spyOn` installed. `--fix` only in a file whose only before-hook it is; a suggestion otherwise; never inside a test body |
106
106
  | `no-unasserted-argument` | `warn` | — | a bare `expect(spy).toHaveBeenCalled()` on evidence from the file: the same subject asserted with `toHaveBeenCalledWith(…)` in another test, or a title containing `with` over a body whose every assertion is a bare call → `toHaveBeenCalledWith(…)` / `mustBeCalledWith(…)`. `not.toHaveBeenCalled()` and the counting matchers are never reported |
@@ -61,9 +61,12 @@ second argument (`{}` included) keeps the first a seed.
61
61
 
62
62
  **A method that returns another class's double is one entry:** `returnsClass: { create: Report }` on
63
63
  any factory that takes `returns` builds `createSpyFromClass(Report)` once per outer double and makes
64
- `create()` answer it. Reach it with `asSpy(factory.create('a'))` — typed `Spy<Report>`, but that read
65
- is a recorded call, so keep `const report = createSpyFromClass(Report)` +
66
- `returns: { create: asInstance(report) }` when the spec asserts `create`'s call count.
64
+ `create()` answer it. Reach it with `innerDouble(factory, 'create')` — typed `Spy<Report>`, and it
65
+ records no call, so a spec asserting `create`'s call count uses it too (`asSpy(factory.create('a'))`
66
+ is a recorded call). `innerDouble` throws for a method with no `returnsClass` entry. When the inner
67
+ double needs options of its own — a `void` method under `strict` — pass a pair:
68
+ `returnsClass: { open: [SnackBarRef, { returnsUndefined: ['dismiss'] }] }`; the options are typed
69
+ against `SnackBarRef`.
67
70
 
68
71
  `createMock<T>()` is the one to reach for on data shapes — it returns a plain `T`, so it satisfies a
69
72
  `no-type-assertion` lint rule without an `eslint-disable` on every fixture. `createMock<T>(undefined)`
@@ -1,10 +1,10 @@
1
1
  import { pendingRequestsReport, assertAngularInternals, instrumentTestBed, onTestingModuleConfigured, onComponentCreated, HTTP_TESTING_BRAND, beforeTestBedReset, verifyOnTeardown } from './chunk-JCTHGJTY.js';
2
2
  export { disableTestBedDiagnostics, enableTestBedDiagnostics, formatSpecTiming, getTestBedTiming, instrumentTestBed, reportSpecTiming } from './chunk-JCTHGJTY.js';
3
- import { failOnUnspiedProvider, onTestBedFileEnd, isLazyDoubleFactory } from './chunk-KHALREYP.js';
3
+ import { failOnUnspiedProvider, onTestBedFileEnd, isLazyDoubleFactory } from './chunk-3457Z3JE.js';
4
4
  import './chunk-T5MQSNRX.js';
5
5
  import './chunk-4JY7KIJG.js';
6
6
  import './chunk-RQLUH6RE.js';
7
- import './chunk-LKXOKRTC.js';
7
+ import './chunk-IQVNZORF.js';
8
8
  import './chunk-F7UPX6YV.js';
9
9
  import './chunk-PC3FAZT3.js';
10
10
  import './chunk-UH2Q7RTQ.js';
@@ -1,6 +1,6 @@
1
1
  import './vitest-mock-types-B17-xaWt.js';
2
2
  import { InjectionToken, AbstractType, Injector, ValueProvider, FactoryProvider, ProviderToken, ChangeDetectorRef } from '@angular/core';
3
- import { h as AddSpyMethodsByReturnTypes, S as Spy, F as Func } from './types-NphKNopY.js';
3
+ import { h as AddSpyMethodsByReturnTypes, S as Spy, F as Func } from './types-CpBA3PjQ.js';
4
4
  import { DomSanitizer } from '@angular/platform-browser';
5
5
  import 'vitest';
6
6
 
@@ -1,7 +1,7 @@
1
1
  import { useVitestAdapter } from './chunk-JFROAGGY.js';
2
2
  import { describeInstance } from './chunk-3OEYMUV3.js';
3
3
  import { angularInternalsError } from './chunk-4JY7KIJG.js';
4
- import { createSpyFromClass } from './chunk-LKXOKRTC.js';
4
+ import { createSpyFromClass } from './chunk-IQVNZORF.js';
5
5
  import './chunk-XZ5JUXKT.js';
6
6
  import './chunk-ZTT2QLMJ.js';
7
7
  import './chunk-YHDBRBGU.js';
@@ -1,6 +1,6 @@
1
1
  import { Type, Injector, FactoryProvider, Provider } from '@angular/core';
2
2
  import { Params, Data, UrlSegment, ActivatedRoute, Route, ResolveData, Navigation, Router, Event } from '@angular/router';
3
- import { h as AddSpyMethodsByReturnTypes } from './types-NphKNopY.js';
3
+ import { h as AddSpyMethodsByReturnTypes } from './types-CpBA3PjQ.js';
4
4
  import { SpyLocation } from '@angular/common/testing';
5
5
 
6
6
  /**
package/dist/angular.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import './vitest-mock-types-B17-xaWt.js';
2
- export { w as AngularTokenProvider, A as AngularValueProvider, a as AutoSpiedInstance, C as ComponentInputs, b as CreateWithAutoSpiesOptions, E as ElementConstructor, N as NativeElementHolder, P as PreparedShallow, R as RenderShallowOptions, c as ResourceStatusLike, d as RunCounter, S as SettleResourceOptions, e as ShallowOverrides, f as ShallowRender, g as SpyRegistry, h as StableOptions, i as createWithAutoSpies, j as flushEffects, k as hostElement, l as injectSpy, p as prepareShallow, m as provideAutoSpy, x as provideAutoSpyForToken, q as queryElement, r as renderShallow, n as runEffect, s as setInputs, o as settleResource, t as stable, u as trackEffectRuns, v as trackRecomputations } from './track-signal-runs-BDQ6MqwO.js';
3
- import { o as DeepPartial, m as ClassType, C as ClassSpyConfiguration, S as Spy, u as OnlyMethodKeysOf, h as AddSpyMethodsByReturnTypes, s as NotAPublicKey } from './types-NphKNopY.js';
4
- export { K as SubjectOf } from './types-NphKNopY.js';
2
+ export { w as AngularTokenProvider, A as AngularValueProvider, a as AutoSpiedInstance, C as ComponentInputs, b as CreateWithAutoSpiesOptions, E as ElementConstructor, N as NativeElementHolder, P as PreparedShallow, R as RenderShallowOptions, c as ResourceStatusLike, d as RunCounter, S as SettleResourceOptions, e as ShallowOverrides, f as ShallowRender, g as SpyRegistry, h as StableOptions, i as createWithAutoSpies, j as flushEffects, k as hostElement, l as injectSpy, p as prepareShallow, m as provideAutoSpy, x as provideAutoSpyForToken, q as queryElement, r as renderShallow, n as runEffect, s as setInputs, o as settleResource, t as stable, u as trackEffectRuns, v as trackRecomputations } from './track-signal-runs-Cw_x1b9n.js';
3
+ import { o as DeepPartial, m as ClassType, C as ClassSpyConfiguration, S as Spy, u as OnlyMethodKeysOf, h as AddSpyMethodsByReturnTypes, s as NotAPublicKey } from './types-CpBA3PjQ.js';
4
+ export { K as SubjectOf } from './types-CpBA3PjQ.js';
5
5
  import { InjectionToken, Provider, Type, WritableSignal, Signal } from '@angular/core';
6
- import { b as AutoMockConfiguration, D as DeepReadonly } from './emission-sync-CNbHIKGX.js';
7
- export { C as CallbackSubscribable, E as EmissionObserver, e as EmissionOptions, f as EmissionSource, S as SubscribableLike, j as expectAllEmissions, k as expectCompletion, l as expectEmission, m as expectEmissions, n as expectError, o as expectNoEmission, p as expectNoEmissionSync, s as setEmissionTimeout } from './emission-sync-CNbHIKGX.js';
6
+ import { b as AutoMockConfiguration, D as DeepReadonly } from './emission-sync-Cv6VnggW.js';
7
+ export { C as CallbackSubscribable, E as EmissionObserver, e as EmissionOptions, f as EmissionSource, S as SubscribableLike, j as expectAllEmissions, k as expectCompletion, l as expectEmission, m as expectEmissions, n as expectError, o as expectNoEmission, p as expectNoEmissionSync, s as setEmissionTimeout } from './emission-sync-Cv6VnggW.js';
8
8
  import { TestAPI } from 'vitest';
9
- export { I as InjectionLog, T as TrackInjectionsOptions, a as TrackedProvider, t as trackInjections } from './track-injections-BkGvSEzV.js';
10
- export { A as AccessorImplementations, R as RestoreProp, c as countMockedProps, m as mockAccessorsProp, a as mockReadonlyProp, b as mockReadonlyPropGetter, d as mockValueProp, e as restoreMockedProps } from './prop-mock-vydpb5c5.js';
9
+ export { I as InjectionLog, T as TrackInjectionsOptions, a as TrackedProvider, t as trackInjections } from './track-injections-xXSrGdpM.js';
10
+ export { A as AccessorImplementations, R as RestoreProp, c as countMockedProps, m as mockAccessorsProp, a as mockReadonlyProp, b as mockReadonlyPropGetter, d as mockValueProp, e as restoreMockedProps } from './prop-mock-CIWAmzz0.js';
11
11
  import '@angular/core/testing';
12
12
 
13
13
  /**
@@ -1,10 +1,10 @@
1
- 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, C as ClassSpyConfiguration, m as ClassType, n as CompleteValueConfig, D as DeepMockProxy, o as DeepPartial, E as ErrorValueConfig, F as Func, p as FunctionSpy, I as InstanceSpyConfiguration, M as MethodReturns, q as MethodReturnsClass, r as Mutable, N as NextValueConfig, s as NotAPublicKey, O as ObservableLike, t as ObservablePropSpyMethods, u as OnlyMethodKeysOf, v as OnlyObservablePropsOf, w as OnlyPropsOf, x as Overload, y as OverloadChoice, z as Overloads, P as PropStubValue, S as Spy, B as SpyDisposable, G as SpyOptions, H as StrictSpyConfiguration, J as SubjectLike, K as SubjectOf, U as UnstubbedCall, L as UnstubbedCallHandler, Q as UnstubbedRead, R as UnstubbedReadHandler, V as ValueConfig, T as ValueConfigPerCall, W as WithMockReturnValue } from './types-NphKNopY.js';
2
- 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, outOfType, resetAutoSpy, restoreSpiedInstance, settleDynamicImport, spyOnOwnMethod, spyOnVoidMethod, stubConstructor, withOverrides } from './core.js';
3
- export { A as AutoMockConfigMarker, a as AutoMockConfigOnly, b as AutoMockConfiguration, c as AutoMocked, d as AutoSpyDefaultEntry, C as CallbackSubscribable, E as EmissionObserver, e as EmissionOptions, f as EmissionSource, S as SubscribableLike, g as autoMocked, h as clearAutoSpyDefaults, i as createAutoMock, j as expectAllEmissions, k as expectCompletion, l as expectEmission, m as expectEmissions, n as expectError, o as expectNoEmission, p as expectNoEmissionSync, r as registerAutoSpyDefaults, s as setEmissionTimeout } from './emission-sync-CNbHIKGX.js';
4
- export { c as createFunctionSpy, d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-Dhlx2i2x.js';
5
- 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-vydpb5c5.js';
6
- export { C as CreateNestUnitOptions, N as NestUnit, a as NestUnitClass, b as NestUnitProvider, c as NestUnitSpies, d as createNestUnit } from './nest-unit-DdJ251KZ.js';
7
- export { A as AngularValueProvider, a as AutoSpiedInstance, C as ComponentInputs, b as CreateWithAutoSpiesOptions, E as ElementConstructor, N as NativeElementHolder, P as PreparedShallow, R as RenderShallowOptions, c as ResourceStatusLike, d as RunCounter, S as SettleResourceOptions, e as ShallowOverrides, f as ShallowRender, g as SpyRegistry, h as StableOptions, i as createWithAutoSpies, j as flushEffects, k as hostElement, l as injectSpy, p as prepareShallow, m as provideAutoSpy, q as queryElement, r as renderShallow, n as runEffect, s as setInputs, o as settleResource, t as stable, u as trackEffectRuns, v as trackRecomputations } from './track-signal-runs-BDQ6MqwO.js';
1
+ 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, C as ClassSpyConfiguration, m as ClassType, n as CompleteValueConfig, D as DeepMockProxy, o as DeepPartial, E as ErrorValueConfig, F as Func, p as FunctionSpy, I as InstanceSpyConfiguration, M as MethodReturns, q as MethodReturnsClass, r as Mutable, N as NextValueConfig, s as NotAPublicKey, O as ObservableLike, t as ObservablePropSpyMethods, u as OnlyMethodKeysOf, v as OnlyObservablePropsOf, w as OnlyPropsOf, x as Overload, y as OverloadChoice, z as Overloads, P as PropStubValue, R as ReturnsClassEntry, S as Spy, B as SpyDisposable, G as SpyOptions, H as StrictSpyConfiguration, J as SubjectLike, K as SubjectOf, U as UnstubbedCall, L as UnstubbedCallHandler, Q as UnstubbedRead, T as UnstubbedReadHandler, V as ValueConfig, W as ValueConfigPerCall, X as WithMockReturnValue } from './types-CpBA3PjQ.js';
2
+ 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, innerDouble, mockConstructor, mockDeep, moduleNamespace, narrow, outOfType, resetAutoSpy, restoreSpiedInstance, settleDynamicImport, spyOnOwnMethod, spyOnVoidMethod, stubConstructor, withOverrides } from './core.js';
3
+ export { A as AutoMockConfigMarker, a as AutoMockConfigOnly, b as AutoMockConfiguration, c as AutoMocked, d as AutoSpyDefaultEntry, C as CallbackSubscribable, E as EmissionObserver, e as EmissionOptions, f as EmissionSource, S as SubscribableLike, g as autoMocked, h as clearAutoSpyDefaults, i as createAutoMock, j as expectAllEmissions, k as expectCompletion, l as expectEmission, m as expectEmissions, n as expectError, o as expectNoEmission, p as expectNoEmissionSync, r as registerAutoSpyDefaults, s as setEmissionTimeout } from './emission-sync-Cv6VnggW.js';
4
+ export { c as createFunctionSpy, d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-DM9vHPzU.js';
5
+ 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-CIWAmzz0.js';
6
+ export { C as CreateNestUnitOptions, N as NestUnit, a as NestUnitClass, b as NestUnitProvider, c as NestUnitSpies, d as createNestUnit } from './nest-unit-DG-qxd6Q.js';
7
+ export { A as AngularValueProvider, a as AutoSpiedInstance, C as ComponentInputs, b as CreateWithAutoSpiesOptions, E as ElementConstructor, N as NativeElementHolder, P as PreparedShallow, R as RenderShallowOptions, c as ResourceStatusLike, d as RunCounter, S as SettleResourceOptions, e as ShallowOverrides, f as ShallowRender, g as SpyRegistry, h as StableOptions, i as createWithAutoSpies, j as flushEffects, k as hostElement, l as injectSpy, p as prepareShallow, m as provideAutoSpy, q as queryElement, r as renderShallow, n as runEffect, s as setInputs, o as settleResource, t as stable, u as trackEffectRuns, v as trackRecomputations } from './track-signal-runs-Cw_x1b9n.js';
8
8
  import '@angular/core';
9
9
  import '@angular/core/testing';
10
10
 
@@ -1,17 +1,17 @@
1
- import { withTestBedSplitExplained } from './chunk-KHALREYP.js';
2
- export { injectSpy, provideAutoSpy } from './chunk-KHALREYP.js';
1
+ import { withTestBedSplitExplained } from './chunk-3457Z3JE.js';
2
+ export { injectSpy, provideAutoSpy } from './chunk-3457Z3JE.js';
3
3
  import { stable, flushEffects } from './chunk-RHGDQQNC.js';
4
4
  export { flushEffects, stable } from './chunk-RHGDQQNC.js';
5
5
  import { readSignalSymbol } from './chunk-T5MQSNRX.js';
6
6
  import { angularInternalsError } from './chunk-4JY7KIJG.js';
7
7
  import './chunk-VLEU3CWT.js';
8
- import { createSpyForToken } from './chunk-RAJTKMDV.js';
9
- export { createNestUnit } from './chunk-RAJTKMDV.js';
10
- export { adoptMock, asInstance, asInstances, asSpy, assertMocked, captureArg, createFixture, createFixtureFactory, createLog, createMock, createSpyClass, createSpyFromInstance, describeDuplicateCopies, expectAllEmissions, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, expectNoEmissionSync, flushEventLoop, flushEventLoopUntil, getPackageCopies, mockConstructor, mockDeep, moduleNamespace, narrow, outOfType, restoreSpiedInstance, setEmissionTimeout, settleDynamicImport, spyOnOwnMethod, spyOnVoidMethod, stubConstructor, withOverrides } from './chunk-3IINYLDB.js';
8
+ import { createSpyForToken } from './chunk-OL2J4K4Z.js';
9
+ export { createNestUnit } from './chunk-OL2J4K4Z.js';
10
+ export { adoptMock, asInstance, asInstances, asSpy, assertMocked, captureArg, createFixture, createFixtureFactory, createLog, createMock, createSpyClass, createSpyFromInstance, describeDuplicateCopies, expectAllEmissions, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, expectNoEmissionSync, flushEventLoop, flushEventLoopUntil, getPackageCopies, mockConstructor, mockDeep, moduleNamespace, narrow, outOfType, restoreSpiedInstance, setEmissionTimeout, settleDynamicImport, spyOnOwnMethod, spyOnVoidMethod, stubConstructor, withOverrides } from './chunk-7MDSR745.js';
11
11
  import { mockValueProp } from './chunk-RQLUH6RE.js';
12
12
  export { countMockedProps, mockAccessorsProp, mockReadonlyProp, mockReadonlyPropGetter, mockValueProp, reportPropsOutsideHooks, restoreMockedProps } from './chunk-RQLUH6RE.js';
13
- import { closestName } from './chunk-LKXOKRTC.js';
14
- export { autoMocked, clearAutoSpy, clearAutoSpyDefaults, createAutoMock, createSpyFromClass, registerAutoSpyDefaults, resetAutoSpy } from './chunk-LKXOKRTC.js';
13
+ import { closestName } from './chunk-IQVNZORF.js';
14
+ export { autoMocked, clearAutoSpy, clearAutoSpyDefaults, createAutoMock, createSpyFromClass, innerDouble, registerAutoSpyDefaults, resetAutoSpy } from './chunk-IQVNZORF.js';
15
15
  import { fakeClockBacklog } from './chunk-SF4GKKN4.js';
16
16
  import './chunk-SOROJD3W.js';
17
17
  import './chunk-75WPOZKE.js';
package/dist/bun.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- 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, C as ClassSpyConfiguration, m as ClassType, n as CompleteValueConfig, D as DeepMockProxy, o as DeepPartial, E as ErrorValueConfig, F as Func, p as FunctionSpy, I as InstanceSpyConfiguration, M as MethodReturns, q as MethodReturnsClass, r as Mutable, N as NextValueConfig, s as NotAPublicKey, O as ObservableLike, t as ObservablePropSpyMethods, u as OnlyMethodKeysOf, v as OnlyObservablePropsOf, w as OnlyPropsOf, x as Overload, y as OverloadChoice, z as Overloads, P as PropStubValue, S as Spy, B as SpyDisposable, G as SpyOptions, H as StrictSpyConfiguration, J as SubjectLike, K as SubjectOf, U as UnstubbedCall, L as UnstubbedCallHandler, Q as UnstubbedRead, R as UnstubbedReadHandler, V as ValueConfig, T as ValueConfigPerCall, W as WithMockReturnValue } from './types-NphKNopY.js';
2
- 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, outOfType, resetAutoSpy, restoreSpiedInstance, settleDynamicImport, spyOnOwnMethod, spyOnVoidMethod, stubConstructor, withOverrides } from './core.js';
3
- export { A as AutoMockConfigMarker, a as AutoMockConfigOnly, b as AutoMockConfiguration, c as AutoMocked, d as AutoSpyDefaultEntry, C as CallbackSubscribable, E as EmissionObserver, e as EmissionOptions, f as EmissionSource, S as SubscribableLike, g as autoMocked, h as clearAutoSpyDefaults, i as createAutoMock, j as expectAllEmissions, k as expectCompletion, l as expectEmission, m as expectEmissions, n as expectError, o as expectNoEmission, p as expectNoEmissionSync, r as registerAutoSpyDefaults, s as setEmissionTimeout } from './emission-sync-CNbHIKGX.js';
4
- export { c as createFunctionSpy, d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-Dhlx2i2x.js';
5
- 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-vydpb5c5.js';
6
- export { C as CreateNestUnitOptions, N as NestUnit, a as NestUnitClass, b as NestUnitProvider, c as NestUnitSpies, d as createNestUnit } from './nest-unit-DdJ251KZ.js';
1
+ 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, C as ClassSpyConfiguration, m as ClassType, n as CompleteValueConfig, D as DeepMockProxy, o as DeepPartial, E as ErrorValueConfig, F as Func, p as FunctionSpy, I as InstanceSpyConfiguration, M as MethodReturns, q as MethodReturnsClass, r as Mutable, N as NextValueConfig, s as NotAPublicKey, O as ObservableLike, t as ObservablePropSpyMethods, u as OnlyMethodKeysOf, v as OnlyObservablePropsOf, w as OnlyPropsOf, x as Overload, y as OverloadChoice, z as Overloads, P as PropStubValue, R as ReturnsClassEntry, S as Spy, B as SpyDisposable, G as SpyOptions, H as StrictSpyConfiguration, J as SubjectLike, K as SubjectOf, U as UnstubbedCall, L as UnstubbedCallHandler, Q as UnstubbedRead, T as UnstubbedReadHandler, V as ValueConfig, W as ValueConfigPerCall, X as WithMockReturnValue } from './types-CpBA3PjQ.js';
2
+ 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, innerDouble, mockConstructor, mockDeep, moduleNamespace, narrow, outOfType, resetAutoSpy, restoreSpiedInstance, settleDynamicImport, spyOnOwnMethod, spyOnVoidMethod, stubConstructor, withOverrides } from './core.js';
3
+ export { A as AutoMockConfigMarker, a as AutoMockConfigOnly, b as AutoMockConfiguration, c as AutoMocked, d as AutoSpyDefaultEntry, C as CallbackSubscribable, E as EmissionObserver, e as EmissionOptions, f as EmissionSource, S as SubscribableLike, g as autoMocked, h as clearAutoSpyDefaults, i as createAutoMock, j as expectAllEmissions, k as expectCompletion, l as expectEmission, m as expectEmissions, n as expectError, o as expectNoEmission, p as expectNoEmissionSync, r as registerAutoSpyDefaults, s as setEmissionTimeout } from './emission-sync-Cv6VnggW.js';
4
+ export { c as createFunctionSpy, d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-DM9vHPzU.js';
5
+ 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-CIWAmzz0.js';
6
+ export { C as CreateNestUnitOptions, N as NestUnit, a as NestUnitClass, b as NestUnitProvider, c as NestUnitSpies, d as createNestUnit } from './nest-unit-DG-qxd6Q.js';
package/dist/bun.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import './chunk-VLEU3CWT.js';
2
- export { createNestUnit } from './chunk-RAJTKMDV.js';
3
- export { adoptMock, asInstance, asInstances, asSpy, assertMocked, captureArg, createFixture, createFixtureFactory, createLog, createMock, createSpyClass, createSpyFromInstance, describeDuplicateCopies, expectAllEmissions, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, expectNoEmissionSync, flushEventLoop, flushEventLoopUntil, getPackageCopies, mockConstructor, mockDeep, moduleNamespace, narrow, outOfType, restoreSpiedInstance, setEmissionTimeout, settleDynamicImport, spyOnOwnMethod, spyOnVoidMethod, stubConstructor, withOverrides } from './chunk-3IINYLDB.js';
2
+ export { createNestUnit } from './chunk-OL2J4K4Z.js';
3
+ export { adoptMock, asInstance, asInstances, asSpy, assertMocked, captureArg, createFixture, createFixtureFactory, createLog, createMock, createSpyClass, createSpyFromInstance, describeDuplicateCopies, expectAllEmissions, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, expectNoEmissionSync, flushEventLoop, flushEventLoopUntil, getPackageCopies, mockConstructor, mockDeep, moduleNamespace, narrow, outOfType, restoreSpiedInstance, setEmissionTimeout, settleDynamicImport, spyOnOwnMethod, spyOnVoidMethod, stubConstructor, withOverrides } from './chunk-7MDSR745.js';
4
4
  export { countMockedProps, mockAccessorsProp, mockReadonlyProp, mockReadonlyPropGetter, mockValueProp, reportPropsOutsideHooks, restoreMockedProps } from './chunk-RQLUH6RE.js';
5
- export { autoMocked, clearAutoSpy, clearAutoSpyDefaults, createAutoMock, createSpyFromClass, registerAutoSpyDefaults, resetAutoSpy } from './chunk-LKXOKRTC.js';
5
+ export { autoMocked, clearAutoSpy, clearAutoSpyDefaults, createAutoMock, createSpyFromClass, innerDouble, registerAutoSpyDefaults, resetAutoSpy } from './chunk-IQVNZORF.js';
6
6
  import './chunk-SF4GKKN4.js';
7
7
  import './chunk-SOROJD3W.js';
8
8
  import './chunk-75WPOZKE.js';
@@ -1,5 +1,5 @@
1
1
  import { currentSpecFile } from './chunk-RQLUH6RE.js';
2
- import { createSpyFromClass } from './chunk-LKXOKRTC.js';
2
+ import { createSpyFromClass } from './chunk-IQVNZORF.js';
3
3
  import { isAutoSpyLike, misconfigurationThrows, reportMisconfiguration } from './chunk-TXC3L3FO.js';
4
4
  import { count, displayPath, sourceClassName } from './chunk-DYAS4OK4.js';
5
5
  import { setup, angularComponentStub, angularInjectSpyReal, angularTestBedCopies, installationVitest } from './chunk-IATDAQMO.js';
@@ -1,5 +1,5 @@
1
1
  import { mockValueProp, mockAccessorsProp } from './chunk-RQLUH6RE.js';
2
- import { resolveConfiguration, mergeAutoSpyDefaults, resolveReadGuard, mergeMethodNames, getCallableMemberNames, createTrackedPropSpy, applyConfiguredReturns, createSpyFromClass, warnOnUnknownMethods, warnOnAccessorNamingAMethod, resolveAccessors, createAccessorsSpies, ownerOf, createProxyPropStore, storeWriteTraps, describeStoredProp, hasStoredProp, isProtocolKey, isDeletedProp, readStoredAccessor, NOT_STORED, disposeAutoSpy, writeStoredValue } from './chunk-LKXOKRTC.js';
2
+ import { resolveConfiguration, mergeAutoSpyDefaults, resolveReadGuard, mergeMethodNames, getCallableMemberNames, createTrackedPropSpy, applyConfiguredReturns, recordInnerDoubles, createSpyFromClass, warnOnUnknownMethods, warnOnAccessorNamingAMethod, resolveAccessors, createAccessorsSpies, ownerOf, createProxyPropStore, storeWriteTraps, describeStoredProp, hasStoredProp, isProtocolKey, isDeletedProp, readStoredAccessor, NOT_STORED, disposeAutoSpy, writeStoredValue } from './chunk-IQVNZORF.js';
3
3
  import { fakeClockAdvice, fakeClockBacklog } from './chunk-SF4GKKN4.js';
4
4
  import { unpatchedSetTimeout, unpatchedClearTimeout } from './chunk-SOROJD3W.js';
5
5
  import { redefineFailure } from './chunk-F7UPX6YV.js';
@@ -48,6 +48,7 @@ function withoutRealMembers(instance, label, config) {
48
48
  return {
49
49
  ...config,
50
50
  returns: Object.fromEntries(Object.entries(config.returns).filter(([name]) => kept(name))),
51
+ classReturns: Object.fromEntries(Object.entries(config.classReturns).filter(([name]) => kept(name))),
51
52
  selfReturning: config.selfReturning.filter(kept)
52
53
  };
53
54
  }
@@ -203,7 +204,9 @@ function createSpyFromInstance(instance, methodsToSpyOnOrConfig) {
203
204
  config.observablePropsToSpyOn.forEach((name) => installMember(instance, name, createTrackedPropSpy(name, reads), restores));
204
205
  installAccessorSpies(instance, config, restores, reads);
205
206
  const label = `createSpyFromInstance(${className ?? "object"})`;
206
- applyConfiguredReturns(instance, label, withoutRealMembers(instance, label, config), () => getCallableMemberNames(instance));
207
+ const applied = withoutRealMembers(instance, label, config);
208
+ applyConfiguredReturns(instance, label, applied, () => getCallableMemberNames(instance));
209
+ recordInnerDoubles(instance, applied.classReturns);
207
210
  for (const key of Reflect.ownKeys(config.overrides)) {
208
211
  installMember(instance, key, Reflect.get(config.overrides, key), restores);
209
212
  }
@@ -111,6 +111,26 @@ function mergeInto(defaults, written) {
111
111
  }
112
112
  return merged;
113
113
  }
114
+
115
+ // src/lib/inner-double.ts
116
+ function registry2() {
117
+ return globalThis.__vitestAutoSpyInnerDoubles__ ??= /* @__PURE__ */ new WeakMap();
118
+ }
119
+ function recordInnerDoubles(outer, doubles) {
120
+ const entries = Object.entries(doubles ?? {});
121
+ if (entries.length > 0) {
122
+ registry2().set(outer, new Map([...registry2().get(outer) ?? [], ...entries]));
123
+ }
124
+ }
125
+ function innerDouble(outer, method) {
126
+ const double = registry2().get(outer)?.get(method);
127
+ if (double === void 0) {
128
+ throw new Error(
129
+ `[vitest-auto-spy] innerDouble: '${method}' has no returnsClass entry on this double, so there is no inner double to read. Name it in the configuration, { returnsClass: { ${method}: SomeClass } }, or read what it answers with asSpy(double.${method}(\u2026)).`
130
+ );
131
+ }
132
+ return double;
133
+ }
114
134
  function isAccessorBag(value) {
115
135
  return typeof value === "object" && value !== null && "getters" in value && "setters" in value;
116
136
  }
@@ -428,8 +448,10 @@ function buildAutoMock(overrides, config, boundary) {
428
448
  seeded,
429
449
  "returnsUndefined"
430
450
  );
431
- applyMockReturns(mock, config?.returnsClass && withClassReturns({}, config.returnsClass), seeded, "returnsClass");
451
+ const inner = config?.returnsClass && classDoubles(config.returnsClass, (name) => seeded.has(name) || Object.hasOwn(config.returns ?? {}, name));
452
+ applyMockReturns(mock, inner, seeded, "returnsClass");
432
453
  applyMockReturns(mock, config?.returns, seeded);
454
+ recordInnerDoubles(mock, inner);
433
455
  return mock;
434
456
  }
435
457
  function applyObservableProps(mock, names, reads) {
@@ -842,6 +864,7 @@ var EMPTY_CONFIGURATION = {
842
864
  fillMissing: void 0,
843
865
  lazySpies: void 0,
844
866
  returns: {},
867
+ classReturns: {},
845
868
  selfReturning: [],
846
869
  overrides: {},
847
870
  strict: void 0,
@@ -1010,6 +1033,8 @@ function resolveConfiguration(methodsToSpyOnOrConfig) {
1010
1033
  if (Array.isArray(methodsToSpyOnOrConfig)) {
1011
1034
  return { ...EMPTY_CONFIGURATION, methodsToSpyOn: methodsToSpyOnOrConfig };
1012
1035
  }
1036
+ const returns = methodsToSpyOnOrConfig.returns ?? {};
1037
+ const classReturns = classDoubles(methodsToSpyOnOrConfig.returnsClass, (name) => Object.hasOwn(returns, name));
1013
1038
  return {
1014
1039
  methodsToSpyOn: methodsToSpyOnOrConfig.methodsToSpyOn ?? [],
1015
1040
  onlyMethodsToSpyOn: methodsToSpyOnOrConfig.onlyMethodsToSpyOn ?? [],
@@ -1021,9 +1046,10 @@ function resolveConfiguration(methodsToSpyOnOrConfig) {
1021
1046
  fillMissing: methodsToSpyOnOrConfig.fillMissing,
1022
1047
  lazySpies: methodsToSpyOnOrConfig.lazySpies,
1023
1048
  returns: withUndefinedReturns(
1024
- withClassReturns(methodsToSpyOnOrConfig.returns ?? {}, methodsToSpyOnOrConfig.returnsClass),
1049
+ Object.keys(classReturns).length > 0 ? { ...classReturns, ...returns } : returns,
1025
1050
  methodsToSpyOnOrConfig.returnsUndefined
1026
1051
  ),
1052
+ classReturns,
1027
1053
  selfReturning: methodsToSpyOnOrConfig.selfReturning ?? [],
1028
1054
  overrides: methodsToSpyOnOrConfig.overrides ?? {},
1029
1055
  strict: methodsToSpyOnOrConfig.strict,
@@ -1034,11 +1060,12 @@ function resolveConfiguration(methodsToSpyOnOrConfig) {
1034
1060
  function withUndefinedReturns(returns, names) {
1035
1061
  return names?.length ? { ...Object.fromEntries(names.map((name) => [name, void 0])), ...returns } : returns;
1036
1062
  }
1037
- function withClassReturns(returns, classes) {
1038
- const built = Object.entries(classes ?? {}).flatMap(
1039
- ([name, ReturnedClass]) => ReturnedClass === void 0 || Object.hasOwn(returns, name) ? [] : [[name, createSpyFromClass2(ReturnedClass)]]
1063
+ function classDoubles(classes, answered) {
1064
+ return Object.fromEntries(
1065
+ Object.entries(classes ?? {}).flatMap(
1066
+ ([name, entry]) => entry === void 0 || answered(name) ? [] : [[name, typeof entry === "function" ? createSpyFromClass2(entry) : createSpyFromClass2(entry[0], entry[1])]]
1067
+ )
1040
1068
  );
1041
- return built.length > 0 ? { ...Object.fromEntries(built), ...returns } : returns;
1042
1069
  }
1043
1070
  var warnedThenables = /* @__PURE__ */ new WeakSet();
1044
1071
  function warnOnHeldBackThen(ObjectClass, config) {
@@ -1064,6 +1091,7 @@ function createSpyFromClass2(ObjectClass, methodsToSpyOnOrConfig) {
1064
1091
  config,
1065
1092
  () => getDeclaredMethodNames(ObjectClass.prototype)
1066
1093
  );
1094
+ recordInnerDoubles(autoSpy, config.classReturns);
1067
1095
  }
1068
1096
  if (Reflect.ownKeys(config.overrides).length > 0) {
1069
1097
  applyOverrides(autoSpy, config.overrides, ObjectClass.name, (key) => answersWithMethodSpy(ObjectClass, config, key));
@@ -1165,4 +1193,4 @@ function hasNothingToRead(ObjectClass, accessors, config) {
1165
1193
  config.onlyMethodsToSpyOn.length === 0;
1166
1194
  }
1167
1195
 
1168
- export { NOT_STORED, applyConfiguredReturns, autoMocked, clearAutoSpy, clearAutoSpyDefaults, closestName, createAccessorsSpies, createAutoMock, createProxyPropStore, createSpyFromClass2 as createSpyFromClass, createTrackedPropSpy, describeStoredProp, disposeAutoSpy, getCallableMemberNames, hasStoredProp, isDeletedProp, isProtocolKey, mergeAutoSpyDefaults, mergeMethodNames, ownerOf, readStoredAccessor, registerAutoSpyDefaults, resetAutoSpy, resolveAccessors, resolveConfiguration, resolveReadGuard, storeWriteTraps, warnOnAccessorNamingAMethod, warnOnUnknownMethods, writeStoredValue };
1196
+ export { NOT_STORED, applyConfiguredReturns, autoMocked, clearAutoSpy, clearAutoSpyDefaults, closestName, createAccessorsSpies, createAutoMock, createProxyPropStore, createSpyFromClass2 as createSpyFromClass, createTrackedPropSpy, describeStoredProp, disposeAutoSpy, getCallableMemberNames, hasStoredProp, innerDouble, isDeletedProp, isProtocolKey, mergeAutoSpyDefaults, mergeMethodNames, ownerOf, readStoredAccessor, recordInnerDoubles, registerAutoSpyDefaults, resetAutoSpy, resolveAccessors, resolveConfiguration, resolveReadGuard, storeWriteTraps, warnOnAccessorNamingAMethod, warnOnUnknownMethods, writeStoredValue };
@@ -1,4 +1,4 @@
1
- import { createSpyFromClass, createAutoMock } from './chunk-LKXOKRTC.js';
1
+ import { createSpyFromClass, createAutoMock } from './chunk-IQVNZORF.js';
2
2
  import { sourceClassName } from './chunk-DYAS4OK4.js';
3
3
  import { trackInjectionsUntracked, nestUnitRefusals } from './chunk-IATDAQMO.js';
4
4
  import { withDocs } from './chunk-ENCEEH23.js';