vitest-auto-spy 5.60.0 → 5.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -250,6 +250,9 @@ Rules that carry most of the value:
250
250
  In [`agent-docs/return-helpers.md`](./agent-docs/return-helpers.md). Read it when stubbing a return value: `calledWith`, `resolveWith`, `nextWith`, `returnSubject` and the rest, by return type.
251
251
 
252
252
  <!-- agents-outline: agent-docs/return-helpers.md -->
253
+
254
+ - Keeping an awaited collaborator pending
255
+
253
256
  <!-- /agents-outline -->
254
257
 
255
258
  ---
@@ -455,6 +458,7 @@ In [`agent-docs/doubles.md`](./agent-docs/doubles.md). Read it when production c
455
458
  ## 13. Angular
456
459
 
457
460
  In [`agent-docs/angular.md`](./agent-docs/angular.md). Read it for any spec that uses `TestBed`, signals, Angular HTTP, the router or an Angular double.
461
+ For selected void window methods, use `createWindowSpies` from `/angular/doubles`; the window recipe is in that file.
458
462
 
459
463
  <!-- agents-outline: agent-docs/angular.md -->
460
464
 
package/CHANGELOG.md CHANGED
@@ -10,6 +10,29 @@ The latest released version here must always match the one published on
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [5.63.0] - 2026-10-21
14
+
15
+ ### Added
16
+
17
+ - `createDeferred<T>()` returns a typed pending promise with detached `resolve` and `reject`
18
+ functions, for assertions before an awaited collaborator finishes. It defaults to `void` and
19
+ works on supported runtimes without `Promise.withResolvers`.
20
+
21
+ ## [5.62.0] - 2026-10-20
22
+
23
+ ### Fixed
24
+
25
+ - **`prefer-settle-dynamic-import` recognises Angular provider setup in setup hooks.** A namespace
26
+ loaded for providers is allowed after logger or fixture preparation. Imports after application
27
+ actions remain checked. The English and Russian rule guides distinguish provider loading from
28
+ waiting for handlers, and clarify that `Promise.resolve()` does not take an event-loop turn.
29
+
30
+ ## [5.61.0] - 2026-10-07
31
+
32
+ ### Added
33
+
34
+ - `createWindowSpies` in `/angular/doubles`: typed, configured no-op spies for selected void window methods, including `location.reload` and `parent.postMessage`, composable with existing window overrides.
35
+
13
36
  ## [5.60.0] - 2026-10-06
14
37
 
15
38
  ### Added
@@ -6841,7 +6864,10 @@ moved under 1 %: `/angular` +192 B (+1.0 %) for the override queue and the HTTP
6841
6864
  This copy ships with the package and carries 5.x only. Releases before 5.0.0 are in the
