vitest-auto-spy 5.3.0 → 5.5.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 +219 -138
- package/README.md +183 -142
- package/dist/angular.d.ts +1 -1
- package/dist/angular.js +270 -143
- 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-XAS66AWX.js → chunk-7FUZBDFD.js} +2 -29
- package/dist/{chunk-NHSUUN3D.js → chunk-A7INJLDC.js} +1 -1
- package/dist/{chunk-XRVVZXOM.js → chunk-B4Z3CFDJ.js} +11 -1
- package/dist/{chunk-ED4EVQKA.js → chunk-E2JLMCOR.js} +2 -3
- package/dist/{chunk-JJ2JA2E3.js → chunk-EPTJRSSO.js} +3 -2
- package/dist/{chunk-KE3LEHPW.js → chunk-FPMWEHKF.js} +67 -9
- package/dist/{chunk-URZIJ5CL.js → chunk-M2ZI62ZY.js} +4 -4
- package/dist/{chunk-J33KX6XT.js → chunk-SNRHI2QI.js} +47 -26
- package/dist/{chunk-GOG2CJOY.js → chunk-UF47X335.js} +1 -1
- package/dist/{chunk-5TUDM4DS.js → chunk-XCIRU75U.js} +67 -7
- package/dist/cli.js +94 -29
- package/dist/console.js +4 -4
- package/dist/dom-stubs.js +74 -51
- package/dist/eslint-plugin.cjs +422 -137
- package/dist/eslint-plugin.d.cts +7 -0
- package/dist/eslint-plugin.d.ts +7 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +218 -99
- package/dist/jasmine.js +6 -6
- package/dist/nestjs.js +12 -12
- package/dist/node.cjs +103 -72
- 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.d.ts +30 -2
- package/dist/setup.js +102 -25
- 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 +82 -75
package/AGENTS.md
CHANGED
|
@@ -643,9 +643,9 @@ Also true, and worth not re-deriving:
|
|
|
643
643
|
for `@ts-expect-error`: one migration wrote sixty of those across twenty-five files before anyone
|
|
644
644
|
found this option, and each one stops checking the response shape that line exists to describe.
|
|
645
645
|
|
|
646
|
-
**Name the method rather than the whole double.** `'first'` on the type moves
|
|
646
|
+
**Name the method rather than the whole double.** `'first'` on the type moves _every_ overloaded
|
|
647
647
|
member, and on a wide type that breaks the ones nobody was fixing — `Spy<Response, { overload:
|
|
648
|
-
|
|
648
|
+
'first' }>` for one method collected five `TS2769`s on `download`. `overload` also takes a map:
|
|
649
649
|
|
|
650
650
|
```ts
|
|
651
651
|
let perf: Spy<Performance, { overload: { getEntriesByType: 'first' } }>;
|
|
@@ -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
|
|
@@ -808,7 +823,7 @@ carry (an index signature makes inference drop the default) and the union in `in
|
|
|
808
823
|
parameter (a union does too — a class now matches a bare construct-signature overload first).
|
|
809
824
|
Spelling the argument out still works and is still the answer when the class has **no** default.
|
|
810
825
|
|
|
811
|
-
**A generic
|
|
826
|
+
**A generic _method_ is a different thing, and it does collapse.** `show<T, U>(component: Type<T>,
|
|
812
827
|
data: U)` on a modal or factory service reaches `Spy<T>` through `Parameters` / `ReturnType`, which
|
|
813
828
|
instantiate the method's own type parameters — so the double types as `show(component: Type<unknown>,
|
|
814
829
|
data: unknown)`. No mapped type in TypeScript can preserve a generic signature, so this is a limit
|
|
@@ -1031,6 +1046,29 @@ property. That is how you add an Observable member that `provideAutoSpy` did not
|
|
|
1031
1046
|
What the second overload costs is the property-name check, so a typo in the name compiles. Nothing
|
|
1032
1047
|
checks the _value_ on either overload; that is deliberate, and the partial fixture above is why.
|
|
1033
1048
|
|
|
1049
|
+
**A read the constructor does cannot be seeded by any of these.** They patch an object that already
|
|
1050
|
+
exists, so the earliest they can run is after the double is built — and a component that reads
|
|
1051
|
+
`service.paymentParams.offer` in a field initializer or in its constructor has already read it by the
|
|
1052
|
+
time `TestBed.createComponent` returns:
|
|
1053
|
+
|
|
1054
|
+
```ts
|
|
1055
|
+
fixture = TestBed.createComponent(PaymentComponent); // ← TypeError thrown here, inside the component
|
|
1056
|
+
mockReadonlyProp(paymentService, 'paymentParams', params); // never reached
|
|
1057
|
+
```
|
|
1058
|
+
|
|
1059
|
+
Nothing warns, because nothing of this library runs: the throw is a plain `TypeError` from the
|
|
1060
|
+
component's own line, and the stack names the component rather than the seeding that is missing. The
|
|
1061
|
+
only place early enough is the registration:
|
|
1062
|
+
|
|
1063
|
+
```ts
|
|
1064
|
+
providers: [provideAutoSpy(PaymentService, { overrides: { paymentParams: params } })];
|
|
1065
|
+
providers: [provideAutoSpyForToken(STATE_TOKEN, { snapshot })]; // a token's second argument does the same
|
|
1066
|
+
```
|
|
1067
|
+
|
|
1068
|
+
Three migration shards found this independently, each of them after the failure had pointed at the
|
|
1069
|
+
service. A `mock*Prop` after the render is right for everything a template or a method reads later —
|
|
1070
|
+
which is most of them — and wrong only for a constructor-time read.
|
|
1071
|
+
|
|
1034
1072
|
### Properties of DOM objects — the same helpers, and the reason to look for them
|
|
1035
1073
|
|
|
1036
1074
|
`document.fullscreenElement`, `document.visibilityState`, `document.cookie`, `navigator.userAgent`,
|
|
@@ -1489,6 +1527,25 @@ worker inherits it, and what fails is some library, every other run, with nothin
|
|
|
1489
1527
|
that did it. The guard compares `globalThis` / `document` / `navigator` around every test and reports
|
|
1490
1528
|
only what appeared and cannot be removed.
|
|
1491
1529
|
|
|
1530
|
+
### Naming the file that polluted `Object.prototype`
|
|
1531
|
+
|
|
1532
|
+
```ts
|
|
1533
|
+
setupAutoSpy(); // prototypePollution: 'throw' by default — 'warn' sweeps and only reports
|
|
1534
|
+
```
|
|
1535
|
+
|
|
1536
|
+
Vitest walks a file's hooks with `for…in` in `mergeHooks`, so one own enumerable key on
|
|
1537
|
+
`Object.prototype` is spread as if it were an array during **collect**:
|
|
1538
|
+
`TypeError: Spread syntax requires ...iterable[Symbol.iterator] to be a function`, with no stack —
|
|
1539
|
+
every frame of it is filtered out by `stackIgnorePatterns`. Under `isolate: false` the key outlives
|
|
1540
|
+
its file, so **every later spec file in that worker fails to collect** while the run still reports
|
|
1541
|
+
success: `145 failed | 1613 passed` over `11880 passed | 0 failed`, zero failing tests because those
|
|
1542
|
+
files never ran. The guard compares `Object.prototype` / `Array.prototype` / `Function.prototype`
|
|
1543
|
+
around every test, takes the key back off and names the file. The write is nearly always accidental:
|
|
1544
|
+
`Object.getPrototypeOf(instance)` **is** `Object.prototype` when `instance` is an object literal from
|
|
1545
|
+
a `useValue` provider or a test double — patch the prototype of the class the object came from.
|
|
1546
|
+
`guardPrototypePollution(reaction)` from `/setup` registers the same check on its own, for a suite
|
|
1547
|
+
that does not call `setupAutoSpy()`.
|
|
1548
|
+
|
|
1492
1549
|
### Hook order differs from Jest
|
|
1493
1550
|
|
|
1494
1551
|
Vitest runs `afterEach` hooks as a stack (innermost / last-registered first); Jest ran them in
|
|
@@ -1965,13 +2022,13 @@ import { enableAngularDiagnostics } from 'vitest-auto-spy/angular';
|
|
|
1965
2022
|
enableAngularDiagnostics(); // { ngModuleScopes, deadSchemas, unspiedProviders, pendingRequests }
|
|
1966
2023
|
```
|
|
1967
2024
|
|
|
1968
|
-
| Member
|
|
1969
|
-
|
|
|
1970
|
-
| `ngModuleScopes`
|
|
1971
|
-
| `deadSchemas`
|
|
1972
|
-
| `unspiedProviders`
|
|
1973
|
-
| `pendingRequests`
|
|
1974
|
-
| `shadowedProviders` | a double on the testing module loses to the component's own `providers`
|
|
2025
|
+
| Member | Fails when |
|
|
2026
|
+
| ------------------- | -------------------------------------------------------------------------------- |
|
|
2027
|
+
| `ngModuleScopes` | a testing module imports an NgModule that contributes nothing at runtime |
|
|
2028
|
+
| `deadSchemas` | `schemas` sit next to a standalone component (`declarations` empty) — a no-op |
|
|
2029
|
+
| `unspiedProviders` | `injectSpy` got a real instance; a `console.warn` alone, a throw under the group |
|
|
2030
|
+
| `pendingRequests` | the test ended with unflushed `HttpTestingController` requests, named one by one |
|
|
2031
|
+
| `shadowedProviders` | a double on the testing module loses to the component's own `providers` |
|
|
1975
2032
|
|
|
1976
2033
|
Every member defaults to `true`, takes `false` to opt out, and a second call **replaces** the
|
|
1977
2034
|
selection (safe from anywhere, including inside a test). `disableAngularDiagnostics()` turns the
|
|
@@ -2466,43 +2523,53 @@ export default [
|
|
|
2466
2523
|
errors — `prefer-as-spy` (`TS2352`) and `no-mocked-for-spy` (`TS2322`). Spread its `rules` after a
|
|
2467
2524
|
blanket downgrade so those keep their severity; do not copy the two names into a consumer's config.
|
|
2468
2525
|
|
|
2469
|
-
| Rule | Level | Fix | Flags
|
|
2470
|
-
| --------------------------------- | ------- | ----------------- |
|
|
2471
|
-
| `no-expect-in-subscribe` | `error` | suggest | `expect()` inside `subscribe()` → `expectEmission` / `firstValueFrom`
|
|
2472
|
-
| `no-object-define-property` | `error` | suggest | `Object.defineProperty` in a spec → `mockReadonlyProp` / `mockValueProp`
|
|
2473
|
-
| `prefer-provide-auto-spy` | `error` | — | a hand-rolled `useValue` **or** `
|
|
2474
|
-
| `prefer-create-spy-from-class` | `error` | — | an object literal of 2+ `vi.fn()`s → `createSpyFromClass` (a factory's own seed is exempt)
|
|
2475
|
-
| `
|
|
2476
|
-
| `no-
|
|
2477
|
-
| `
|
|
2478
|
-
| `
|
|
2479
|
-
| `no-
|
|
2480
|
-
| `
|
|
2481
|
-
| `no-
|
|
2482
|
-
| `no-
|
|
2483
|
-
| `no-
|
|
2484
|
-
| `no-
|
|
2485
|
-
| `no-
|
|
2486
|
-
| `no-
|
|
2487
|
-
| `no-
|
|
2488
|
-
| `
|
|
2489
|
-
| `
|
|
2490
|
-
| `
|
|
2491
|
-
| `
|
|
2492
|
-
| `
|
|
2493
|
-
| `
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2526
|
+
| Rule | Level | Fix | Flags |
|
|
2527
|
+
| --------------------------------- | ------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
2528
|
+
| `no-expect-in-subscribe` | `error` | suggest | `expect()` inside `subscribe()` → `expectEmission` / `firstValueFrom` |
|
|
2529
|
+
| `no-object-define-property` | `error` | suggest | `Object.defineProperty` in a spec → `mockReadonlyProp` / `mockValueProp` |
|
|
2530
|
+
| `prefer-provide-auto-spy` | `error` | — | a hand-rolled `useValue`, `useFactory`, `useClass` or `useExisting` (also `useValue: new StubMock()`), in a provider **or** a `TestBed.overrideProvider(X, { … })` → `provideAutoSpy(Class)` / `provideAutoSpyForToken(TOKEN)`. A name in the slot is followed one step, through an initialiser or a single `beforeEach` assignment |
|
|
2531
|
+
| `prefer-create-spy-from-class` | `error` | — | an object literal of 2+ `vi.fn()`s → `createSpyFromClass` (a factory's own seed is exempt) |
|
|
2532
|
+
| `no-stub-class-double` | `warn` | — | a class whose fields are `vi.fn()`s → `createSpyFromClass` / `provideAutoSpy` and delete the stub; a decorated, `implements`-ing, `extends`-ing or unnamed class is exempt — option: `{ minRunnerFns }` |
|
|
2533
|
+
| `no-structural-double` | `warn` | — | an object of `vi.fn()`s bound to a name declared `{ load: Mock }` → `createAutoMock<T>()`; a bare `let fn: Mock` is a callback and never reported — option: `{ minRunnerFns }` |
|
|
2534
|
+
| `prefer-inject-spy` | `error` | suggest | `vi.spyOn(TestBed.inject(X), 'm')`, inline or via a `const` → `injectSpy(X).m` |
|
|
2535
|
+
| `no-shared-module-level-mock` | `error` | — | an **exported** value holding `vi.fn()`s → export a factory instead |
|
|
2536
|
+
| `no-mocked-for-spy` | `error` | `--fix` / suggest | `Mocked<T>` in any type position → `Spy<T>`, import and all — a suggestion where the assigned value is not from a factory of this library |
|
|
2537
|
+
| `prefer-as-spy` | `error` | `--fix` | `TestBed.inject(X) as Spy<X>` → `asSpy<X>(TestBed.inject(X))`, import and all |
|
|
2538
|
+
| `no-done-callback` | `error` | — | `it('x', (done) => …)` → `async` + an awaited assertion, and `done.fail(…)` at the call site |
|
|
2539
|
+
| `no-floating-assertion` | `error` | — | `expect()` in a `.then()` nobody awaits → `expect(await promise)` |
|
|
2540
|
+
| `no-bare-called-with` | `error` | — | `spy.m.calledWith(1);` as a statement — a stub nobody continued, asserting nothing; chai's `expect(fn).to.have.been.calledWith()` exempt |
|
|
2541
|
+
| `no-overridden-provider` | `error` | suggest | two providers for one token in one array, or one a `TestBed.overrideProvider` in the same hook replaces → the earlier one never runs; the exact duplicate can be deleted |
|
|
2542
|
+
| `no-inject-before-override` | `error` | — | `TestBed.inject()` / `injectSpy()` / `renderShallow()` in a hook, in a suite that still calls `override*` |
|
|
2543
|
+
| `no-private-member-access` | `error` | — | `instance['privateMember']`, `(instance as any).privateMember` (and `as unknown as`, and a decoy type), `vi.spyOn(Object.getPrototypeOf(x), 'm')` → drive the member through the public API. **Type-aware**: silent without `parserOptions.project`, and silent on an index signature |
|
|
2544
|
+
| `no-dead-schemas` | `error` | — | `schemas` on a testing module with no `declarations` — the schema applies to nothing; the file decides, so a `declarations` in another `configureTestingModule` call silences it |
|
|
2545
|
+
| `no-import-time-spread` | `error` | suggest | `export const x = [...Imported]` at module scope → a `TypeError` while the bundle loads |
|
|
2546
|
+
| `no-unregistered-inject-spy` | `error` | — | `injectSpy(X)` for a token this file never registered → the real instance, whose spy helpers exist only for the compiler |
|
|
2547
|
+
| `prefer-render-shallow` | `warn` | suggest | `TestBed.createComponent` in a file that never reads the template → `renderShallow(X)`; 0.24× the per-test cycle at 100 children |
|
|
2548
|
+
| `prefer-observer-stub` | `error` | — | a hand-rolled observer global → `stubIntersectionObserver()` / `stubResizeObserver()` / `stubMutationObserver()`; the manual save-and-restore goes too, `restoreMockedProps()` runs the undo |
|
|
2549
|
+
| `jasmine-namespace-without-entry` | `error` | — | `.and` / `.calls` / `.withArgs` on a library spy in a file that installs the compat layer nowhere — option: `{ setupModules: […] }` |
|
|
2550
|
+
| `no-jasmine-globals` | `error` | — | `jasmine.*`, bare `spyOn(` / `spyOnProperty(` / `spyOnAllFunctions(` / `fail(` / `pending(`, `.withContext(` |
|
|
2551
|
+
| `no-save-arguments-by-value` | `error` | — | `spy.calls.saveArgumentsByValue()` — a no-op here, so the spec silently asserts on post-mutation state |
|
|
2552
|
+
| `prefer-native-spy-api` | `error` | `--fix` / suggest | `.and` / `.calls` where the spy's own API says the same thing — turn it on for the last mile off the jasmine shim |
|
|
2553
|
+
|
|
2554
|
+
Twenty-five rules, **every one an `error` since 4.0.0 except `prefer-render-shallow`,
|
|
2555
|
+
`no-stub-class-double` and `no-structural-double`**; three fix on their own, eight offer suggestions. Twenty-four are syntactic; `no-private-member-access` is the one
|
|
2497
2556
|
that reads types, and it reports nothing at all without `parserOptions.project` / `projectService`
|
|
2498
2557
|
rather than guessing. The config used to be a graded mix of `error` / `warn` / `off`, which decided for the
|
|
2499
|
-
consumer how much each finding mattered — a `warn` nothing reads is `off` with extra output. The
|
|
2500
|
-
`warn` left
|
|
2501
|
-
|
|
2502
|
-
could render more cheaply, and `renderShallow` is a migration a suite either takes or does
|
|
2503
|
-
`error` the plugin would gate that migration — 491 findings across 398 of one consumer's
|
|
2504
|
-
files — so `recommended` would exist to be overridden.
|
|
2505
|
-
|
|
2558
|
+
consumer how much each finding mattered — a `warn` nothing reads is `off` with extra output. The
|
|
2559
|
+
three `warn`s left are not judgements about how much a finding matters. `prefer-render-shallow` is
|
|
2560
|
+
about the _kind_ of finding: every other rule names something wrong or dead, while this one names a
|
|
2561
|
+
file that could render more cheaply, and `renderShallow` is a migration a suite either takes or does
|
|
2562
|
+
not. At `error` the plugin would gate that migration — 491 findings across 398 of one consumer's
|
|
2563
|
+
1759 spec files — so `recommended` would exist to be overridden. `no-stub-class-double` and
|
|
2564
|
+
`no-structural-double` (5.5.0) are about the _evidence_: both report the same drift
|
|
2565
|
+
`prefer-create-spy-from-class` reports at `error`, but neither has a `provide:` beside it to settle
|
|
2566
|
+
the question, so each decides on a heuristic — and a project that disagrees with the reading has to
|
|
2567
|
+
be able to switch it off without losing the rule that reads a count. The counts are not the argument
|
|
2568
|
+
and moved a long way inside the release: measured on the same 1759 files, the two started at 12
|
|
2569
|
+
reports in 8 files and 115 in 74, and are 10 in 7 and 5 in 4 once `prefer-provide-auto-spy` learnt to
|
|
2570
|
+
follow a name into a `useValue` — 112 of those doubles are handed to Angular DI one name away, where
|
|
2571
|
+
a `provide:` settles it. That rule reports **154 times across 87 files** on the same suite, all at
|
|
2572
|
+
`error`. Set any of the three `warn`s to `'error'` once the batch is done. Three of
|
|
2506
2573
|
them can report on a _correct_ project, and only one has an option:
|
|
2507
2574
|
`jasmine-namespace-without-entry` takes `['error', { setupModules: ['./test-setup'] }]`, naming the
|
|
2508
2575
|
file where `enableJasmineCompat()` is called; `prefer-native-spy-api` goes `'off'` for as long as a
|
|
@@ -2625,98 +2692,101 @@ packages, which a subpath export can never be.
|
|
|
2625
2692
|
|
|
2626
2693
|
## 17. Error → fix
|
|
2627
2694
|
|
|
2628
|
-
| Message contains
|
|
2629
|
-
|
|
|
2630
|
-
| `No mock adapter registered`
|
|
2631
|
-
| `Observable spies require rxjs`
|
|
2632
|
-
| `Type 'SubjectLike<T>' is not assignable to type 'Subject<T>'`
|
|
2633
|
-
| `Cannot read properties of undefined (reading 'returnValue')` on `spy.m.and.…`
|
|
2634
|
-
| `spy.withArgs is not a function`
|
|
2635
|
-
| `jasmine is not defined`
|
|
2636
|
-
| `done.fail is not a function`
|
|
2637
|
-
| a `.withContext('…')` message that never appears in the failure output
|
|
2638
|
-
| `names method(s) that are not on the class prototype`
|
|
2639
|
-
| `All declarations of 'Matchers' must have identical type parameters`
|
|
2640
|
-
| `toHaveBeenCalledTimes` reads `0` for a call an earlier test made, after moving to Vitest 5
|
|
2641
|
-
| `was configured with 'mustBeCalledWith'`
|
|
2642
|
-
| `extendWithAutoSpies needs Vitest 4.1 or newer`
|
|
2643
|
-
| `advanceTimers() requires fake timers`
|
|
2644
|
-
| `Nothing configured X.method, and strict mode is on`
|
|
2645
|
-
| `Cannot redefine property: …` from a library accessor spy
|
|
2646
|
-
| `Cannot spy on this instance in place: it is not extensible`
|
|
2647
|
-
| `Cannot mock the property 'X': it is not configurable`
|
|
2648
|
-
| `overrideComponentProvider(…): the override did not apply`
|
|
2649
|
-
| `the test ended with N unflushed HttpTestingController request(s)`
|
|
2650
|
-
| `NgModule(s) with an empty runtime scope: …`
|
|
2651
|
-
| `Cannot read properties of undefined
|
|
2652
|
-
| `
|
|
2653
|
-
| `
|
|
2654
|
-
| `
|
|
2655
|
-
| `
|
|
2656
|
-
| `
|
|
2657
|
-
| `
|
|
2658
|
-
| `
|
|
2659
|
-
|
|
|
2660
|
-
| `
|
|
2661
|
-
|
|
|
2662
|
-
|
|
|
2663
|
-
| `
|
|
2664
|
-
|
|
|
2665
|
-
| `
|
|
2666
|
-
|
|
|
2667
|
-
| `
|
|
2668
|
-
| `
|
|
2669
|
-
| `
|
|
2670
|
-
|
|
|
2671
|
-
|
|
|
2672
|
-
|
|
|
2673
|
-
|
|
|
2674
|
-
| `
|
|
2675
|
-
|
|
|
2676
|
-
| `
|
|
2677
|
-
| `
|
|
2678
|
-
| `
|
|
2679
|
-
| `
|
|
2680
|
-
| `is missing
|
|
2681
|
-
| `
|
|
2682
|
-
| `
|
|
2683
|
-
| `
|
|
2684
|
-
|
|
|
2685
|
-
|
|
|
2686
|
-
| `
|
|
2687
|
-
| `
|
|
2688
|
-
| `
|
|
2689
|
-
|
|
|
2690
|
-
|
|
|
2691
|
-
|
|
|
2692
|
-
| a
|
|
2693
|
-
| a
|
|
2694
|
-
|
|
|
2695
|
-
|
|
|
2696
|
-
| `
|
|
2697
|
-
| `
|
|
2698
|
-
| `
|
|
2699
|
-
| `
|
|
2700
|
-
| `
|
|
2701
|
-
| `
|
|
2702
|
-
| `TS2540
|
|
2703
|
-
| `
|
|
2704
|
-
| `
|
|
2705
|
-
|
|
|
2706
|
-
| `
|
|
2707
|
-
|
|
|
2708
|
-
| a
|
|
2709
|
-
|
|
|
2710
|
-
|
|
|
2711
|
-
|
|
|
2712
|
-
|
|
|
2713
|
-
|
|
|
2714
|
-
| `
|
|
2715
|
-
| `createNestUnit(X)
|
|
2716
|
-
| `createNestUnit(X)
|
|
2717
|
-
| `
|
|
2718
|
-
| `
|
|
2719
|
-
| `
|
|
2695
|
+
| Message contains | Cause | Fix |
|
|
2696
|
+
| ------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
2697
|
+
| `No mock adapter registered` | no runtime entry was imported, or the wrong one | import `vitest-auto-spy` (Vitest) / `…/bun` / `…/node` once before creating spies |
|
|
2698
|
+
| `Observable spies require rxjs` | the rxjs layer was never loaded | `import 'vitest-auto-spy/rxjs';` once, in the setup file |
|
|
2699
|
+
| `Type 'SubjectLike<T>' is not assignable to type 'Subject<T>'` | 4.0.0: `returnSubject()` is rxjs-typed only where `vitest-auto-spy/rxjs` is in the TypeScript program, and it is not in this one | put `import 'vitest-auto-spy/rxjs';` in a file the spec `tsconfig` includes — a `setupFiles` entry outside `include` is the usual cause |
|
|
2700
|
+
| `Cannot read properties of undefined (reading 'returnValue')` on `spy.m.and.…` | the jasmine namespaces are not installed — the spy was built before them, or nothing installed them at all | import from `vitest-auto-spy/jasmine`; on Bun / `node:test`, `enableJasmineCompat()` in the setup file (§20) |
|
|
2701
|
+
| `spy.withArgs is not a function` | the same, seen from the argument-matching side | the same — or write `spy.m.calledWith(a).mockReturnValue(v)`, which needs no layer (§20) |
|
|
2702
|
+
| `jasmine is not defined` | jasmine's global is the runner's, and Vitest declares none | `import { jasmine } from 'vitest-auto-spy/jasmine'`, then `codemod --from jasmine` to rewrite the members (§20) |
|
|
2703
|
+
| `done.fail is not a function` | Vitest passes a `TestContext`, not jasmine's `done`; the line usually sits in an `error` callback nobody awaits, so the run stays **green** | assert on the failure — `await expect(firstValueFrom(src$)).rejects.toMatchObject({ … })`, or `expect.fail(message)` |
|
|
2704
|
+
| a `.withContext('…')` message that never appears in the failure output | Vitest's chai layer has an `@internal` `withContext(flags)`; handed a string it walks the character indices, sets nonsense flags and returns `this` | `expect(actual, 'message').toBe(expected)` — the second argument of `expect` is the label. Nothing throws, so nothing warns (§20) |
|
|
2705
|
+
| `names method(s) that are not on the class prototype` | typo, or an instance-field callable | fix the name, or move it to `instanceMethodsToSpyOn` |
|
|
2706
|
+
| `All declarations of 'Matchers' must have identical type parameters` | a custom matcher declares `interface Matchers<T = any>` (the Vitest 4 shape) while Vitest 5 declares `Matchers<R, T>` | declare it on `Chai.Assertion` instead — that interface has no type parameters in either major, so one declaration merges on both (§10) |
|
|
2707
|
+
| `toHaveBeenCalledTimes` reads `0` for a call an earlier test made, after moving to Vitest 5 | `clearMocks` defaults to `true` on Vitest 5, so `vi.clearAllMocks()` runs before every test | count the calls in a plain variable instead of reading the spy, or set `clearMocks: false` (§10) |
|
|
2708
|
+
| `was configured with 'mustBeCalledWith'` | the code called the spy with other arguments | that is the assertion firing — fix the code, or relax to `calledWith` |
|
|
2709
|
+
| `extendWithAutoSpies needs Vitest 4.1 or newer` | the `test` handed in has only the object-form `extend` (Vitest ≤ 4.0); the builder form the helper is written against arrived in 4.1 | upgrade Vitest, or keep `provideAutoSpy` + `injectSpy` in a `beforeEach` until then |
|
|
2710
|
+
| `advanceTimers() requires fake timers` | no fake timers installed | `setupFakeTimers()` or `vi.useFakeTimers()` first |
|
|
2711
|
+
| `Nothing configured X.method, and strict mode is on` | a strict double was asked for a method no line configured | configure it (`mockReturnValue` / `resolveWith` / `nextWith` / `calledWith`), or `{ strict: false }` on that double (§5) |
|
|
2712
|
+
| `Cannot redefine property: …` from a library accessor spy | the target is an ES module namespace a bundler inlined | no spy library can win this — give the code a real seam (inject it, pass it in) and spy on that |
|
|
2713
|
+
| `Cannot spy on this instance in place: it is not extensible` | `createSpyFromInstance` was handed a frozen or sealed object | spy it before it is frozen, or build a separate double with `createSpyFromClass` (§2) |
|
|
2714
|
+
| `Cannot mock the property 'X': it is not configurable` | the member was defined with `configurable: false`, so it cannot be redefined | members replaced before it are still restorable — `restoreSpiedInstance(instance)` or `restoreMockedProps()` |
|
|
2715
|
+
| `overrideComponentProvider(…): the override did not apply` | the component injects a different token, or a later `overrideProvider` won | pass the token the component actually injects (a base class, an `InjectionToken`), and override after nothing else re-configures |
|
|
2716
|
+
| `the test ended with N unflushed HttpTestingController request(s)` | `enableAngularDiagnostics({ pendingRequests })` — nothing answered them | flush each (`controller.expectOne(url).flush(body)`), or `controller.verify()` where absence is the assertion (§13) |
|
|
2717
|
+
| `NgModule(s) with an empty runtime scope: …` | `ngModuleScopes` (or `assertNgModuleScopes`) — an AOT test bundle stripped `ɵɵsetNgModuleScope`, so the import contributes nothing | declare what the spec needs in the TestBed module directly; pass only modules expected to bring declarations (§13) |
|
|
2718
|
+
| `Cannot read properties of undefined`, stack inside the component's own constructor or a field initializer | a member the double must **hold** rather than spy on is read while the component is being constructed, and the `mockReadonlyProp` that seeds it is written _below_ `TestBed.createComponent` — so it has not run yet, and never will | seed it **before** construction: `provideAutoSpy(X, { overrides: { paymentParams: … } })`, or `provideAutoSpyForToken(TOKEN, { … })`. No later call can repair this — the throw happens inside `createComponent`, so the helper is not reached and cannot say so; the stack names the component (§9, §13) |
|
|
2719
|
+
| `arr.map(asInstance)` infers `unknown[]` | `asInstance` is overloaded, and passing it **by reference** resolves against the `DeepMockProxy<T>` overload, from which `T` cannot be inferred | `arr.map((spy) => asInstance(spy))` — the arrow gives each call its own inference. For a fixed set, `asInstances(a, b, c)` keeps the tuple types (§6) |
|
|
2720
|
+
| `Cannot read properties of undefined (reading 'provide')`, stack inside `render3/di_setup` | a barrel chunk had not run when the component's definition was built, so a provider slot is `undefined` | `assertComponentDefIntact(Cmp)` before `createComponent` — it names the list and the index (§13) |
|
|
2721
|
+
| `assertComponentDefIntact(): argument N is undefined, which carries no ɵcmp or ɵdir` | the class reference itself never arrived — the `Cannot read properties of undefined (reading 'ɵcmp')` case | the same split barrel; import the component from its own module, not the barrel (§13) |
|
|
2722
|
+
| `TS1117: An object literal cannot have multiple properties with the same name`, in a fixture | a hundred-line model literal copied into eight specs and edited independently | one `createFixtureFactory<T>(defaults)`; note the runtime keeps the **second** key, so do not auto-fix by dropping one (§12) |
|
|
2723
|
+
| `configureTestingModule was given N schema(s) that can never apply` | `enableAngularDiagnostics({ deadSchemas })` — `schemas` next to a standalone component, with `declarations` empty | drop the `schemas` entry and put the missing directive/pipe in the component's own `imports`, or use `createDirectiveHost` (§13) |
|
|
2724
|
+
| `injectSpy(X): the injector returned a plain instance, not an auto-spy` | the token is provided for real; a `console.warn` on its own, a **throw** under `enableAngularDiagnostics({ unspiedProviders })` | `provideAutoSpy(X)` / `provideAutoSpyForToken(TOKEN)`, or `TestBed.inject(X)` if the real thing is what the spec wants |
|
|
2725
|
+
| `trackInjections(...).get(X): that token is not tracked by this log` | `get` only answers for tokens whose providers the log created | add the token to the `trackInjections([...])` list, or read it from the injector directly (§13) |
|
|
2726
|
+
| `Spread syntax requires ...iterable[Symbol.iterator] to be a function`, at load time | a module-scope spread of an imported binding, inside a bundle | build the array in a function or a getter — `no-import-time-spread` (§16) |
|
|
2727
|
+
| `the timers APIs are not mocked` in a nested `describe`'s `beforeAll` | fakes armed in `beforeEach` only; Jest armed them for the whole file | `setupFakeTimers(cfg, { betweenTests: true })` / `setupAutoSpy({ globalFakeTimers: true })` |
|
|
2728
|
+
| setup-file hooks reaching only the first spec file of a worker | the setup module stayed cached (Angular unit-test builder + coverage) | run coverage with `--isolate`, or call `setupAutoSpy()` from a per-file module |
|
|
2729
|
+
| `no DOM could be installed` | `bun-angular` preload with no DOM package | `bun add -d @happy-dom/global-registrator` (or `jsdom`) |
|
|
2730
|
+
| `cannot read "…" referenced by …` | a `templateUrl` / `styleUrls` path does not resolve | fix the path, relative to the component file |
|
|
2731
|
+
| duplicate-copy report from `setupAutoSpy()` | two installs, or one loaded as both ESM and CJS | dedupe the dependency; `setupAutoSpy({ duplicateCopies: 'warn' })` to downgrade |
|
|
2732
|
+
| `Type 'Spy<T>' is not assignable to type 'T'` | `Spy<T>` drops private members — by design | declare as `Spy<T>`, or use `asInstance()` / `asSpy()` (§6) |
|
|
2733
|
+
| a spy is never called, no warning | the method is an instance field, not on the prototype | `instanceMethodsToSpyOn`, or `createAutoMock<T>()` |
|
|
2734
|
+
| `Cannot access '__vi_import_N__' before initialization` | `vi.mock()` on `@angular/core` or a relative path | you cannot mock it — the specs are bundled. Assert the result instead |
|
|
2735
|
+
| `AggregateError at Object.dispatchError`, for a request nothing asserts on | jsdom really served an `XMLHttpRequest` — `blockNetwork` used to cover only `fetch` | `setupAutoSpy({ blockNetwork: true })`, or `{ xhr: 'empty' }` for tracker pings (§10) |
|
|
2736
|
+
| `localStorage.setItem is not a function`, or `localStorage` undefined | Node's own Web Storage made Vitest's global filter skip the environment's — Node 25 and up, jsdom and happy-dom alike | on by default in `setupAutoSpy()`; `restoreWebStorage()` on its own (§10) |
|
|
2737
|
+
| `Schedulers cannot synchronously execute watches while scheduling` | a timer from a **previous** file, under `isolate: false` | track and cancel pending timers/frames in the setup file (§10) |
|
|
2738
|
+
| `signal read during notification phase` | same — a stray `requestAnimationFrame` callback | same |
|
|
2739
|
+
| an assertion error printed to stderr, every test green and the run exiting 0 | zone.js swallowed a rejection nobody handled | `setupAutoSpy({ strayRejections: true })` fails the test it surfaced in (§10) |
|
|
2740
|
+
| an `expect()` inside a `.then()` that never seems to run | nothing awaits the chain, so the test ended first | `await` the promise and assert the settled value — `no-floating-assertion` (§16) |
|
|
2741
|
+
| `trackStrayRejections() found no zone.js on the host` | `strayRejections` turned on where zone.js is not loaded | `import 'zone.js';` in the setup file, or drop the option |
|
|
2742
|
+
| `… .destroy is not a function` | an ngrx `rxMethod` replaced with a bare mock | `Object.assign(vi.fn(), { destroy: vi.fn() })` |
|
|
2743
|
+
| `NullInjectorError` for a service you did provide | it is a component-level provider, not a module one | `asSpy(fixture.debugElement.injector.get(X))`, not `injectSpy(X)` |
|
|
2744
|
+
| `runEffect(): … not an EffectRef returned by effect()` | passed the callback, a signal, or an unassigned field | pass what `effect()` returned; a field may need its lifecycle hook to run first |
|
|
2745
|
+
| `X is not a constructor`, stack in production code | a `vi.fn(() => …)` where the code does `new X()` | `mockConstructor` / `stubConstructor` / `createSpyClass` (§12) |
|
|
2746
|
+
| `Date is not a constructor` | `vi.spyOn(globalThis, 'Date')` — the fakes own it | `mockSystemTime(date)` / `vi.setSystemTime` |
|
|
2747
|
+
| `TS2352: … 'accessorSpies' is missing in type 'X'` | `TestBed.inject(X) as Spy<X>` | `asSpy(TestBed.inject(X))` — never a double assertion (§6) |
|
|
2748
|
+
| `TS2739` / `TS2740` / `TS2345` with `Spy<X>` on the left | a spy handed to an API typed against the class | `asInstance(spy)` (§6) |
|
|
2749
|
+
| `is missing the following properties: _private, …` | declared as Vitest's `Mocked<T>` | declare `Spy<T>` (§6) |
|
|
2750
|
+
| `AddPromiseSpyMethods<unknown>` vs `WithMockReturnValue<…>` | a generic class inferred as `Service<any>` | `asSpy<Service>(…)` / `injectSpy<Service>(…)` (§6) |
|
|
2751
|
+
| `'addEventListener' called on an object that is not a valid instance of EventTarget` | Node's `AbortSignal` under jsdom + zone.js | `stubAbortController()` (§12) |
|
|
2752
|
+
| `vi.requireMock is not a function` | a mechanical `jest.` → `vi.` rename | there is no equivalent — provide the double through the TestBed instead |
|
|
2753
|
+
| a `vi.mock()` factory that never applies, only sometimes | under `isolate: false` the module was already in the worker's graph | do not mock it; inject the dependency, or `vi.hoisted()` + a real seam |
|
|
2754
|
+
| a `vi.mock()` of a workspace alias that never applies at all | a bundler inlined the module before the mock could be installed | `assertMocked(ns, { specifier })` to prove it, then inject instead of mocking |
|
|
2755
|
+
| `No "default" export is defined on the mock`, thrown inside a dependency | a factory returning bare named exports; the dep probes `default` | `vi.mock('x', () => moduleNamespace({ … }))` |
|
|
2756
|
+
| `Not implemented: HTMLMediaElement.play`, or `duration` is `NaN` and cannot be set | jsdom implements the media elements as a shell | `stubMediaElement({ duration })`, then `media.set(el, …)` to fire the events |
|
|
2757
|
+
| `Cannot set base providers because it has already been called` | zone and zoneless spec files sharing one worker | `setupAngularTestEnv({ zoneless, initZone, initZoneless })` (§13) |
|
|
2758
|
+
| a stub that works in the first test of the file and in no other | installed at `describe` level or in `beforeAll`, then restored away | install it in `beforeEach`, or `installPerTest(() => stub…())` |
|
|
2759
|
+
| a third-party library failing every other run, no test named | a test sealed a global with `Object.defineProperty` (non-configurable) | `setupAutoSpy({ guardGlobals: 'throw' })` names the file; then `mockValueProp` |
|
|
2760
|
+
| a block of files reported as failed suites with no stack, and zero failing tests | a test left an own enumerable key on `Object.prototype`; `mergeHooks` spreads it and collection dies | `setupAutoSpy()` guards it by default; `prototypePollution` tunes the reaction |
|
|
2761
|
+
| `expected [ { at: 1, …(5) }, …(8) ] to deeply equal [ { …(6) }, … ]` | one field moved in every element — usually a frozen clock or an id | `expect(diffByField(actual, expected)).toBeUndefined()` |
|
|
2762
|
+
| a hand-tuned number of turns waiting for a `resource()` to load | a resource needs a change-detection **tick**, not event-loop turns; `flushEventLoopUntil` never ticks and the resource never even issues its request | `flushEffects()`, flush the request, then `await settleResource(r, { label })` |
|
|
2763
|
+
| a `resource()` assertion that passes but reads the **default** value | the spec asserted before the resource left `loading` | `await settleResource(r, { label })` — it fails loudly instead |
|
|
2764
|
+
| a spec dying on the runner's 5 s file timeout right after `await stable(fixture)` | the fixture never stabilised — an unflushed request, a real `setInterval` | `stable` now fails at 2000 ms naming the cause; raise `{ timeout }` only once neither is true |
|
|
2765
|
+
| `flushEventLoopUntil` timing out on the **first** such test only, the rest green | a cold dynamic `import()` outran the turn budget; later tests hit the module cache | `await settleDynamicImport(() => import('…'))` — await the module, do not count turns |
|
|
2766
|
+
| `Expected to be running in 'ProxyZone', but it was not found` | `zone.js/testing` patches jasmine/mocha/jest, not Vitest | `import 'vitest-auto-spy/zone'` after zone.js, with `globals: true` (§14) |
|
|
2767
|
+
| `nextWith` demanding `HttpEvent<T>` on a generated API client | `Parameters`/`ReturnType` read the **last** overload | `asSpy<Client, { overload: 'first' }>(…)`, or `Overload<M, 0>` |
|
|
2768
|
+
| `NG0303` / `NG0304` / nothing at all, from a directive spec | the host is `standalone: false`, or the module is in the TestBed | `createDirectiveHost({ template, scope: [Module] })` (§13) |
|
|
2769
|
+
| `TS2540: Cannot assign to 'X' because it is a read-only property` | a `readonly` field of an object under test | `mockValueProp(obj, 'X', value)` — on a class **getter**, `mockReadonlyProp` |
|
|
2770
|
+
| `TypeError: Cannot read properties of undefined (reading 'mockReturnValue')` | the member is an **instance field**, not on the prototype — `Router.currentNavigation` since Angular 20 | `provideAutoSpy(Router, { instanceMethodsToSpyOn: ['currentNavigation'] })` (§5) |
|
|
2771
|
+
| `throwWith` reaching the success branch first, with the previous test's value | the spy's `ReplaySubject(1)` outlived the test that filled it | upgrade; and `resetAutoSpy(spy)` in `beforeEach` when the TestBed is built in `beforeAll` |
|
|
2772
|
+
| `TS2540` on a `Spy<T>` / `createAutoMock` member, which the runtime writes fine | `Spy<T>` is homomorphic and keeps the `readonly` of the source member — deliberately: on a member replaced by a **spied accessor** the assignment reaches the setter spy and the getter still answers `undefined`, so the type error is the loud version of a silent no-op | `mockValueProp(spy, 'X', value)` — it defines rather than assigns, so it works in both cases; `Mutable<Spy<T>>` is the opt-in for plain data members, and `Reflect.set` is **not** a way round it |
|
|
2773
|
+
| `TS2345` from `mockReturnValue` / `mockImplementation` / `mockResolvedValue` on a double that used to compile | the mock surface is `MockInstance<Method>`, so the stub is now checked against the method's own return type | stub with what the method returns; if the double is meant to answer something else, the method's type or the spec's expectation is wrong |
|
|
2774
|
+
| `delete mock.optionalMethod` leaving the member present and truthy | the Proxy had no `deleteProperty` trap before 3.5.0 | upgrade; before that, `mock.optionalMethod = undefined` |
|
|
2775
|
+
| half a double's methods reaching the real implementation after `Object.assign` | `ownKeys` on a type-driven Proxy lists only the keys already read | `createSpyFromClass(X)` — a real object, with enumerable method keys |
|
|
2776
|
+
| `let s: MockInstance<() => unknown>` not matching anything | `MockInstance<F>` is invariant in `F`; Jest's `SpyInstance` was not | `MockInstance<T['method']>`, or better `injectSpy(X).method` |
|
|
2777
|
+
| two runs with the same totals, one of them missing a suite | a lost `describe` and a fixed flake cancel out in the counters | `compareTestRuns(before, after)` — compare the set of names, not the numbers |
|
|
2778
|
+
| a 30 s timeout, in a different file each run | module-level `vi.fn()` in a fixture shared by files | make the fixture a factory (§10) |
|
|
2779
|
+
| a component's `afterNextRender` state is empty | `detectChanges()` does not run the after-render phase | `await stable(fixture)` (§11) |
|
|
2780
|
+
| a green test whose only line about a call is `spy.m.calledWith(1);` | that is a **stub**, not an assertion — chai's `expect(fn).to.have.been.calledWith(x)` is the one that checks | continue the chain, or `expect(spy.m).toHaveBeenCalledWith(1)` — `no-bare-called-with` (§16) |
|
|
2781
|
+
| `--detect-async-leaks` reporting no leaks in a suite that visibly leaks timers | `setupAutoSpy({ strayTimers: true })` cancelled them before Vitest collected | re-run that file with `strayTimers` off; the warning on stderr says how many were taken (§10) |
|
|
2782
|
+
| `createNestUnit(X): parameter #n of Y is typed as \`Object\``(or`undefined — usually a circular import`) | the compiler emitted no runtime class for that parameter — interface, union, primitive, or a circular import | `@Inject(TOKEN)` plus a `providers` entry, or `@Optional()` to receive `undefined`; `@Inject(forwardRef(() => X))` for the import cycle |
|
|
2783
|
+
| `createNestUnit(X): Y declares n constructor parameter(s) but carries no design:paramtypes metadata` | no `emitDecoratorMetadata` (esbuild / Vite), or `reflect-metadata` loaded after the class | tsc or SWC with `decoratorMetadata`, `@Injectable()`, `reflect-metadata` first; or `@Inject(X)` on every parameter |
|
|
2784
|
+
| `createNestUnit(X): A -> B -> A is a cycle among the classes built for real` | two exposed / `useClass` classes depend on each other; the helper does not resolve `forwardRef` cycles | expose one side less, or provide it |
|
|
2785
|
+
| `createNestUnit(X).spies.get(Y): the unit never asked for that token` | same guard as `createWithAutoSpies` — the spy would not be the one the unit uses | stub the token the unit actually injects (the message lists the auto-spied ones) |
|
|
2786
|
+
| `createNestUnit(X).spies.get(Y): Y is in \`expose\`, so the unit got a real instance` | an exposed class is real, not a spy | read the spies of its own collaborators, or drop it from `expose` |
|
|
2787
|
+
| `no request matched …` (with the requests that were made listed) | the URL, verb or predicate does not describe anything the code under test sent, or nothing subscribed | read the list in the message — it is the requests that were actually made; then fix the URL, add `{ method }`, or subscribe (§13) |
|
|
2788
|
+
| `this TestBed has no HttpTestingController` | `expectRequest` / `expectNoRequest` on a module that never got the testing backend | `TestBed.configureTestingModule({ providers: [...provideHttpTesting()] })` from `vitest-auto-spy/angular-http` (§13) |
|
|
2789
|
+
| `the test ended with N unanswered request(s)` | `provideHttpTesting({ verifyOnTeardown })` found a request the spec never flushed | answer it (`await expectRequest(url).flush(body)`), assert its absence (`expectNoRequest(url)`), or `{ verifyOnTeardown: false }` (§13) |
|
|
2720
2790
|
|
|
2721
2791
|
**Seven of these are library defects, not spec ones.** On anything below 3.8.0, upgrade and change
|
|
2722
2792
|
nothing in the spec: `of(double)` never emitting; `accessorSpies.setters.X` still `undefined` after
|
|
@@ -2872,6 +2942,17 @@ re-exporting a whole directory). When `environment` + `setup` + `prepare` togeth
|
|
|
2872
2942
|
of that trade rather than restating them — read that page before recommending the flag, since it
|
|
2873
2943
|
raises peak memory.
|
|
2874
2944
|
|
|
2945
|
+
Two more findings are about settings rather than files. `perf-environment-engine` fires when
|
|
2946
|
+
`environment` dominates and a `vite(st).config.*` names `jsdom` while nothing in those configs
|
|
2947
|
+
mentions `happy-dom`: measured on this package's own 117-file Angular suite, `happy-dom` is 23.2 s of
|
|
2948
|
+
user CPU against jsdom's 26.5 s, and on a spec that builds a DOM and does nothing else the gap is
|
|
2949
|
+
253 ms against 119 ms per file. It is a swap, not a flag — `happy-dom` implements less of the
|
|
2950
|
+
platform — so take one project at a time. `perf-workers` fires on a run over a minute of summed CPU
|
|
2951
|
+
that declares no `maxWorkers`, and it is the one finding here about **memory**: one worker per core
|
|
2952
|
+
is the default, resident memory measured at 1.42 GB plus ~155 MB per worker, and a cap of four costs
|
|
2953
|
+
about 2.8 % of wall clock. Do not quote a worker count as universally right — it is a property of
|
|
2954
|
+
the machine.
|
|
2955
|
+
|
|
2875
2956
|
`--json <path>` re-analyses a report an earlier `--out <path>` run wrote, instead of running Vitest
|
|
2876
2957
|
again. Full reference: <https://asdalexey.github.io/vitest-auto-spy/utilities/cli>.
|
|
2877
2958
|
|
|
@@ -2896,7 +2977,7 @@ migrated by hand. Run it after `--write`, and again after any manual clean-up. `
|
|
|
2896
2977
|
select transforms by id, `--list` prints them. Full reference:
|
|
2897
2978
|
<https://asdalexey.github.io/vitest-auto-spy/utilities/codemod>.
|
|
2898
2979
|
|
|
2899
|
-
Past 50 000 files the repository scan truncates and the run says so —
|
|
2980
|
+
Past 50 000 files the repository scan truncates and the run says so — _Nothing left to migrate_ off a
|
|
2900
2981
|
truncated list is a claim about a tree the tool never looked at. `VITEST_AUTO_SPY_SCAN_CAP` raises
|
|
2901
2982
|
the cap.
|
|
2902
2983
|
|