vitest-auto-spy 5.3.0 → 5.4.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 +26 -0
- package/README.md +84 -61
- package/dist/angular.d.ts +1 -1
- package/dist/angular.js +224 -142
- package/dist/bun-angular.d.ts +2 -2
- package/dist/bun-angular.js +36 -19
- package/dist/bun.d.ts +49 -3
- package/dist/bun.js +6 -6
- package/dist/{chunk-JJ2JA2E3.js → chunk-5AOJI3BM.js} +3 -2
- package/dist/{chunk-ED4EVQKA.js → chunk-6YI3G3CH.js} +2 -3
- package/dist/{chunk-XRVVZXOM.js → chunk-75GDWUIT.js} +28 -1
- package/dist/{chunk-KE3LEHPW.js → chunk-DBDXQXS3.js} +15 -8
- package/dist/{chunk-XAS66AWX.js → chunk-EGU3YJJN.js} +2 -29
- package/dist/{chunk-J33KX6XT.js → chunk-JOODFKWS.js} +47 -26
- package/dist/{chunk-URZIJ5CL.js → chunk-NLDPCJKC.js} +4 -4
- package/dist/{chunk-GOG2CJOY.js → chunk-OYQ2PHBU.js} +1 -1
- package/dist/{chunk-5TUDM4DS.js → chunk-QY4UO4BB.js} +67 -19
- package/dist/{chunk-NHSUUN3D.js → chunk-WWO6CUEJ.js} +1 -1
- package/dist/cli.js +51 -10
- package/dist/console.js +4 -4
- package/dist/dom-stubs.js +70 -50
- package/dist/index.d.ts +1 -1
- package/dist/index.js +172 -98
- package/dist/jasmine.js +6 -6
- package/dist/nestjs.js +12 -12
- package/dist/node.cjs +118 -87
- package/dist/node.d.ts +1 -1
- package/dist/node.js +8 -7
- package/dist/react.d.ts +1 -1
- package/dist/react.js +7 -7
- package/dist/rstest.d.ts +1 -1
- package/dist/rstest.js +9 -8
- package/dist/rxjs.js +11 -6
- package/dist/setup.js +6 -6
- package/dist/shared-state.js +1 -53
- package/dist/svelte.d.ts +1 -1
- package/dist/svelte.js +7 -7
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +8 -8
- package/dist/{zoneless-BerZbxtu.d.ts → zoneless-DM1AWQV2.d.ts} +6 -1
- package/package.json +3 -2
- package/skills/vitest-auto-spy/SKILL.md +2 -1
package/AGENTS.md
CHANGED
|
@@ -691,6 +691,21 @@ A second registration for the same class replaces the first, because two of them
|
|
|
691
691
|
drift this removes rather than a merge to perform. `clearAutoSpyDefaults(Class)` drops one,
|
|
692
692
|
`clearAutoSpyDefaults()` the lot.
|
|
693
693
|
|
|
694
|
+
A setup file that registers more than a handful of classes can say them as one table instead of one
|
|
695
|
+
call each. Rows apply in order, and each is checked against **its own** class — a key `Router` does
|
|
696
|
+
not carry fails on that row, naming `Router`'s members and nothing else:
|
|
697
|
+
|
|
698
|
+
```ts
|
|
699
|
+
registerAutoSpyDefaults([
|
|
700
|
+
[Router, { observablePropsToSpyOn: ['events'], gettersToSpyOn: ['url'] }],
|
|
701
|
+
[DomainEventsService, { instanceMethodsToSpyOn: ['announce'] }],
|
|
702
|
+
[BaseLocalStorage, { instanceMethodsToSpyOn: ['getItem', 'setItem'] }],
|
|
703
|
+
]);
|
|
704
|
+
```
|
|
705
|
+
|
|
706
|
+
A later row for a class an earlier row already named replaces it, exactly as a second call would.
|
|
707
|
+
`AutoSpyDefaultEntry<T>` is the row type, for a row built outside the literal.
|
|
708
|
+
|
|
694
709
|
### `strict` — a method nobody configured throws instead of answering `undefined`
|
|
695
710
|
|
|
696
711
|
```ts
|
|
@@ -2872,6 +2887,17 @@ re-exporting a whole directory). When `environment` + `setup` + `prepare` togeth
|
|
|
2872
2887
|
of that trade rather than restating them — read that page before recommending the flag, since it
|
|
2873
2888
|
raises peak memory.
|
|
2874
2889
|
|
|
2890
|
+
Two more findings are about settings rather than files. `perf-environment-engine` fires when
|
|
2891
|
+
`environment` dominates and a `vite(st).config.*` names `jsdom` while nothing in those configs
|
|
2892
|
+
mentions `happy-dom`: measured on this package's own 117-file Angular suite, `happy-dom` is 23.2 s of
|
|
2893
|
+
user CPU against jsdom's 26.5 s, and on a spec that builds a DOM and does nothing else the gap is
|
|
2894
|
+
253 ms against 119 ms per file. It is a swap, not a flag — `happy-dom` implements less of the
|
|
2895
|
+
platform — so take one project at a time. `perf-workers` fires on a run over a minute of summed CPU
|
|
2896
|
+
that declares no `maxWorkers`, and it is the one finding here about **memory**: one worker per core
|
|
2897
|
+
is the default, resident memory measured at 1.42 GB plus ~155 MB per worker, and a cap of four costs
|
|
2898
|
+
about 2.8 % of wall clock. Do not quote a worker count as universally right — it is a property of
|
|
2899
|
+
the machine.
|
|
2900
|
+
|
|
2875
2901
|
`--json <path>` re-analyses a report an earlier `--out <path>` run wrote, instead of running Vitest
|
|
2876
2902
|
again. Full reference: <https://asdalexey.github.io/vitest-auto-spy/utilities/cli>.
|
|
2877
2903
|
|
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ faster at suite scale ([benchmarks](#benchmarks)) — and for
|
|
|
23
23
|
[](https://www.npmjs.com/package/vitest-auto-spy)
|
|
24
24
|
[](https://www.npmjs.com/package/vitest-auto-spy)
|
|
25
25
|
[](https://github.com/ASDAlexey/vitest-auto-spy/actions/workflows/ci.yml)
|
|
26
|
-
[](#install)
|
|
27
27
|
[](https://www.npmjs.com/package/vitest-auto-spy)
|
|
28
28
|
[](https://github.com/ASDAlexey/vitest-auto-spy/actions/workflows/ci.yml)
|
|
29
29
|
[](./LICENSE)
|
|
@@ -442,6 +442,13 @@ per file) and `transform` (whole run). Where the isolation finding suggests `tes
|
|
|
442
442
|
it links to this package's own memory measurements rather than repeating the numbers here — that
|
|
443
443
|
flag trades per-file cleanup for memory that grows with the suite.
|
|
444
444
|
|
|
445
|
+
Two findings are about settings rather than files. `perf-environment-engine` offers `happy-dom` to a
|
|
446
|
+
`jsdom` config whose environment time dominates — 23.2 s of user CPU against 26.5 s on this
|
|
447
|
+
repository's own 117-file suite, and 119 ms against 253 ms per file on a spec that builds a DOM and
|
|
448
|
+
does nothing else. `perf-workers` is the one about **memory**: with no `maxWorkers` declared, Vitest
|
|
449
|
+
takes one worker per core, and a worker measured at ~155 MB on top of a 1.42 GB floor — a cap of four
|
|
450
|
+
cost 2.8 % of wall clock and about 2 GB less on a 16-core machine.
|
|
451
|
+
|
|
445
452
|
Full reference, phase by phase and finding by finding: **[The CLI](https://asdalexey.github.io/vitest-auto-spy/utilities/cli)**.
|
|
446
453
|
|
|
447
454
|
### `codemod` — migrating a suite off `jest-auto-spies`
|
|
@@ -1683,6 +1690,19 @@ Registration is by class identity — a subclass inherits nothing — and a seco
|
|
|
1683
1690
|
class replaces the first, because two of them in one suite is the drift this removes.
|
|
1684
1691
|
`clearAutoSpyDefaults(Class)` drops one, `clearAutoSpyDefaults()` the lot.
|
|
1685
1692
|
|
|
1693
|
+
Many classes at once are a table rather than a call each. Rows apply in order, each checked against
|
|
1694
|
+
**its own** class:
|
|
1695
|
+
|
|
1696
|
+
```ts
|
|
1697
|
+
registerAutoSpyDefaults([
|
|
1698
|
+
[Router, { observablePropsToSpyOn: ['events'], gettersToSpyOn: ['url'] }],
|
|
1699
|
+
[AccountService, { gettersToSpyOn: ['isGuest'] }],
|
|
1700
|
+
]);
|
|
1701
|
+
```
|
|
1702
|
+
|
|
1703
|
+
A later row for a class an earlier row already named replaces it, exactly as a second call would.
|
|
1704
|
+
`AutoSpyDefaultEntry<T>` is the row type, for a row built outside the literal.
|
|
1705
|
+
|
|
1686
1706
|
### Spying instance-assigned callables (`signal()`, arrow props, `signalStore()`)
|
|
1687
1707
|
|
|
1688
1708
|
`createSpyFromClass` discovers methods by walking the **prototype**, so a callable assigned on the
|
|
@@ -2135,11 +2155,14 @@ per-render ratio is also the upper bound on what a whole spec file can gain rath
|
|
|
2135
2155
|
of it: a file's wall clock pays for imports, the `TestBed` module and the assertions too, none of
|
|
2136
2156
|
which shallow rendering touches.
|
|
2137
2157
|
|
|
2138
|
-
`keepTemplate: true` is the middle rung — the component's own template with an empty subtree.
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
`NO_ERRORS_SCHEMA`.
|
|
2142
|
-
`
|
|
2158
|
+
`keepTemplate: true` is the middle rung — the component's own template with an empty subtree. The
|
|
2159
|
+
override keeps the component's own `imports` minus the child *components*, so the template renders
|
|
2160
|
+
with its own pipes and directives working while every child component in it resolves to nothing
|
|
2161
|
+
under `NO_ERRORS_SCHEMA`. (Before 5.4.0 the whole scope was dropped, which made a pipe in a kept
|
|
2162
|
+
template throw `NG0302` and an attribute directive silently never apply.) A child re-exported by an
|
|
2163
|
+
imported `NgModule` still renders — the module is kept whole. Reach for it when the spec reads
|
|
2164
|
+
something the template creates, and keep `keepChildren` for the handful of children it genuinely
|
|
2165
|
+
needs resolvable. Full write-up:
|
|
2143
2166
|
[Performance](https://asdalexey.github.io/vitest-auto-spy/core/performance#_2-rendering-the-child-subtree).
|
|
2144
2167
|
|
|
2145
2168
|
Use [the diagnostics](#where-a-spec-spends-its-time) to find the files worth converting rather than
|
|
@@ -3277,62 +3300,62 @@ another, and the next one is in that same file.
|
|
|
3277
3300
|
|
|
3278
3301
|
## API reference
|
|
3279
3302
|
|
|
3280
|
-
| Export
|
|
3281
|
-
|
|
|
3282
|
-
| `createSpyFromClass(Class, methodsOrConfig?)`
|
|
3283
|
-
| `createSpyFromInstance(instance, methodsOrConfig?)`
|
|
3284
|
-
| `restoreSpiedInstance(instance)`
|
|
3285
|
-
| `createAutoMock<T>(overrides?, config?)`
|
|
3286
|
-
| `createMock<T>(partial?)`
|
|
3287
|
-
| `createFixture<T>(defaults, overrides?)` / `createFixtureFactory<T>(defaults)`
|
|
3288
|
-
| `mockDeep<T>(overrides?, options?)`
|
|
3289
|
-
| `resetAutoSpy(spy)` / `clearAutoSpy(spy)`
|
|
3290
|
-
| `spy[Symbol.dispose]()`
|
|
3291
|
-
| `{ strict, onUnstubbedCall }` on the factories and `setupAutoSpy`
|
|
3292
|
-
| `provideAutoSpy(Class, methodsOrConfig?)`
|
|
3293
|
-
| `provideAutoSpy(token, Class, methodsOrConfig?)`
|
|
3294
|
-
| `injectSpy(token)` _(Angular)_ / `injectSpy(moduleRef, token)` _(NestJS)_
|
|
3295
|
-
| `createFunctionSpy(name)`
|
|
3296
|
-
| `createObservableWithValues(configs, opts?)`
|
|
3297
|
-
| `mockReadonlyProp` / `mockReadonlyPropGetter` / `mockValueProp` / `mockAccessorsProp`
|
|
3298
|
-
| `restoreMockedProps()` / `countMockedProps()`
|
|
3299
|
-
| `expectEmission(source$, opts?)` / `expectEmissions(source$, n, opts?)` / `expectNoEmission(source$, opts?)`
|
|
3300
|
-
| `expectCompletion(source$, opts?)` / `expectError(source$, opts?)`
|
|
3301
|
-
| `setEmissionTimeout(ms)`
|
|
3302
|
-
| `asInstance(spy)` / `asSpy(instance)`
|
|
3303
|
-
| `createSpyClass(Class, config?)`
|
|
3304
|
-
| `mockConstructor(factory, name?)` / `stubConstructor(obj, key, factory)`
|
|
3305
|
-
| `stubAbortController()`
|
|
3306
|
-
| `flushEventLoop(turns?)` / `settleDynamicImport(load, turns?)`
|
|
3307
|
-
| `autoMocked<T>(overrides?)`
|
|
3308
|
-
| `mockSystemTime` / `withSystemTime` / `mockNow` / `useCountingClock` _(`/setup`)_
|
|
3309
|
-
| `registerFocusMatchers()` _(`/setup`)_
|
|
3310
|
-
| `overrideAutoSpy` / `overrideComponentProvider` / `assertNgModuleScopes` / `assertComponentDefIntact` _(Angular)_
|
|
3303
|
+
| Export | Description |
|
|
3304
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
3305
|
+
| `createSpyFromClass(Class, methodsOrConfig?)` | Build a fully-typed `Spy<T>` from a class |
|
|
3306
|
+
| `createSpyFromInstance(instance, methodsOrConfig?)` | Patch an object the test already holds **in place**, so everything that captured it sees the spies |
|
|
3307
|
+
| `restoreSpiedInstance(instance)` | Put one spied instance back — `restoreMockedProps()` and `using` do the same, and all three compose |
|
|
3308
|
+
| `createAutoMock<T>(overrides?, config?)` | Build a `Spy<T>` from a **type/interface** alone (Proxy, no class); `{ returns, observablePropsToSpyOn }` configure it |
|
|
3309
|
+
| `createMock<T>(partial?)` | Build a plain, spy-free `T` from the fields a test seeds — for data shapes the code under test reads |
|
|
3310
|
+
| `createFixture<T>(defaults, overrides?)` / `createFixtureFactory<T>(defaults)` | A model written out and checked once, stamped into a fresh copy per test — for the fixture eight specs would otherwise each keep a copy of |
|
|
3311
|
+
| `mockDeep<T>(overrides?, options?)` | Build a **recursive** auto-mock — `mock.repo.user.find()` chains without seeding; `{ selfReturning: true }` chains through calls too |
|
|
3312
|
+
| `resetAutoSpy(spy)` / `clearAutoSpy(spy)` | Reset every spy in an auto-spy at once — `reset` also reverts return-value config (`calledWith` **and** a bare `mockReturnValue`); `clear` keeps it |
|
|
3313
|
+
| `spy[Symbol.dispose]()` | What `using spy = createSpyFromClass(X)` runs at the end of the block — `resetAutoSpy(this)`, on every double including each `mockDeep` node |
|
|
3314
|
+
| `{ strict, onUnstubbedCall }` on the factories and `setupAutoSpy` | Throw (or run a handler) on a method nobody configured, naming the class, the method and the arguments |
|
|
3315
|
+
| `provideAutoSpy(Class, methodsOrConfig?)` | Angular / NestJS `{ provide, useValue }` shorthand — an `abstract class` DI token included |
|
|
3316
|
+
| `provideAutoSpy(token, Class, methodsOrConfig?)` | Vue `{ [token]: Spy<T> }` for `global.provide` |
|
|
3317
|
+
| `injectSpy(token)` _(Angular)_ / `injectSpy(moduleRef, token)` _(NestJS)_ | Inject typed as `Spy<T>` |
|
|
3318
|
+
| `createFunctionSpy(name)` | A single standalone function spy with all helpers |
|
|
3319
|
+
| `createObservableWithValues(configs, opts?)` | Build an Observable from value configs |
|
|
3320
|
+
| `mockReadonlyProp` / `mockReadonlyPropGetter` / `mockValueProp` / `mockAccessorsProp` | Mock readonly / writable / accessor / signal props |
|
|
3321
|
+
| `restoreMockedProps()` / `countMockedProps()` | Undo every `mock*Prop` patch (descriptors restored newest-first) / how many are still applied |
|
|
3322
|
+
| `expectEmission(source$, opts?)` / `expectEmissions(source$, n, opts?)` / `expectNoEmission(source$, opts?)` | Assert an Observable without a `subscribe` callback that may never run; the emitted type is inferred |
|
|
3323
|
+
| `expectCompletion(source$, opts?)` / `expectError(source$, opts?)` | Assert that a stream terminates; await the error it fails with, unwrapped |
|
|
3324
|
+
| `setEmissionTimeout(ms)` | Change the process-wide default wait of the emission helpers |
|
|
3325
|
+
| `asInstance(spy)` / `asSpy(instance)` | The two named views between `Spy<T>` / `DeepMockProxy<T>` and `T`, instead of `as any` |
|
|
3326
|
+
| `createSpyClass(Class, config?)` | A spy that can be called with `new`; records `calls` and `instances` |
|
|
3327
|
+
| `mockConstructor(factory, name?)` / `stubConstructor(obj, key, factory)` | A runner mock that is also a constructor — for a global or an SDK with no class at runtime |
|
|
3328
|
+
| `stubAbortController()` | A realm-consistent `AbortController` / `AbortSignal` for jsdom + zone.js, statics (`abort`, `timeout`, `any`) included |
|
|
3329
|
+
| `flushEventLoop(turns?)` / `settleDynamicImport(load, turns?)` | Real event-loop turns under fake timers; wait for a dynamic `import()` |
|
|
3330
|
+
| `autoMocked<T>(overrides?)` | `createAutoMock` typed as `T & Spy<T>` |
|
|
3331
|
+
| `mockSystemTime` / `withSystemTime` / `mockNow` / `useCountingClock` _(`/setup`)_ | Clock control that survives fake timers being re-installed per test |
|
|
3332
|
+
| `registerFocusMatchers()` _(`/setup`)_ | Adds `expect(el).toHaveFocus()` |
|
|
3333
|
+
| `overrideAutoSpy` / `overrideComponentProvider` / `assertNgModuleScopes` / `assertComponentDefIntact` _(Angular)_ | Override a component-level provider — and verify on the next fixture that the override applied; diagnose an NgModule with an empty runtime scope |
|
|
3311
3334
|
| `enableAngularDiagnostics(opts?)` / `disableAngularDiagnostics()` / `assertNoPendingRequests()` / `assertNoShadowedProviders()` _(Angular)_ | `ngModuleScopes`, `deadSchemas`, `unspiedProviders`, `shadowedProviders` and `pendingRequests`: a dead NgModule import, `schemas` that can never apply, an unspied provider, a double the component's own `providers` shadow, and unflushed HTTP requests — each as a failure |
|
|
3312
|
-
| `trackInjections(tokens, opts?)` _(Angular, NestJS)_
|
|
3313
|
-
| `setupAutoSpy(opts?)` _(`/setup`)_
|
|
3314
|
-
| `registerAutoSpyDefaults(Class, config)` / `clearAutoSpyDefaults(Class?)`
|
|
3315
|
-
| `setupFakeTimers(config?)` / `advanceTimers(ms?)` _(`/setup`)_
|
|
3316
|
-
| `describeDuplicateCopies()` / `getPackageCopies()`
|
|
3317
|
-
| `renderShallow(Component, opts?)` _(Angular)_
|
|
3318
|
-
| `createWithAutoSpies(Class, opts?)` _(Angular)_
|
|
3319
|
-
| `createNestUnit(Class, opts?)` _(NestJS)_
|
|
3320
|
-
| `stable(fixture, opts?)` / `flushEffects()` _(Angular)_
|
|
3321
|
-
| `settleResource(resource, opts?)` _(Angular)_
|
|
3322
|
-
| `provideHttpTesting(opts?)` / `expectRequest(matcher, opts?)` _(`/angular-http`)_
|
|
3323
|
-
| `expectNoRequest(matcher?, opts?)` / `verifyNoPendingRequests()` _(`/angular-http`)_
|
|
3324
|
-
| `registerSignalMatchers()` _(Angular)_
|
|
3325
|
-
| `enableTestBedDiagnostics(opts?)` _(Angular)_
|
|
3326
|
-
| `setupAngularTestEnv(opts)` _(Angular)_
|
|
3327
|
-
| `stubMediaElement(opts?)`
|
|
3328
|
-
| `assertMocked(namespace, opts?)` / `moduleNamespace(exports, opts?)`
|
|
3329
|
-
| `flushEventLoopUntil(isDone, opts?)`
|
|
3330
|
-
| `diffByField(actual, expected)`
|
|
3331
|
-
| `guardGlobalPatches(reaction)` / `installPerTest(install)` _(`/setup`)_
|
|
3332
|
-
| `consoleDebugSpy` … `consoleWarnSpy` _(`/console`)_
|
|
3333
|
-
| `installConsoleSpies()` / `resetConsoleSpies()` / `restoreConsole()`
|
|
3334
|
-
| `explainSpy(spy, method?)` _(`/diagnostics`)_
|
|
3335
|
-
| `errorHandler`
|
|
3335
|
+
| `trackInjections(tokens, opts?)` _(Angular, NestJS)_ | Providers that record which collaborators DI constructed, with an auto-spy behind each token |
|
|
3336
|
+
| `setupAutoSpy(opts?)` _(`/setup`)_ | Property restore + duplicate-copy detection + mock-registry hygiene, in one call |
|
|
3337
|
+
| `registerAutoSpyDefaults(Class, config)` / `registerAutoSpyDefaults([[Class, config], …])` / `clearAutoSpyDefaults(Class?)` | A class's spy composition registered once — one class, or a table of them — merged into every `createSpyFromClass(X)` / `provideAutoSpy(X)` from then on |
|
|
3338
|
+
| `setupFakeTimers(config?)` / `advanceTimers(ms?)` _(`/setup`)_ | Paired fake-timer install/restore, and an advance that also settles queued microtasks |
|
|
3339
|
+
| `describeDuplicateCopies()` / `getPackageCopies()` | The duplicate-install report, and the copies behind it |
|
|
3340
|
+
| `renderShallow(Component, opts?)` _(Angular)_ | `TestBed` component, minus its children and (by default) its template |
|
|
3341
|
+
| `createWithAutoSpies(Class, opts?)` _(Angular)_ | Build a class through Angular DI with every unprovided token auto-spied |
|
|
3342
|
+
| `createNestUnit(Class, opts?)` _(NestJS)_ | Build a provider from its DI metadata with every unprovided token auto-spied; `expose` builds collaborators for real, `providers` wins over both |
|
|
3343
|
+
| `stable(fixture, opts?)` / `flushEffects()` _(Angular)_ | Zoneless waiting: flush effects, then await the fixture, with a 2 s budget that names the cause |
|
|
3344
|
+
| `settleResource(resource, opts?)` _(Angular)_ | Tick until an `httpResource()` / `resource()` / `rxResource()` leaves `loading` |
|
|
3345
|
+
| `provideHttpTesting(opts?)` / `expectRequest(matcher, opts?)` _(`/angular-http`)_ | `provideHttpClient()` + `provideHttpClientTesting()` in one spread; find the one matching request and `flush` / `error` it with the settling included |
|
|
3346
|
+
| `expectNoRequest(matcher?, opts?)` / `verifyNoPendingRequests()` _(`/angular-http`)_ | Assert that nothing was requested / that the test left nothing unanswered |
|
|
3347
|
+
| `registerSignalMatchers()` _(Angular)_ | Adds `expect(sig).toHaveSignalValue(value)` |
|
|
3348
|
+
| `enableTestBedDiagnostics(opts?)` _(Angular)_ | Per-file report of how much of a spec's time went into `TestBed` |
|
|
3349
|
+
| `setupAngularTestEnv(opts)` _(Angular)_ | Zone and zoneless spec files in one worker, switching platforms per file |
|
|
3350
|
+
| `stubMediaElement(opts?)` | A `<video>` / `<audio>` that plays, reports a duration and fires the media events |
|
|
3351
|
+
| `assertMocked(namespace, opts?)` / `moduleNamespace(exports, opts?)` | Prove a `vi.mock()` applied; give its factory the shape an interop probe recognises |
|
|
3352
|
+
| `flushEventLoopUntil(isDone, opts?)` | Real event-loop turns until a condition holds, with a budget instead of a hang |
|
|
3353
|
+
| `diffByField(actual, expected)` | Which field of an array of records moved, and in how many elements |
|
|
3354
|
+
| `guardGlobalPatches(reaction)` / `installPerTest(install)` _(`/setup`)_ | Name the test that sealed a global property; re-install a stub before every test |
|
|
3355
|
+
| `consoleDebugSpy` … `consoleWarnSpy` _(`/console`)_ | Silent typed spies replacing the global `console` methods on import |
|
|
3356
|
+
| `installConsoleSpies()` / `resetConsoleSpies()` / `restoreConsole()` | Install / clear / undo the console spies |
|
|
3357
|
+
| `explainSpy(spy, method?)` _(`/diagnostics`)_ | Every configured argument list next to every recorded call, attributed to the config it hit |
|
|
3358
|
+
| `errorHandler` | The `mustBeCalledWith` argument-mismatch error helper |
|
|
3336
3359
|
|
|
3337
3360
|
**Spied sync method:** `mockReturnValue`, `calledWith(...)`, `mustBeCalledWith(...)` — `calledWith`
|
|
3338
3361
|
also matches **asymmetric matchers** (`calledWith(expect.any(Number))`, `expect.objectContaining({...})`)
|
package/dist/angular.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { l as AngularTokenProvider, A as AngularValueProvider, a as AutoSpiedInstance, C as ComponentInputs, b as CreateWithAutoSpiesOptions, R as RenderShallowOptions, c as ResourceStatusLike, S as SettleResourceOptions, d as ShallowRender, e as SpyRegistry, f as StableOptions, g as createWithAutoSpies, h as flushEffects, i as injectSpy, p as provideAutoSpy, m as provideAutoSpyForToken, r as renderShallow, j as runEffect, s as settleResource, k as stable } from './zoneless-
|
|
1
|
+
export { l as AngularTokenProvider, A as AngularValueProvider, a as AutoSpiedInstance, C as ComponentInputs, b as CreateWithAutoSpiesOptions, R as RenderShallowOptions, c as ResourceStatusLike, S as SettleResourceOptions, d as ShallowRender, e as SpyRegistry, f as StableOptions, g as createWithAutoSpies, h as flushEffects, i as injectSpy, p as provideAutoSpy, m as provideAutoSpyForToken, r as renderShallow, j as runEffect, s as settleResource, k as stable } from './zoneless-DM1AWQV2.js';
|
|
2
2
|
import { InjectionToken, Provider, Type, Signal, WritableSignal } from '@angular/core';
|
|
3
3
|
import { TestAPI } from 'vitest';
|
|
4
4
|
import { C as ClassType, S as Spy, k as ClassSpyConfiguration, o as OnlyMethodKeysOf, g as AddSpyMethodsByReturnTypes } from './types-DTi4dIeN.js';
|