6842
6865
  [full changelog](https://github.com/ASDAlexey/vitest-auto-spy/blob/master/CHANGELOG.md).
6843
6866
 
6844
- [Unreleased]: https://github.com/ASDAlexey/vitest-auto-spy/compare/v5.60.0...HEAD
6867
+ [Unreleased]: https://github.com/ASDAlexey/vitest-auto-spy/compare/v5.63.0...HEAD
6868
+ [5.63.0]: https://github.com/ASDAlexey/vitest-auto-spy/compare/v5.62.0...v5.63.0
6869
+ [5.62.0]: https://github.com/ASDAlexey/vitest-auto-spy/compare/v5.61.0...v5.62.0
6870
+ [5.61.0]: https://github.com/ASDAlexey/vitest-auto-spy/compare/v5.60.0...v5.61.0
6845
6871
  [5.60.0]: https://github.com/ASDAlexey/vitest-auto-spy/compare/v5.59.1...v5.60.0
6846
6872
  [5.59.1]: https://github.com/ASDAlexey/vitest-auto-spy/compare/v5.59.0...v5.59.1
6847
6873
  [5.59.0]: https://github.com/ASDAlexey/vitest-auto-spy/compare/v5.58.0...v5.59.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.3%20kB-brightgreen)](#install)
18
+ [![minzipped size](https://img.shields.io/badge/minzip-30.4%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)
@@ -42,6 +42,7 @@ replacement for [`jest-auto-spies`](https://www.npmjs.com/package/jest-auto-spie
42
42
 
43
43
  - **A spy of every method from a class**, typed, with helpers that match each return type:
44
44
  `resolveWith` for a `Promise`, `nextWith` for an `Observable`, `mockReturnValue` for the rest.
45
+ `createDeferred<T>()` keeps an awaited collaborator pending until the test releases it.
45
46
  - **Answers per argument list**: `calledWith(1).mockReturnValue(...)`.
46
47
  - **A spy from a type alone**: `createAutoMock<T>()` and `mockDeep<T>()`.
47
48
  - **Angular `TestBed` in one line**: `provideAutoSpy(ApiService)`, then `injectSpy(ApiService)`.
@@ -1167,6 +1168,7 @@ that keeps the cut inside; `node scripts/check-readme-npm-cut.mjs --write` resiz
1167
1168
  - [Synchronous methods](#synchronous-methods)
1168
1169
  - [Matching order, and re-configuring the same arguments](#matching-order-and-re-configuring-the-same-arguments)
1169
1170
  - [Promise-returning methods](#promise-returning-methods)
1171
+ - [Keeping a promise pending](#keeping-a-promise-pending--createdeferred)
1170
1172
  - [Observable-returning methods & Observable properties](#observable-returning-methods--observable-properties)
1171
1173
  - [Standalone observable builder](#standalone-observable-builder)
1172
1174
  - [Getters & setters](#getters--setters)
@@ -2360,6 +2362,33 @@ myService.getProducts.resolveWithPerCall([{ value: ['a'] }, { value: ['b'] }]);
2360
2362
  myService.getProducts.calledWith(1).resolveWith(['one']);
2361
2363
  ```
2362
2364
 
2365
+ ### Keeping a promise pending — `createDeferred`
2366
+
2367
+ `createDeferred<T>()` returns `{ promise, resolve, reject }`. Use it to check what happens before
2368
+ an awaited collaborator finishes, then release that collaborator without timers.
2369
+
2370
+ ```ts
2371
+ import { expect } from 'vitest';
2372
+ import { createDeferred } from 'vitest-auto-spy';
2373
+
2374
+ const home = createDeferred<boolean>();
2375
+ const events: string[] = [];
2376
+ const navigation = home.promise.then((ok) => {
2377
+ events.push('deeplink');
2378
+ return ok;
2379
+ });
2380
+ expect(events).toEqual([]);
2381
+ home.resolve(true);
2382
+ await expect(navigation).resolves.toBe(true);
2383
+ expect(events).toEqual(['deeplink']);
2384
+ ```
2385
+
2386
+ `resolve` accepts a value or a `PromiseLike<T>`; `reject(reason)` rejects with that reason.
2387
+ `createDeferred()` defaults to `void`, so `resolve()` needs no argument. Settle the promise before
2388
+ awaiting the operation that depends on it, or the test will wait forever. Each call creates an
2389
+ independent native promise; the first settlement wins. No fake timers or `Promise.withResolvers`
2390
+ are required. Import from `/bun`, `/node` or `/rstest` when using those runners.
2391
+
2363
2392
  ## Observable-returning methods & Observable properties
2364
2393
 
2365
2394
  Methods that return an `Observable`, and `Observable` properties listed in `observablePropsToSpyOn`,
@@ -3125,6 +3154,7 @@ only the ones you need. Every helper, with its signature: [API](https://asdalexe
3125
3154
  | `provideLocationDouble()` / `injectLocationDouble()` / `createLocationDouble()` | `/angular-router` | Angular's own `SpyLocation` and `MockLocationStrategy` in one call — a real history, the `urlChanges` journal, `simulateUrlPop()` / `simulateHashChange()` for the browser's half of the contract; `Location` is `providedIn: 'root'`, so a spec that forgets the provider silently drives the platform's real one |
3126
3155
  | `createForm(model, schema?)` / `registerFormMatchers()` | `/signal-forms` | A signal form built where `form()` can inject, and `expect(field).toHaveFieldErrors(['required'])` over what it produced |
3127
3156
  | `provideWindowDouble(TOKEN, over?)` / `provideDocumentDouble(over?)` | `/angular/doubles` | A `window` / `document` merged **over** the real jsdom one, so members the spec never named still answer; the globals stay untouched |
3157
+ | `createWindowSpies(selection)` | `/angular/doubles` | Typed no-op spies for selected void window methods: `createWindowSpies({ location: ['reload'], parent: ['postMessage'] })`; pass them as window overrides. |
3128
3158
  | `provideMatDialogData(TOKEN, data)` / `provideMatDialogRef(Ref, init?)` | `/angular/doubles` | The Material dialog trio without `@angular/material` as a dependency — the token and the ref class are arguments, `afterClosed()` still answers after the close |
3129
3159
  | `providePlatform(platform, flags?)` | `/angular/doubles` | `PLATFORM_ID` plus the app's own `isBrowser` / `isServer` tokens, always agreeing |
3130
3160
  | `provideDomSanitizerDouble()` / `provideChangeDetectorRefDouble()` | `/angular/doubles` | A `DomSanitizer` whose bypass spies return Angular's real safe values; a `ChangeDetectorRef` of four spies answering `undefined` (`create…Double()` for the bare double) |
@@ -862,6 +862,32 @@ Five things to know:
862
862
  `win.Promise.resolve()`, `win.Object.keys(x)` and `new win.Event('x')` work, and
863
863
  `win.Event === window.Event` holds — which is what `instanceof` in production code needs.
864
864
 
865
+ `createWindowSpies` creates typed spies for selected `void` methods, including nested window members.
866
+ The spies return `undefined` without invoking browser methods.
867
+
868
+ ```ts
869
+ import { InjectionToken } from '@angular/core';
870
+ import { TestBed } from '@angular/core/testing';
871
+ import { expect } from 'vitest';
872
+ import { createWindowSpies, provideWindowDouble } from 'vitest-auto-spy/angular/doubles';
873
+
874
+ const WINDOW = new InjectionToken<Window>('WINDOW');
875
+ const spies = createWindowSpies({ location: ['reload'], parent: ['postMessage'] });
876
+ TestBed.configureTestingModule({
877
+ providers: [provideWindowDouble(WINDOW, { ...spies, location: { ...spies.location, hostname: 'tv.kion.ru' } })],
878
+ });
879
+ const win = TestBed.inject(WINDOW);
880
+ win.location.reload();
881
+ win.parent.postMessage('ready', '*');
882
+ expect(spies.location.reload).toHaveBeenCalledOnce();
883
+ expect(spies.parent.postMessage).toHaveBeenCalledWith('ready', '*');
884
+ ```
885
+
886
+ Pass an array for root methods: `createWindowSpies(['close', 'focus'])`. Each call builds fresh spies.
887
+ The object returned by `createWindowSpies` contains only the selected methods. Their parameter types and spy helpers are preserved.
888
+ For methods that return a value, use `createFunctionSpy` and configure that value explicitly.
889
+ When adding location values, spread `spies.location` too; replacing it would discard the reload spy.
890
+
865
891
  ### The Material dialog trio — `provideMatDialogData` / `provideMatDialogRef`
866
892
 
867
893
  ```ts
@@ -220,3 +220,11 @@ closures, not on the runner's mock. So when a spy outlives a test — a TestBed
220
220
  a spy hoisted to `describe` scope — put `resetAutoSpy(spy)` in `beforeEach`. Inside one test the
221
221
  sequence `nextWith(a)` then `throwWith(e)` still means "emit a, then fail"; only a reset or a
222
222
  terminal call starts a new stream.
223
+
224
+ ### Keeping an awaited collaborator pending
225
+
226
+ `createDeferred<T>()` from the core entry returns `{ promise, resolve, reject }`. Return `promise`
227
+ from the spy, start the operation, assert the intermediate state, then `resolve(value)` and await
228
+ the operation. `createDeferred()` defaults to `void`; `resolve()` then needs no argument.
229
+ Do not await the operation before resolving its dependency. No timer or `Promise.withResolvers`
230
+ is required. Use the runner's core entry (`/bun`, `/node`, `/rstest`) outside Vitest.
@@ -22,6 +22,17 @@ fixture.debugElement.query(By.css('.open')).nativeElement.click(); // production
22
22
  await settleDynamicImport(() => import('./profile-select.modal'));
23
23
  ```
24
24
 
25
+ **Loading provider classes is setup, not a wait for application work.** Keep
26
+ `const { PremiumService } = await import('./premium.service')` when its exports configure Angular
27
+ providers before creating the service under test. `settleDynamicImport` is useful after an action
28
+ starts a lazy import; it adds no needed wait merely to read provider classes. Preserve dynamic
29
+ imports when module evaluation order matters, including `vi.resetModules()` / `vi.doMock()` setup.
30
+ The ESLint rule recognises provider setup in `beforeEach` / `beforeAll`. Earlier fixture factories
31
+ must be imported functions whose bound results also supply providers. Member calls and other
32
+ actions prevent this exemption, except recognised module-registry resets.
33
+
34
+ `await Promise.resolve()` yields to microtasks; it is not equivalent to `flushEventLoop(1)`.
35
+
25
36
  Three rules worth stating outright, because each of them cost a day somewhere:
26
37
 
27
38
  - **`afterNextRender` does not run on `detectChanges()`.** A component that fills a form there is
@@ -30,9 +41,8 @@ Three rules worth stating outright, because each of them cost a day somewhere:
30
41
  - **`fixture.whenRenderingDone()` is not a stronger `whenStable()`.** With an animation renderer
31
42
  installed it degrades to `Promise.resolve()`. Use `stable(fixture)`.
32
43
  - **`fakeAsync` / `tick()` / `flushMicrotasks()` never reach the module loader.** Spinning
33
- `await Promise.resolve()` ten times looks like it works and instead lands the continuation after
34
- teardown — a green run with `NG0205: Injector has already been destroyed` in "Unhandled Errors"
35
- and a non-zero exit code.
44
+ `await Promise.resolve()` ten times may leave a continuation until after teardown, causing
45
+ `NG0205: Injector has already been destroyed` in "Unhandled Errors" and a non-zero exit code.
36
46
 
37
47
  **`stable()` and `flushEffects()` are not zoneless-only, and their tick runs inside the `NgZone` so
38
48
  that they are not.** `TestBed.createComponent` builds the component inside `ngZone.run(…)`, so an
@@ -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-BdYUK_Zv.js';
3
+ import { h as AddSpyMethodsByReturnTypes, S as Spy, F as Func, p as FunctionSpy } from './types-BdYUK_Zv.js';
4
4
  import { DomSanitizer } from '@angular/platform-browser';
5
5
  import 'vitest';
6
6
 
@@ -183,7 +183,7 @@ declare function injectMatDialogRef<Ref extends DialogRefLike>(RefClass: Abstrac
183
183
  */
184
184
 
185
185
  /** How many levels of slicing the type follows. Beyond it a member takes its whole type. */
186
- type Levels = [never, 0, 1, 2, 3];
186
+ type Levels$1 = [never, 0, 1, 2, 3];
187
187
  /**
188
188
  * One member's override: the member's own type, or a slice of it wherever it is a plain-ish object.
189
189
  *
@@ -192,7 +192,7 @@ type Levels = [never, 0, 1, 2, 3];
192
192
  * array is matched whole too: slicing one by index describes nothing a spec means.
193
193
  */
194
194
  type PlatformOverride<V, Depth extends number> = V extends (...args: never[]) => unknown ? V : V extends readonly unknown[] ? V : V extends object ? Depth extends 0 ? V : V | {
195
- [K in keyof V]?: PlatformOverride<V[K], Levels[Depth]>;
195
+ [K in keyof V]?: PlatformOverride<V[K], Levels$1[Depth]>;
196
196
  } : V;
197
197
  /**
198
198
  * What a spec says about a platform object: a value per member, and a **slice** wherever the member
@@ -470,4 +470,35 @@ declare function provideOverlayDouble<O extends OverlayLike>(OverlayClass: Abstr
470
470
  */
471
471
  declare function injectOverlayDouble<O extends OverlayLike>(OverlayClass: AbstractType<O>, injector?: Injector): OverlayDouble<O>;
472
472
 
473
- export { type AttachedComponent, type DialogComponent, type DialogDataOf, type DialogRefLike, type DialogResult, type MatDialogRefDouble, type MatDialogRefInit, type OverlayDouble, type OverlayDoubleInit, type OverlayLike, type OverlayRefDouble, type OverlayRefStub, type PlatformFlagTokens, type PlatformName, type PlatformOverrides, type PositionCall, createChangeDetectorRefDouble, createDocumentDouble, createDomSanitizerDouble, createMatDialogRef, createOverlayDouble, createWindowDouble, injectMatDialogRef, injectOverlayDouble, provideChangeDetectorRefDouble, provideDocumentDouble, provideDomSanitizerDouble, provideMatDialogData, provideMatDialogRef, provideOverlayDouble, providePlatform, provideWindowDouble };
473
+ type Levels = [never, 0, 1, 2, 3];
474
+ type VoidMethodKeys<T> = {
475
+ [K in keyof T]: T[K] extends (...args: never[]) => infer R ? (R extends void ? K : never) : never;
476
+ }[keyof T];
477
+ /** Select void methods at each object level; only named methods become spies. */
478
+ type WindowSpySelection<T = Window, Depth extends number = 3> = readonly VoidMethodKeys<T>[] | (Depth extends 0 ? never : {
479
+ [K in keyof T as T[K] extends object ? (T[K] extends (...args: never[]) => unknown ? never : K) : never]?: WindowSpySelection<NonNullable<T[K]>, Levels[Depth]>;
480
+ });
481
+ /** The selected methods, with their original call signatures and the auto-spy helpers. */
482
+ type WindowSpies<T, Selection> = Selection extends readonly (infer K)[] ? {
483
+ [P in Extract<K, keyof T>]: T[P] extends (...args: never[]) => unknown ? FunctionSpy<T[P]> : never;
484
+ } : {
485
+ [P in keyof Selection & keyof T]: WindowSpies<NonNullable<T[P]>, Selection[P]>;
486
+ };
487
+ type ValidSelection<T, Selection> = Selection extends readonly unknown[] ? readonly VoidMethodKeys<T>[] : {
488
+ [K in keyof Selection]: K extends keyof T ? T[K] extends (...args: never[]) => unknown ? never : ValidSelection<NonNullable<T[K]>, Selection[K]> : never;
489
+ };
490
+ /**
491
+ * Build typed, already configured no-op spies for selected void window methods.
492
+ *
493
+ * ```ts
494
+ * const spies = createWindowSpies({ location: ['reload'], parent: ['postMessage'] });
495
+ * provideWindowDouble(WINDOW, { ...spies, location: { ...spies.location, hostname: 'tv.kion.ru' } });
496
+ * expect(spies.location.reload).toHaveBeenCalledOnce();
497
+ * ```
498
+ *
499
+ * No global is read or patched. Pass the result to `createWindowDouble` or `provideWindowDouble`;
500
+ * unnamed members still use the real window. Use `createFunctionSpy` for methods returning values.
501
+ */
502
+ declare function createWindowSpies<const Selection extends WindowSpySelection>(selection: Selection & ValidSelection<Window, Selection>): WindowSpies<Window, Selection>;
503
+
504
+ export { type AttachedComponent, type DialogComponent, type DialogDataOf, type DialogRefLike, type DialogResult, type MatDialogRefDouble, type MatDialogRefInit, type OverlayDouble, type OverlayDoubleInit, type OverlayLike, type OverlayRefDouble, type OverlayRefStub, type PlatformFlagTokens, type PlatformName, type PlatformOverrides, type PositionCall, type WindowSpies, type WindowSpySelection, createChangeDetectorRefDouble, createDocumentDouble, createDomSanitizerDouble, createMatDialogRef, createOverlayDouble, createWindowDouble, createWindowSpies, injectMatDialogRef, injectOverlayDouble, provideChangeDetectorRefDouble, provideDocumentDouble, provideDomSanitizerDouble, provideMatDialogData, provideMatDialogRef, provideOverlayDouble, providePlatform, provideWindowDouble };
@@ -464,7 +464,35 @@ function injectOverlayDouble(OverlayClass, injector) {
464
464
  return double;
465
465
  }
466
466
 
467
+ // src/lib/window-spies.ts
468
+ function buildSpies(selection, path) {
469
+ const result = {};
470
+ if (Array.isArray(selection)) {
471
+ for (const key of selection) {
472
+ Object.defineProperty(result, key, {
473
+ value: createFunctionSpy(`${path}.${String(key)}`).mockReturnValue(void 0),
474
+ enumerable: true,
475
+ configurable: true,
476
+ writable: true
477
+ });
478
+ }
479
+ } else {
480
+ for (const key of Reflect.ownKeys(selection)) {
481
+ Object.defineProperty(result, key, {
482
+ value: buildSpies(Reflect.get(selection, key), `${path}.${String(key)}`),
483
+ enumerable: true,
484
+ configurable: true,
485
+ writable: true
486
+ });
487
+ }
488
+ }
489
+ return result;
490
+ }
491
+ function createWindowSpies(selection) {
492
+ return buildSpies(selection, "window");
493
+ }
494
+
467
495
  // src/angular-doubles.ts
468
496
  useVitestAdapter();
469
497
 
470
- export { createChangeDetectorRefDouble, createDocumentDouble, createDomSanitizerDouble, createMatDialogRef, createOverlayDouble, createWindowDouble, injectMatDialogRef, injectOverlayDouble, provideChangeDetectorRefDouble, provideDocumentDouble, provideDomSanitizerDouble, provideMatDialogData, provideMatDialogRef, provideOverlayDouble, providePlatform, provideWindowDouble };
498
+ export { createChangeDetectorRefDouble, createDocumentDouble, createDomSanitizerDouble, createMatDialogRef, createOverlayDouble, createWindowDouble, createWindowSpies, injectMatDialogRef, injectOverlayDouble, provideChangeDetectorRefDouble, provideDocumentDouble, provideDomSanitizerDouble, provideMatDialogData, provideMatDialogRef, provideOverlayDouble, providePlatform, provideWindowDouble };
@@ -1,5 +1,5 @@
1
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-BdYUK_Zv.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';
2
+ export { AdoptMockOptions, AdoptedMock, ArgCaptor, AsInstances, AssertMockedOptions, CallLog, CaptureArgOptions, ConstructorMock, ConstructorSpy, Deferred, FixtureFactory, FlushUntilOptions, MockDeepOptions, ModuleNamespace, ModuleNamespaceOptions, SpyClassOptions, adoptMock, asInstance, asInstances, asSpy, assertMocked, captureArg, clearAutoSpy, createDeferred, 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
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-ByzgYsbj.js';
4
4
  export { c as createFunctionSpy, d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-xpq8sPYM.js';
5
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-424cOHvI.js';
@@ -7,7 +7,7 @@ import { angularInternalsError } from './chunk-4JY7KIJG.js';
7
7
  import './chunk-VLEU3CWT.js';
8
8
  import { createSpyForToken } from './chunk-6KS7F4YM.js';
9
9
  export { createNestUnit } from './chunk-6KS7F4YM.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-YAAE5465.js';
10
+ export { adoptMock, asInstance, asInstances, asSpy, assertMocked, captureArg, createDeferred, 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-EFUZ44HT.js';
11
11
  import { mockValueProp } from './chunk-RQLUH6RE.js';
12
12
  export { countMockedProps, mockAccessorsProp, mockReadonlyProp, mockReadonlyPropGetter, mockValueProp, reportPropsOutsideHooks, restoreMockedProps } from './chunk-RQLUH6RE.js';
13
13
  import { closestName } from './chunk-BCT7C6DQ.js';
package/dist/bun.d.ts CHANGED
@@ -1,5 +1,5 @@
1
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-BdYUK_Zv.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';
2
+ export { AdoptMockOptions, AdoptedMock, ArgCaptor, AsInstances, AssertMockedOptions, CallLog, CaptureArgOptions, ConstructorMock, ConstructorSpy, Deferred, FixtureFactory, FlushUntilOptions, MockDeepOptions, ModuleNamespace, ModuleNamespaceOptions, SpyClassOptions, adoptMock, asInstance, asInstances, asSpy, assertMocked, captureArg, clearAutoSpy, createDeferred, 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
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-ByzgYsbj.js';
4
4
  export { c as createFunctionSpy, d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-xpq8sPYM.js';
5
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-424cOHvI.js';
package/dist/bun.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import './chunk-VLEU3CWT.js';
2
2
  export { createNestUnit } from './chunk-6KS7F4YM.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-YAAE5465.js';
3
+ export { adoptMock, asInstance, asInstances, asSpy, assertMocked, captureArg, createDeferred, 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-EFUZ44HT.js';
4
4
  export { countMockedProps, mockAccessorsProp, mockReadonlyProp, mockReadonlyPropGetter, mockValueProp, reportPropsOutsideHooks, restoreMockedProps } from './chunk-RQLUH6RE.js';
5
5
  export { autoMocked, clearAutoSpy, clearAutoSpyDefaults, createAutoMock, createSpyFromClass, innerDouble, registerAutoSpyDefaults, resetAutoSpy } from './chunk-BCT7C6DQ.js';
6
6
  import './chunk-SF4GKKN4.js';
@@ -1097,6 +1097,17 @@ function createLog() {
1097
1097
  };
1098
1098
  }
1099
1099
 
1100
+ // src/lib/deferred.ts
1101
+ function createDeferred() {
1102
+ let resolve;
1103
+ let reject;
1104
+ const promise = new Promise((resolvePromise, rejectPromise) => {
1105
+ resolve = resolvePromise;
1106
+ reject = rejectPromise;
1107
+ });
1108
+ return { promise, resolve, reject };
1109
+ }
1110
+
1100
1111
  // src/lib/with-overrides.ts
1101
1112
  function readableKeys(model) {
1102
1113
  const keys = new Set(Object.keys(model));
@@ -1408,4 +1419,4 @@ var adoptMock2 = defineHelper((mock, options = {}) => {
1408
1419
  return exposeAsAdopted(spy);
1409
1420
  });
1410
1421
 
1411
- export { adoptMock2 as adoptMock, asInstance, asInstances, asSpy, assertMocked, captureArg2 as captureArg, createFixture, createFixtureFactory, createLog, createMock, createSpyClass, createSpyFromInstance, expectAllEmissions, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, expectNoEmissionSync, flushEventLoop, flushEventLoopUntil, mockConstructor2 as mockConstructor, mockDeep, moduleNamespace, narrow2 as narrow, outOfType, restoreSpiedInstance, settleDynamicImport, spyOnOwnMethod, spyOnVoidMethod, stubConstructor, withOverrides };
1422
+ export { adoptMock2 as adoptMock, asInstance, asInstances, asSpy, assertMocked, captureArg2 as captureArg, createDeferred, createFixture, createFixtureFactory, createLog, createMock, createSpyClass, createSpyFromInstance, expectAllEmissions, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, expectNoEmissionSync, flushEventLoop, flushEventLoopUntil, mockConstructor2 as mockConstructor, mockDeep, moduleNamespace, narrow2 as narrow, outOfType, restoreSpiedInstance, settleDynamicImport, spyOnOwnMethod, spyOnVoidMethod, stubConstructor, withOverrides };
package/dist/cli.js CHANGED
@@ -1667,7 +1667,7 @@ function foreignPragmaPass() {
1667
1667
  }
1668
1668
 
1669
1669
  // src/cli/checks/export-map.generated.ts
1670
- var EXPORT_MAP_VERSION = "5.59.1";
1670
+ var EXPORT_MAP_VERSION = "5.62.0";
1671
1671
  var ENTRY_SPECIFIERS = "vitest-auto-spy vitest-auto-spy/bun vitest-auto-spy/bun-angular vitest-auto-spy/node vitest-auto-spy/rstest vitest-auto-spy/rxjs vitest-auto-spy/console vitest-auto-spy/dom-stubs vitest-auto-spy/diagnostics vitest-auto-spy/jasmine vitest-auto-spy/jasmine-compat vitest-auto-spy/observer-spy vitest-auto-spy/angular vitest-auto-spy/angular/diagnostics vitest-auto-spy/angular/doubles vitest-auto-spy/angular/matchers vitest-auto-spy/angular-http vitest-auto-spy/angular-router vitest-auto-spy/signal-forms vitest-auto-spy/nestjs vitest-auto-spy/react vitest-auto-spy/vue vitest-auto-spy/svelte vitest-auto-spy/setup vitest-auto-spy/zone vitest-auto-spy/eslint-plugin vitest-auto-spy/perf-reporter";
1672
1672
  var EXPORTED_BY = {
1673
1673
  AccessorImplementations: "0 1 2 3 4 12 20 21 22",
@@ -1775,6 +1775,7 @@ var EXPORTED_BY = {
1775
1775
  createAutoMock: "0 1 2 3 4 20 21 22",
1776
1776
  createChangeDetectorRefDouble: "14",
1777
1777
  createComponentStub: "12",
1778
+ createDeferred: "0 1 2 3 4 20 21 22",
1778
1779
  createDirectiveHost: "12",
1779
1780
  createDocumentDouble: "14",
1780
1781
  createDomSanitizerDouble: "14",
@@ -1800,11 +1801,13 @@ var EXPORTED_BY = {
1800
1801
  createSpyFromInstance: "0 1 2 3 4 20 21 22",
1801
1802
  createSpyObj: "9",
1802
1803
  createWindowDouble: "14",
1804
+ createWindowSpies: "14",
1803
1805
  createWithAutoSpies: "2 12",
1804
1806
  CreateWithAutoSpiesOptions: "2 12",
1805
1807
  DeepMockProxy: "0 1 2 3 4 20 21 22",
1806
1808
  DeepPartial: "0 1 2 3 4 20 21 22",
1807
1809
  default: "25 26",
1810
+ Deferred: "0 1 2 3 4 20 21 22",
1808
1811
  describeDuplicateCopies: "0 1 2 3 4 20 21 22 23",
1809
1812
  describeStrayListeners: "23",
1810
1813
  describeStrayTimers: "23",
@@ -2158,6 +2161,8 @@ var EXPORTED_BY = {
2158
2161
  WebStorageKey: "7",
2159
2162
  WebStorageStub: "7",
2160
2163
  WebStorageStubOptions: "7",
2164
+ WindowSpies: "14",
2165
+ WindowSpySelection: "14",
2161
2166
  withFakeTimers: "23",
2162
2167
  WithMockReturnValue: "0 1 2 3 4 20 21 22",
2163
2168
  withoutStrayTimerTracking: "23",
package/dist/core.d.ts CHANGED
@@ -855,6 +855,18 @@ interface CallLog<T extends string = string> {
855
855
  */
856
856
  declare function createLog<T extends string = string>(): CallLog<T>;
857
857
 
858
+ /** A promise whose outcome the test controls after the application starts awaiting it. */
859
+ interface Deferred<T> {
860
+ readonly promise: Promise<T>;
861
+ readonly resolve: (value: PromiseLike<T> | T) => void;
862
+ readonly reject: (reason?: unknown) => void;
863
+ }
864
+ /**
865
+ * Keep an async collaborator pending until the test has checked the intermediate state.
866
+ * Uses the Promise constructor, so it also works without `Promise.withResolvers`.
867
+ */
868
+ declare function createDeferred<T = void>(): Deferred<T>;
869
+
858
870
  /**
859
871
  * A fixture built from a model instance, with some fields changed.
860
872
  *
@@ -1166,4 +1178,4 @@ type AdoptedMock<F extends Func> = AddSpyMethodsByReturnTypes<F extends MockInst
1166
1178
  */
1167
1179
  declare const adoptMock: <F extends Func>(mock: F, options?: AdoptMockOptions) => AdoptedMock<F>;
1168
1180
 
1169
- export { AddSpyMethodsByReturnTypes, type AdoptMockOptions, type AdoptedMock, type ArgCaptor, type AsInstances, type AssertMockedOptions, type CallLog, type CaptureArgOptions, ClassSpyConfiguration, ClassType, type ConstructorMock, type ConstructorSpy, DeepMockProxy, DeepPartial, type FixtureFactory, type FlushUntilOptions, Func, InstanceSpyConfiguration, type MockDeepOptions, type ModuleNamespace, type ModuleNamespaceOptions, OnlyMethodKeysOf, Spy, type SpyClassOptions, SpyOptions, 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 };
1181
+ export { AddSpyMethodsByReturnTypes, type AdoptMockOptions, type AdoptedMock, type ArgCaptor, type AsInstances, type AssertMockedOptions, type CallLog, type CaptureArgOptions, ClassSpyConfiguration, ClassType, type ConstructorMock, type ConstructorSpy, DeepMockProxy, DeepPartial, type Deferred, type FixtureFactory, type FlushUntilOptions, Func, InstanceSpyConfiguration, type MockDeepOptions, type ModuleNamespace, type ModuleNamespaceOptions, OnlyMethodKeysOf, Spy, type SpyClassOptions, SpyOptions, adoptMock, asInstance, asInstances, asSpy, assertMocked, captureArg, clearAutoSpy, createDeferred, createFixture, createFixtureFactory, createLog, createMock, createSpyClass, createSpyFromClass, createSpyFromInstance, errorHandler, flushEventLoop, flushEventLoopUntil, innerDouble, mockConstructor, mockDeep, moduleNamespace, narrow, outOfType, resetAutoSpy, restoreSpiedInstance, settleDynamicImport, spyOnOwnMethod, spyOnVoidMethod, stubConstructor, withOverrides };
@@ -480,13 +480,13 @@ function runnerBehind(callee) {
480
480
  }
481
481
  return isCallExpression(callee) ? runnerBehind(callee.callee) : void 0;
482
482
  }
483
- function insideRunnerCallback(node) {
483
+ function enclosingRunner(node) {
484
484
  const callback = enclosingFunction(node);
485
485
  if (!callback) {
486
- return false;
486
+ return void 0;
487
487
  }
488
488
  const call = callback.parent;
489
- return isCallExpression(call) && call.arguments.includes(callback) && runnerBehind(call.callee) !== void 0;
489
+ return isCallExpression(call) && call.arguments.includes(callback) ? runnerBehind(call.callee) : void 0;
490
490
  }
491
491
  function consumptionOf(node) {
492
492
  const { parent } = node;
@@ -518,6 +518,74 @@ function takesTheNamespaceFirst(node, bound) {
518
518
  const before2 = siblings2.slice(0, siblings2.indexOf(statement)).reverse().find((sibling) => !bound.has(sibling));
519
519
  return before2 === void 0 ? statement.parent === callback.body : resetsRegistry(before2);
520
520
  }
521
+ function providerReference(context, reference, callback) {
522
+ if (enclosingFunction(reference) !== callback) {
523
+ return false;
524
+ }
525
+ let current = reference;
526
+ while (current !== callback) {
527
+ if (propertyName(current) === "providers") {
528
+ const configuration = current.parent;
529
+ const call = configuration.parent;
530
+ if (!isCallExpression(call) || !call.arguments.includes(configuration)) {
531
+ return false;
532
+ }
533
+ if (!isMemberExpression(call.callee) || memberName(call.callee) !== "configureTestingModule" || !isIdentifier(call.callee.object)) {
534
+ return false;
535
+ }
536
+ const receiver = call.callee.object;
537
+ const binding = findBinding(context.sourceCode.getScope(receiver), receiver.name);
538
+ const specifier = binding && importSpecifierOf(binding);
539
+ return specifier ? isIdentifier(specifier.imported) && specifier.imported.name === "TestBed" && specifier.parent.source.value === "@angular/core/testing" : binding === void 0 && receiver.name === "TestBed";
540
+ }
541
+ current = current.parent;
542
+ }
543
+ return false;
544
+ }
545
+ function suppliesProvider(context, awaited, callback) {
546
+ const holder = awaited.parent;
547
+ const pattern = isVariableDeclarator(holder) ? holder.id : isAssignmentExpression(holder) ? holder.left : void 0;
548
+ return pattern !== void 0 && anyInSubtree(
549
+ context,
550
+ pattern,
551
+ (candidate) => {
552
+ if (!isIdentifier(candidate)) {
553
+ return false;
554
+ }
555
+ const binding = findBinding(context.sourceCode.getScope(candidate), candidate.name);
556
+ const writes = binding?.references.filter((reference) => reference.writeExpr) ?? [];
557
+ return writes.length === 1 && writes[0]?.writeExpr === awaited && binding?.references.some(
558
+ (reference) => reference.identifier.range[0] > awaited.range[1] && providerReference(context, reference.identifier, callback)
559
+ ) === true;
560
+ },
561
+ false
562
+ );
563
+ }
564
+ function preparesProvider(context, call, callback) {
565
+ if (!isCallExpression(call) || !isIdentifier(call.callee)) {
566
+ return false;
567
+ }
568
+ const binding = findBinding(context.sourceCode.getScope(call), call.callee.name);
569
+ return binding?.defs.some((definition) => definition.type === "ImportBinding") === true && suppliesProvider(context, call, callback);
570
+ }
571
+ function loadsProviderForSetup(context, node, runner) {
572
+ const callback = enclosingFunction(node);
573
+ const statement = bindingStatement(node.parent);
574
+ if (!callback || statement?.parent !== callback.body || !isBlockStatement(callback.body)) {
575
+ return false;
576
+ }
577
+ if (runner !== "beforeAll" && runner !== "beforeEach" || !suppliesProvider(context, node.parent, callback)) {
578
+ return false;
579
+ }
580
+ return callback.body.body.slice(0, callback.body.body.indexOf(statement)).every(
581
+ (before2) => (before2.type === "VariableDeclaration" || isExpressionStatement(before2)) && !anyInSubtree(
582
+ context,
583
+ before2,
584
+ (candidate) => isAssignmentExpression(candidate) && !isIdentifier(candidate.left) || candidate.type === "UnaryExpression" && Reflect.get(candidate, "operator") === "delete" || (isCallExpression(candidate) || candidate.type === "NewExpression" || candidate.type === "AwaitExpression" || candidate.type === "UpdateExpression") && !preparesProvider(context, candidate, callback) && !(candidate.type === "AwaitExpression" && suppliesProvider(context, candidate, callback) && anyInSubtree(context, candidate, (child) => child.type === "ImportExpression" && child.parent === candidate, false)) && !isRunnerCall(candidate, REGISTRY_RESETS),
585
+ false
586
+ )
587
+ );
588
+ }
521
589
  function wrap(context, node) {
522
590
  const state = bindingState(context.sourceCode.getScope(node), HELPER);
523
591
  if (state === "taken") {
@@ -540,7 +608,7 @@ var preferSettleDynamicImport = defineRule({
540
608
  description: "Load a module the code under test lazy-loads with settleDynamicImport(), not a bare await import()",
541
609
  hasSuggestions: true,
542
610
  messages: {
543
- awaitedDynamicImport: `\`await {{load}}\` waits for the module, not for the code under test that was loading it: its continuation after its own \`await\` has not run yet, so the assertions below read the state one turn early. ${REPAIR}`,
611
+ awaitedDynamicImport: `\`await {{load}}\` waits for the module, not for the code under test that was loading it: its continuation after its own \`await\` may still be pending, so the assertions below may read state too early. ${REPAIR}`,
544
612
  thenedDynamicImport: `\`{{load}}.then(\u2026)\` waits for the module, not for the code under test that was loading it, and its callback runs later still, after the test ends if nothing awaits it. ${REPAIR}`
545
613
  },
546
614
  create: (context) => {
@@ -548,7 +616,8 @@ var preferSettleDynamicImport = defineRule({
548
616
  return {
549
617
  ImportExpression: (node) => {
550
618
  const consumption = consumptionOf(node);
551
- if (consumption === void 0 || !insideRunnerCallback(node) || consumption === "await" && takesTheNamespaceFirst(node, bound)) {
619
+ const runner = enclosingRunner(node);
620
+ if (consumption === void 0 || runner === void 0 || consumption === "await" && (takesTheNamespaceFirst(node, bound) || loadsProviderForSetup(context, node, runner))) {
552
621
  return;
553
622
  }
554
623
  const messageId = consumption === "await" ? "awaitedDynamicImport" : "thenedDynamicImport";
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import './vitest-mock-types-B17-xaWt.js';
2
2
  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-BdYUK_Zv.js';
3
- 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 { AdoptMockOptions, AdoptedMock, ArgCaptor, AsInstances, AssertMockedOptions, CallLog, CaptureArgOptions, ConstructorMock, ConstructorSpy, Deferred, FixtureFactory, FlushUntilOptions, MockDeepOptions, ModuleNamespace, ModuleNamespaceOptions, SpyClassOptions, adoptMock, asInstance, asInstances, asSpy, assertMocked, captureArg, clearAutoSpy, createDeferred, 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';
4
4
  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-ByzgYsbj.js';
5
5
  export { c as createFunctionSpy, d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-xpq8sPYM.js';
6
6
  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-424cOHvI.js';
package/dist/index.js CHANGED
@@ -4820,6 +4820,17 @@ function createLog() {
4820
4820
  };
4821
4821
  }
4822
4822
 
4823
+ // src/lib/deferred.ts
4824
+ function createDeferred() {
4825
+ let resolve;
4826
+ let reject;
4827
+ const promise = new Promise((resolvePromise, rejectPromise) => {
4828
+ resolve = resolvePromise;
4829
+ reject = rejectPromise;
4830
+ });
4831
+ return { promise, resolve, reject };
4832
+ }
4833
+
4823
4834
  // src/lib/with-overrides.ts
4824
4835
  function readableKeys(model) {
4825
4836
  const keys = new Set(Object.keys(model));
@@ -5134,4 +5145,4 @@ var adoptMock2 = defineHelper((mock, options = {}) => {
5134
5145
  // vitest-auto-spy-host:index.ts
5135
5146
  useVitestAdapter();
5136
5147
 
5137
- export { adoptMock2 as adoptMock, asInstance, asInstances, asSpy, assertMocked, autoMocked, captureArg2 as captureArg, clearAutoSpy, clearAutoSpyDefaults, countMockedProps, createAutoMock, createFixture, createFixtureFactory, createFunctionSpy, createLog, createMock, createSpyClass, createSpyFromClass2 as createSpyFromClass, createSpyFromInstance, errorHandler, expectAllEmissions, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, expectNoEmissionSync, flushEventLoop, flushEventLoopUntil, innerDouble, mockAccessorsProp, mockConstructor2 as mockConstructor, mockDeep, mockReadonlyProp, mockReadonlyPropGetter, mockValueProp, moduleNamespace, narrow2 as narrow, outOfType, registerAutoSpyDefaults, reportPropsOutsideHooks, resetAutoSpy, restoreMockedProps, restoreSpiedInstance, settleDynamicImport, spyOnOwnMethod, spyOnVoidMethod, stubConstructor, withOverrides, callSiteName as ɵauto_mock$callSiteName, PROXY_MIN_METHODS as ɵcreate_spy_from_class$PROXY_MIN_METHODS, applyConfiguredReturns as ɵcreate_spy_from_class$applyConfiguredReturns, applyReturns as ɵcreate_spy_from_class$applyReturns, classDoubles as ɵcreate_spy_from_class$classDoubles, getCallableMemberNames as ɵcreate_spy_from_class$getCallableMemberNames, mergeMethodNames as ɵcreate_spy_from_class$mergeMethodNames, resolveAccessors as ɵcreate_spy_from_class$resolveAccessors, resolveConfiguration as ɵcreate_spy_from_class$resolveConfiguration, rejectAsSourceError as ɵexpect_emission$rejectAsSourceError, subscribeAndCollect as ɵexpect_emission$subscribeAndCollect, timeoutError as ɵexpect_emission$timeoutError, unexpectedEmissionError as ɵexpect_emission$unexpectedEmissionError, fakeClockAdvice as ɵfake_clock_state$fakeClockAdvice, fakeClockBacklog as ɵfake_clock_state$fakeClockBacklog, adoptFunctionSpy as ɵfunction_spy$adoptFunctionSpy, defaultStrict as ɵfunction_spy$defaultStrict, ownDirectory as ɵfunction_spy$ownDirectory, reinstallDispatch as ɵfunction_spy$reinstallDispatch, resetLenientMissHint as ɵfunction_spy$resetLenientMissHint, resolveUnstubbedGuard as ɵfunction_spy$resolveUnstubbedGuard, seedReturnValue as ɵfunction_spy$seedReturnValue, setDefaultStrictMode as ɵfunction_spy$setDefaultStrictMode, takeStrictViolations as ɵfunction_spy$takeStrictViolations, DOCS as ɵmessage_link$DOCS, DOCS_RXJS as ɵmessage_link$DOCS_RXJS, withDocs as ɵmessage_link$withDocs, misconfigurationThrows as ɵmisconfiguration$misconfigurationThrows, reportMisconfiguration as ɵmisconfiguration$reportMisconfiguration, setMisconfigurationReaction as ɵmisconfiguration$setMisconfigurationReaction, beginPropEpoch as ɵprop_mock$beginPropEpoch, currentSpecFile as ɵspec_file$currentSpecFile, closestName as ɵspy_config_warnings$closestName, ownerOf as ɵspy_config_warnings$ownerOf, warnOnAccessorNamingAMethod as ɵspy_config_warnings$warnOnAccessorNamingAMethod, warnOnUnknownMethods as ɵspy_config_warnings$warnOnUnknownMethods, dropAutoSpyDefaults as ɵspy_defaults$dropAutoSpyDefaults, mergeAutoSpyDefaults as ɵspy_defaults$mergeAutoSpyDefaults, mergeRegisteredDefaults as ɵspy_defaults$mergeRegisteredDefaults, registerFrom as ɵspy_defaults$registerFrom, AUTO_SPY_MARK as ɵspy_mark$AUTO_SPY_MARK, DEEP_CHILDREN as ɵspy_mark$DEEP_CHILDREN, hooksOf as ɵspy_mark$hooksOf, isAutoSpyLike as ɵspy_mark$isAutoSpyLike, isMarkedMock as ɵspy_mark$isMarkedMock, markAsMock as ɵspy_mark$markAsMock, readDeepChildren as ɵspy_mark$readDeepChildren, runClearHook as ɵspy_mark$runClearHook, runConfigReset as ɵspy_mark$runConfigReset, unpatchedClearTimeout as ɵunpatched_timers$unpatchedClearTimeout, unpatchedSetTimeout as ɵunpatched_timers$unpatchedSetTimeout, unpatchedTimer as ɵunpatched_timers$unpatchedTimer, useVitestAdapter as ɵuse_vitest_adapter$useVitestAdapter };
5148
+ export { adoptMock2 as adoptMock, asInstance, asInstances, asSpy, assertMocked, autoMocked, captureArg2 as captureArg, clearAutoSpy, clearAutoSpyDefaults, countMockedProps, createAutoMock, createDeferred, createFixture, createFixtureFactory, createFunctionSpy, createLog, createMock, createSpyClass, createSpyFromClass2 as createSpyFromClass, createSpyFromInstance, errorHandler, expectAllEmissions, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, expectNoEmissionSync, flushEventLoop, flushEventLoopUntil, innerDouble, mockAccessorsProp, mockConstructor2 as mockConstructor, mockDeep, mockReadonlyProp, mockReadonlyPropGetter, mockValueProp, moduleNamespace, narrow2 as narrow, outOfType, registerAutoSpyDefaults, reportPropsOutsideHooks, resetAutoSpy, restoreMockedProps, restoreSpiedInstance, settleDynamicImport, spyOnOwnMethod, spyOnVoidMethod, stubConstructor, withOverrides, callSiteName as ɵauto_mock$callSiteName, PROXY_MIN_METHODS as ɵcreate_spy_from_class$PROXY_MIN_METHODS, applyConfiguredReturns as ɵcreate_spy_from_class$applyConfiguredReturns, applyReturns as ɵcreate_spy_from_class$applyReturns, classDoubles as ɵcreate_spy_from_class$classDoubles, getCallableMemberNames as ɵcreate_spy_from_class$getCallableMemberNames, mergeMethodNames as ɵcreate_spy_from_class$mergeMethodNames, resolveAccessors as ɵcreate_spy_from_class$resolveAccessors, resolveConfiguration as ɵcreate_spy_from_class$resolveConfiguration, rejectAsSourceError as ɵexpect_emission$rejectAsSourceError, subscribeAndCollect as ɵexpect_emission$subscribeAndCollect, timeoutError as ɵexpect_emission$timeoutError, unexpectedEmissionError as ɵexpect_emission$unexpectedEmissionError, fakeClockAdvice as ɵfake_clock_state$fakeClockAdvice, fakeClockBacklog as ɵfake_clock_state$fakeClockBacklog, adoptFunctionSpy as ɵfunction_spy$adoptFunctionSpy, defaultStrict as ɵfunction_spy$defaultStrict, ownDirectory as ɵfunction_spy$ownDirectory, reinstallDispatch as ɵfunction_spy$reinstallDispatch, resetLenientMissHint as ɵfunction_spy$resetLenientMissHint, resolveUnstubbedGuard as ɵfunction_spy$resolveUnstubbedGuard, seedReturnValue as ɵfunction_spy$seedReturnValue, setDefaultStrictMode as ɵfunction_spy$setDefaultStrictMode, takeStrictViolations as ɵfunction_spy$takeStrictViolations, DOCS as ɵmessage_link$DOCS, DOCS_RXJS as ɵmessage_link$DOCS_RXJS, withDocs as ɵmessage_link$withDocs, misconfigurationThrows as ɵmisconfiguration$misconfigurationThrows, reportMisconfiguration as ɵmisconfiguration$reportMisconfiguration, setMisconfigurationReaction as ɵmisconfiguration$setMisconfigurationReaction, beginPropEpoch as ɵprop_mock$beginPropEpoch, currentSpecFile as ɵspec_file$currentSpecFile, closestName as ɵspy_config_warnings$closestName, ownerOf as ɵspy_config_warnings$ownerOf, warnOnAccessorNamingAMethod as ɵspy_config_warnings$warnOnAccessorNamingAMethod, warnOnUnknownMethods as ɵspy_config_warnings$warnOnUnknownMethods, dropAutoSpyDefaults as ɵspy_defaults$dropAutoSpyDefaults, mergeAutoSpyDefaults as ɵspy_defaults$mergeAutoSpyDefaults, mergeRegisteredDefaults as ɵspy_defaults$mergeRegisteredDefaults, registerFrom as ɵspy_defaults$registerFrom, AUTO_SPY_MARK as ɵspy_mark$AUTO_SPY_MARK, DEEP_CHILDREN as ɵspy_mark$DEEP_CHILDREN, hooksOf as ɵspy_mark$hooksOf, isAutoSpyLike as ɵspy_mark$isAutoSpyLike, isMarkedMock as ɵspy_mark$isMarkedMock, markAsMock as ɵspy_mark$markAsMock, readDeepChildren as ɵspy_mark$readDeepChildren, runClearHook as ɵspy_mark$runClearHook, runConfigReset as ɵspy_mark$runConfigReset, unpatchedClearTimeout as ɵunpatched_timers$unpatchedClearTimeout, unpatchedSetTimeout as ɵunpatched_timers$unpatchedSetTimeout, unpatchedTimer as ɵunpatched_timers$unpatchedTimer, useVitestAdapter as ɵuse_vitest_adapter$useVitestAdapter };
package/dist/node.cjs CHANGED
@@ -4296,6 +4296,17 @@ function createLog() {
4296
4296
  };
4297
4297
  }
4298
4298
 
4299
+ // src/lib/deferred.ts
4300
+ function createDeferred() {
4301
+ let resolve;
4302
+ let reject;
4303
+ const promise = new Promise((resolvePromise, rejectPromise) => {
4304
+ resolve = resolvePromise;
4305
+ reject = rejectPromise;
4306
+ });
4307
+ return { promise, resolve, reject };
4308
+ }
4309
+
4299
4310
  // src/lib/with-overrides.ts
4300
4311
  function readableKeys(model) {
4301
4312
  const keys = new Set(Object.keys(model));
@@ -4795,6 +4806,7 @@ exports.clearAutoSpyDefaults = clearAutoSpyDefaults;
4795
4806
  exports.countMockedProps = countMockedProps;
4796
4807
  exports.countNodeMocks = countNodeMocks;
4797
4808
  exports.createAutoMock = createAutoMock;
4809
+ exports.createDeferred = createDeferred;
4798
4810
  exports.createFixture = createFixture;
4799
4811
  exports.createFixtureFactory = createFixtureFactory;
4800
4812
  exports.createFunctionSpy = createFunctionSpy;
package/dist/node.d.cts CHANGED
@@ -20,6 +20,7 @@ export declare const clearAutoSpyDefaults: typeof Entry.clearAutoSpyDefaults;
20
20
  export declare const countMockedProps: typeof Entry.countMockedProps;
21
21
  export declare const countNodeMocks: typeof Entry.countNodeMocks;
22
22
  export declare const createAutoMock: typeof Entry.createAutoMock;
23
+ export declare const createDeferred: typeof Entry.createDeferred;
23
24
  export declare const createFixture: typeof Entry.createFixture;
24
25
  export declare const createFixtureFactory: typeof Entry.createFixtureFactory;
25
26
  export declare const createFunctionSpy: typeof Entry.createFunctionSpy;
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
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-BdYUK_Zv.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';
2
+ export { AdoptMockOptions, AdoptedMock, ArgCaptor, AsInstances, AssertMockedOptions, CallLog, CaptureArgOptions, ConstructorMock, ConstructorSpy, Deferred, FixtureFactory, FlushUntilOptions, MockDeepOptions, ModuleNamespace, ModuleNamespaceOptions, SpyClassOptions, adoptMock, asInstance, asInstances, asSpy, assertMocked, captureArg, clearAutoSpy, createDeferred, 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
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-ByzgYsbj.js';
4
4
  export { c as createFunctionSpy, d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-xpq8sPYM.js';
5
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-424cOHvI.js';
package/dist/node.js CHANGED
@@ -4164,6 +4164,17 @@ function createLog() {
4164
4164
  };
4165
4165
  }
4166
4166
 
4167
+ // src/lib/deferred.ts
4168
+ function createDeferred() {
4169
+ let resolve;
4170
+ let reject;
4171
+ const promise = new Promise((resolvePromise, rejectPromise) => {
4172
+ resolve = resolvePromise;
4173
+ reject = rejectPromise;
4174
+ });
4175
+ return { promise, resolve, reject };
4176
+ }
4177
+
4167
4178
  // src/lib/with-overrides.ts
4168
4179
  function readableKeys(model) {
4169
4180
  const keys = new Set(Object.keys(model));
@@ -4649,4 +4660,4 @@ function createNestUnit(Target, options = {}) {
4649
4660
  registerMockAdapter(createNodeMockAdapter(createSwappableNodeTracker({ mock, afterEach })));
4650
4661
  registerRunnerHooks({ beforeEach, afterEach });
4651
4662
 
4652
- export { adoptMock2 as adoptMock, asInstance, asInstances, asSpy, assertMocked, autoMocked, captureArg2 as captureArg, clearAutoSpy, clearAutoSpyDefaults, countMockedProps, countNodeMocks, createAutoMock, createFixture, createFixtureFactory, createFunctionSpy, createLog, createMock, createNestUnit, createSpyClass, createSpyFromClass2 as createSpyFromClass, createSpyFromInstance, errorHandler, expectAllEmissions, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, expectNoEmissionSync, flushEventLoop, flushEventLoopUntil, innerDouble, mockAccessorsProp, mockConstructor2 as mockConstructor, mockDeep, mockReadonlyProp, mockReadonlyPropGetter, mockValueProp, moduleNamespace, narrow2 as narrow, outOfType, pruneNodeMocks, registerAutoSpyDefaults, reportPropsOutsideHooks, resetAutoSpy, restoreMockedProps, restoreSpiedInstance, settleDynamicImport, spyOnOwnMethod, spyOnVoidMethod, stubConstructor, trackNodeMocks, withOverrides };
4663
+ export { adoptMock2 as adoptMock, asInstance, asInstances, asSpy, assertMocked, autoMocked, captureArg2 as captureArg, clearAutoSpy, clearAutoSpyDefaults, countMockedProps, countNodeMocks, createAutoMock, createDeferred, createFixture, createFixtureFactory, createFunctionSpy, createLog, createMock, createNestUnit, createSpyClass, createSpyFromClass2 as createSpyFromClass, createSpyFromInstance, errorHandler, expectAllEmissions, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, expectNoEmissionSync, flushEventLoop, flushEventLoopUntil, innerDouble, mockAccessorsProp, mockConstructor2 as mockConstructor, mockDeep, mockReadonlyProp, mockReadonlyPropGetter, mockValueProp, moduleNamespace, narrow2 as narrow, outOfType, pruneNodeMocks, registerAutoSpyDefaults, reportPropsOutsideHooks, resetAutoSpy, restoreMockedProps, restoreSpiedInstance, settleDynamicImport, spyOnOwnMethod, spyOnVoidMethod, stubConstructor, trackNodeMocks, withOverrides };
package/dist/react.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import './vitest-mock-types-B17-xaWt.js';
2
2
  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-BdYUK_Zv.js';
3
- 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 { AdoptMockOptions, AdoptedMock, ArgCaptor, AsInstances, AssertMockedOptions, CallLog, CaptureArgOptions, ConstructorMock, ConstructorSpy, Deferred, FixtureFactory, FlushUntilOptions, MockDeepOptions, ModuleNamespace, ModuleNamespaceOptions, SpyClassOptions, adoptMock, asInstance, asInstances, asSpy, assertMocked, captureArg, clearAutoSpy, createDeferred, 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';
4
4
  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-ByzgYsbj.js';
5
5
  export { c as createFunctionSpy, d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-xpq8sPYM.js';
6
6
  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-424cOHvI.js';
package/dist/react.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ɵuse_vitest_adapter$useVitestAdapter as _use_vitest_adapter$useVitestAdapter } from './index.js';
2
- export { adoptMock, asInstance, asInstances, asSpy, assertMocked, autoMocked, captureArg, clearAutoSpy, clearAutoSpyDefaults, countMockedProps, createAutoMock, createFixture, createFixtureFactory, createFunctionSpy, createLog, createMock, createSpyClass, createSpyFromClass, createSpyFromInstance, describeDuplicateCopies, errorHandler, expectAllEmissions, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, expectNoEmissionSync, flushEventLoop, flushEventLoopUntil, getPackageCopies, innerDouble, mockAccessorsProp, mockConstructor, mockDeep, mockReadonlyProp, mockReadonlyPropGetter, mockValueProp, moduleNamespace, narrow, outOfType, registerAutoSpyDefaults, reportPropsOutsideHooks, resetAutoSpy, restoreMockedProps, restoreSpiedInstance, setEmissionTimeout, settleDynamicImport, spyOnOwnMethod, spyOnVoidMethod, stubConstructor, withOverrides } from './index.js';
2
+ export { adoptMock, asInstance, asInstances, asSpy, assertMocked, autoMocked, captureArg, clearAutoSpy, clearAutoSpyDefaults, countMockedProps, createAutoMock, createDeferred, createFixture, createFixtureFactory, createFunctionSpy, createLog, createMock, createSpyClass, createSpyFromClass, createSpyFromInstance, describeDuplicateCopies, errorHandler, expectAllEmissions, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, expectNoEmissionSync, flushEventLoop, flushEventLoopUntil, getPackageCopies, innerDouble, mockAccessorsProp, mockConstructor, mockDeep, mockReadonlyProp, mockReadonlyPropGetter, mockValueProp, moduleNamespace, narrow, outOfType, registerAutoSpyDefaults, reportPropsOutsideHooks, resetAutoSpy, restoreMockedProps, restoreSpiedInstance, setEmissionTimeout, settleDynamicImport, spyOnOwnMethod, spyOnVoidMethod, stubConstructor, withOverrides } from './index.js';
3
3
 
4
4
  // vitest-auto-spy-host-reexport:src/lib/use-vitest-adapter.ts
5
5
 
package/dist/rstest.d.ts CHANGED
@@ -1,5 +1,5 @@
1
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-BdYUK_Zv.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';
2
+ export { AdoptMockOptions, AdoptedMock, ArgCaptor, AsInstances, AssertMockedOptions, CallLog, CaptureArgOptions, ConstructorMock, ConstructorSpy, Deferred, FixtureFactory, FlushUntilOptions, MockDeepOptions, ModuleNamespace, ModuleNamespaceOptions, SpyClassOptions, adoptMock, asInstance, asInstances, asSpy, assertMocked, captureArg, clearAutoSpy, createDeferred, 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
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-ByzgYsbj.js';
4
4
  export { c as createFunctionSpy, d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-xpq8sPYM.js';
5
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-424cOHvI.js';
package/dist/rstest.js CHANGED
@@ -1,4 +1,4 @@
1
- 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-YAAE5465.js';
1
+ export { adoptMock, asInstance, asInstances, asSpy, assertMocked, captureArg, createDeferred, 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-EFUZ44HT.js';
2
2
  export { countMockedProps, mockAccessorsProp, mockReadonlyProp, mockReadonlyPropGetter, mockValueProp, reportPropsOutsideHooks, restoreMockedProps } from './chunk-RQLUH6RE.js';
3
3
  export { autoMocked, clearAutoSpy, clearAutoSpyDefaults, createAutoMock, createSpyFromClass, innerDouble, registerAutoSpyDefaults, resetAutoSpy } from './chunk-BCT7C6DQ.js';
4
4
  import './chunk-SF4GKKN4.js';
package/dist/svelte.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import './vitest-mock-types-B17-xaWt.js';
2
2
  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-BdYUK_Zv.js';
3
- 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 { AdoptMockOptions, AdoptedMock, ArgCaptor, AsInstances, AssertMockedOptions, CallLog, CaptureArgOptions, ConstructorMock, ConstructorSpy, Deferred, FixtureFactory, FlushUntilOptions, MockDeepOptions, ModuleNamespace, ModuleNamespaceOptions, SpyClassOptions, adoptMock, asInstance, asInstances, asSpy, assertMocked, captureArg, clearAutoSpy, createDeferred, 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';
4
4
  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-ByzgYsbj.js';
5
5
  export { c as createFunctionSpy, d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-xpq8sPYM.js';
6
6
  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-424cOHvI.js';
package/dist/svelte.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ɵuse_vitest_adapter$useVitestAdapter as _use_vitest_adapter$useVitestAdapter } from './index.js';
2
- export { adoptMock, asInstance, asInstances, asSpy, assertMocked, autoMocked, captureArg, clearAutoSpy, clearAutoSpyDefaults, countMockedProps, createAutoMock, createFixture, createFixtureFactory, createFunctionSpy, createLog, createMock, createSpyClass, createSpyFromClass, createSpyFromInstance, describeDuplicateCopies, errorHandler, expectAllEmissions, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, expectNoEmissionSync, flushEventLoop, flushEventLoopUntil, getPackageCopies, innerDouble, mockAccessorsProp, mockConstructor, mockDeep, mockReadonlyProp, mockReadonlyPropGetter, mockValueProp, moduleNamespace, narrow, outOfType, registerAutoSpyDefaults, reportPropsOutsideHooks, resetAutoSpy, restoreMockedProps, restoreSpiedInstance, setEmissionTimeout, settleDynamicImport, spyOnOwnMethod, spyOnVoidMethod, stubConstructor, withOverrides } from './index.js';
2
+ export { adoptMock, asInstance, asInstances, asSpy, assertMocked, autoMocked, captureArg, clearAutoSpy, clearAutoSpyDefaults, countMockedProps, createAutoMock, createDeferred, createFixture, createFixtureFactory, createFunctionSpy, createLog, createMock, createSpyClass, createSpyFromClass, createSpyFromInstance, describeDuplicateCopies, errorHandler, expectAllEmissions, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, expectNoEmissionSync, flushEventLoop, flushEventLoopUntil, getPackageCopies, innerDouble, mockAccessorsProp, mockConstructor, mockDeep, mockReadonlyProp, mockReadonlyPropGetter, mockValueProp, moduleNamespace, narrow, outOfType, registerAutoSpyDefaults, reportPropsOutsideHooks, resetAutoSpy, restoreMockedProps, restoreSpiedInstance, setEmissionTimeout, settleDynamicImport, spyOnOwnMethod, spyOnVoidMethod, stubConstructor, withOverrides } from './index.js';
3
3
 
4
4
  // vitest-auto-spy-host-reexport:src/lib/use-vitest-adapter.ts
5
5
 
package/dist/vue.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import './vitest-mock-types-B17-xaWt.js';
2
2
  import { S as Spy, m as ClassType, C as ClassSpyConfiguration, u as OnlyMethodKeysOf } from './types-BdYUK_Zv.js';
3
3
  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, 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, v as OnlyObservablePropsOf, w as OnlyPropsOf, x as Overload, y as OverloadChoice, z as Overloads, P as PropStubValue, R as ReturnsClassEntry, 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-BdYUK_Zv.js';
4
- 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';
4
+ export { AdoptMockOptions, AdoptedMock, ArgCaptor, AsInstances, AssertMockedOptions, CallLog, CaptureArgOptions, ConstructorMock, ConstructorSpy, Deferred, FixtureFactory, FlushUntilOptions, MockDeepOptions, ModuleNamespace, ModuleNamespaceOptions, SpyClassOptions, adoptMock, asInstance, asInstances, asSpy, assertMocked, captureArg, clearAutoSpy, createDeferred, 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';
5
5
  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-ByzgYsbj.js';
6
6
  export { c as createFunctionSpy, d as describeDuplicateCopies, g as getPackageCopies } from './package-identity-xpq8sPYM.js';
7
7
  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-424cOHvI.js';
package/dist/vue.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ɵuse_vitest_adapter$useVitestAdapter as _use_vitest_adapter$useVitestAdapter, createSpyFromClass } from './index.js';
2
- export { adoptMock, asInstance, asInstances, asSpy, assertMocked, autoMocked, captureArg, clearAutoSpy, clearAutoSpyDefaults, countMockedProps, createAutoMock, createFixture, createFixtureFactory, createFunctionSpy, createLog, createMock, createSpyClass, createSpyFromClass, createSpyFromInstance, describeDuplicateCopies, errorHandler, expectAllEmissions, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, expectNoEmissionSync, flushEventLoop, flushEventLoopUntil, getPackageCopies, innerDouble, mockAccessorsProp, mockConstructor, mockDeep, mockReadonlyProp, mockReadonlyPropGetter, mockValueProp, moduleNamespace, narrow, outOfType, registerAutoSpyDefaults, reportPropsOutsideHooks, resetAutoSpy, restoreMockedProps, restoreSpiedInstance, setEmissionTimeout, settleDynamicImport, spyOnOwnMethod, spyOnVoidMethod, stubConstructor, withOverrides } from './index.js';
2
+ export { adoptMock, asInstance, asInstances, asSpy, assertMocked, autoMocked, captureArg, clearAutoSpy, clearAutoSpyDefaults, countMockedProps, createAutoMock, createDeferred, createFixture, createFixtureFactory, createFunctionSpy, createLog, createMock, createSpyClass, createSpyFromClass, createSpyFromInstance, describeDuplicateCopies, errorHandler, expectAllEmissions, expectCompletion, expectEmission, expectEmissions, expectError, expectNoEmission, expectNoEmissionSync, flushEventLoop, flushEventLoopUntil, getPackageCopies, innerDouble, mockAccessorsProp, mockConstructor, mockDeep, mockReadonlyProp, mockReadonlyPropGetter, mockValueProp, moduleNamespace, narrow, outOfType, registerAutoSpyDefaults, reportPropsOutsideHooks, resetAutoSpy, restoreMockedProps, restoreSpiedInstance, setEmissionTimeout, settleDynamicImport, spyOnOwnMethod, spyOnVoidMethod, stubConstructor, withOverrides } from './index.js';
3
3
 
4
4
  // vitest-auto-spy-host-reexport:src/lib/use-vitest-adapter.ts
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-auto-spy",
3
- "version": "5.60.0",
3
+ "version": "5.63.0",
4
4
  "description": "Auto-generate fully-typed test spies from a class — across Vitest, Bun, node:test and Rstest, 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: Typed spies on Vitest, bun:test, node:test and Rstest. Use when a spec imports vitest-auto-spy or a subpath (/angular, /angular/*, /signal-forms, /bun-angular, /bun, /node, /rstest, /rxjs, /diagnostics, /nestjs, /jasmine, /setup, /zone, /eslint-plugin), naming createSpyFromClass, createAutoMock, createMock, mockDeep, subscribeSpyTo, provideAutoSpy, provideHttpTesting, expectRequest, stubResponse, injectSpy, createNestUnit, extendWithAutoSpies, renderShallow, createWithAutoSpies, enableAngularDiagnostics, trackInjections, runEffect, settleResource, mockResourceProp, mockSignalProp, mockReadonlyProp, registerAutoSpyDefaults, provideActivatedRoute, provideLocationDouble, collectRouterEvents, createLog, createComponentStub, createForm, toHaveFieldErrors, stubWebStorage, assertNoShadowedProviders, createSpyFromInstance, adoptMock, spyOnOwnMethod, spyOnVoidMethod, explainSpy, compareTestRuns, expectEmission, setupAutoSpy, setSpyEngine, assertMocked, calledWith, mustBeCalledWith, captureArg, ArgumentCaptor, onlyMethodsToSpyOn, onUnstubbedCall, passthrough, resolveWith or nextWith, migrating off jest-auto-spies, jasmine-auto-spies or @ngneat/spectator, or a test fails with "No mock adapter registered", "Observable spies require rxjs", "not a method of", "strict double has nothing configured", "the override did not apply", "is not a constructor", "Expected to be running in 'ProxyZone'", "jasmine is not defined", "no HttpTestingController", "localStorage.setItem is not a function" or "Spy<T> is not assignable".
3
+ description: Typed spies on Vitest, bun:test, node:test and Rstest. Use when a spec imports vitest-auto-spy (/angular, /angular/*, /signal-forms, /bun-angular, /bun, /node, /rstest, /rxjs, /diagnostics, /nestjs, /jasmine, /setup, /zone, /eslint-plugin), naming createSpyFromClass, createAutoMock, createMock, mockDeep, subscribeSpyTo, provideAutoSpy, createWindowSpies, provideHttpTesting, expectRequest, stubResponse, injectSpy, createNestUnit, extendWithAutoSpies, renderShallow, createWithAutoSpies, enableAngularDiagnostics, trackInjections, runEffect, settleResource, mockResourceProp, mockSignalProp, mockReadonlyProp, registerAutoSpyDefaults, provideActivatedRoute, provideLocationDouble, collectRouterEvents, createLog, createComponentStub, createForm, toHaveFieldErrors, stubWebStorage, assertNoShadowedProviders, createSpyFromInstance, adoptMock, spyOnOwnMethod, spyOnVoidMethod, explainSpy, compareTestRuns, expectEmission, setupAutoSpy, setSpyEngine, assertMocked, calledWith, mustBeCalledWith, captureArg, ArgumentCaptor, onlyMethodsToSpyOn, onUnstubbedCall, passthrough, resolveWith or nextWith, migrating off jest-auto-spies, jasmine-auto-spies or @ngneat/spectator, or a test fails with "No mock adapter registered", "Observable spies require rxjs", "not a method of", "strict double has nothing configured", "the override did not apply", "is not a constructor", "Expected to be running in 'ProxyZone'", "jasmine is not defined", "no HttpTestingController", "localStorage.setItem is not a function" or "Spy<T> is not assignable".
4
4
  ---
5
5
 
6
6
  # vitest-auto-spy
@@ -216,6 +216,7 @@ it('loads', async () => {
216
216
  | a `vi.mock` factory's `vi.fn()` needs `calledWith` / `resolveWith` | `adoptMock(api.load).calledWith(7).resolveWith(…)` — same object, history kept |
217
217
  | real module, one case configured | `vi.mock('x', async (orig) => moduleNamespace(await orig(), { passthrough: true }))` |
218
218
  | feeding a stubbed `fetch` | `vi.fn(async () => stubResponse({ body: data }))` from `/setup` — a real `Response`, no `as Response`; a body reads once |
219
+ | an awaited dependency must stay pending while the test checks intermediate state | `createDeferred<T>()` from the core entry — return `.promise` from the spy, then `.resolve(value)` or `.reject(reason)` before awaiting the operation |
219
220
  | a backend that answers the JSON literal `null` | `stubResponse({ body: null })` — the literal, not "no body"; `undefined` or an omitted `body` is the way to send none |
220
221
  | the code under test lazy-loads on a click and the spec has no promise | `await settleDynamicImport(() => import('./thing'))` — a bare `await import(…)` waits for the module, not for the handler's continuation |
221
222
  | MSW handlers not answering under `setupAutoSpy({ blockNetwork: true })` | upgrade — `blockNetwork` now leaves `fetch` to MSW's interceptor; end the handlers with `http.all('*', () => HttpResponse.error())` |
@@ -329,11 +330,17 @@ it('loads', async () => {
329
330
  | a component that reads `location.back()`, or asserts where a redirect landed | `provideLocationDouble()` + `injectLocationDouble()` — Angular's own `SpyLocation`; without the provider, `Location` is `providedIn: 'root'` and the real one answers |
330
331
  | "did A run before B?" across three collaborators | `createLog<'drop-cache' \| 'flush'>()` — hand `log.fn('drop-cache')` to each, assert `log.result()` once |
331
332
  | a `window` or `document` behind a DI token | `provideWindowDouble(WINDOW, { screen })` / `provideDocumentDouble({ … })` — `/angular/doubles` |
333
+ | selected void window methods, such as `location.reload` or `parent.postMessage` | `createWindowSpies({ location: ['reload'], parent: ['postMessage'] })` from `/angular/doubles` — pass the result to `provideWindowDouble(WINDOW, spies)`; each spy returns `undefined` without calling the browser. For root methods, use `createWindowSpies(['close', 'focus'])`. |
332
334
  | `MAT_DIALOG_DATA` and `MatDialogRef` provided by hand | `provideMatDialogData(TOKEN, data)` / `provideMatDialogRef(MatDialogRef)` + `injectMatDialogRef(Ref)` — `/angular/doubles` |
333
335
  | asserting a `computed()` did **not** recompute | `trackRecomputations(sig)` / `trackEffectRuns(ref)` — `{ count, stop() }` |
334
336
  | `form()` in a spec, or `errors()` read by hand | `createForm(model, schema)` + `registerFormMatchers()` — then `toHaveFieldErrors([…])` (`/signal-forms`) |
335
337
  | any of those doubles without a `TestBed` | `createRouterDouble` (`/angular-router`) / `createWindowDouble` / `createDocumentDouble` / `createMatDialogRef` (`/angular/doubles`) |
336
338
 
339
+ When composing window spies with data overrides, keep the nested spies too:
340
+ `provideWindowDouble(WINDOW, { ...spies, location: { ...spies.location, hostname: 'example.test' } })`.
341
+ Assert calls on `spies.location.reload` or `spies.parent.postMessage`. For methods returning a value,
342
+ use `createFunctionSpy` from the core and configure that value explicitly.
343
+
337
344
  ## Rules that prevent most of the mistakes
338
345
 
339
346
  - Declare the variable as **`Spy<T>`, never as `T`** — `Spy<T>` is a mapped type and drops private