vitest-auto-spy 4.5.0 → 4.5.1

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/dist/angular.js CHANGED
@@ -2526,7 +2526,10 @@ function renderShallow(component, options = {}) {
2526
2526
  imports: standalone ? [component, ...options.imports ?? []] : options.imports ?? [],
2527
2527
  declarations: standalone ? [] : [component],
2528
2528
  providers: options.providers ?? [],
2529
- schemas: [NO_ERRORS_SCHEMA]
2529
+ // Only where it can do something. A standalone component carries its own dependency scope, so a
2530
+ // module-level schema never reaches its template — and `enableAngularDiagnostics({ deadSchemas })`
2531
+ // is right to report one, which made these two features of the same package cancel each other out.
2532
+ ...standalone ? {} : { schemas: [NO_ERRORS_SCHEMA] }
2530
2533
  });
2531
2534
  TestBed.overrideComponent(component, { set: buildOverride(component, options) });
2532
2535
  options.beforeCreate?.();
@@ -314,7 +314,10 @@ function renderShallow(component, options = {}) {
314
314
  imports: standalone ? [component, ...options.imports ?? []] : options.imports ?? [],
315
315
  declarations: standalone ? [] : [component],
316
316
  providers: options.providers ?? [],
317
- schemas: [NO_ERRORS_SCHEMA]
317
+ // Only where it can do something. A standalone component carries its own dependency scope, so a
318
+ // module-level schema never reaches its template — and `enableAngularDiagnostics({ deadSchemas })`
319
+ // is right to report one, which made these two features of the same package cancel each other out.
320
+ ...standalone ? {} : { schemas: [NO_ERRORS_SCHEMA] }
318
321
  });
319
322
  TestBed.overrideComponent(component, { set: buildOverride(component, options) });
320
323
  options.beforeCreate?.();
package/dist/cli.js CHANGED
@@ -2356,7 +2356,7 @@ function checkForeignPragma(graph) {
2356
2356
  }
2357
2357
 
2358
2358
  // src/cli/checks/export-map.generated.ts
2359
- var EXPORT_MAP_VERSION = "4.4.0";
2359
+ var EXPORT_MAP_VERSION = "4.5.0";
2360
2360
  var ENTRY_SPECIFIERS = "vitest-auto-spy vitest-auto-spy/bun vitest-auto-spy/bun-angular vitest-auto-spy/node 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-http 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";
2361
2361
  var EXPORTED_BY = {
2362
2362
  AccessorImplementations: "0 1 2 3 11 14 15 16",
@@ -336,6 +336,13 @@ var TEMPLATE_READS = [
336
336
  function templatePolicy(context) {
337
337
  return Reflect.get(Object(context.options[0]), "templates") === "never" ? "never" : "as-needed";
338
338
  }
339
+ var RENDER_MESSAGES = {
340
+ keepTemplate: '`keepTemplate: true` puts the real template back, and this project set `{ templates: "never" }`. Drop it \u2014 or, when the component genuinely reads its own template through `viewChild` or content projection, silence this line, because the alternative is a spec that cannot reach the component at all.',
341
+ preferRenderShallow: "`TestBed.createComponent` pays for compiling the template and instantiating the whole child subtree, and nothing in this file reads either \u2014 no `nativeElement`, no `debugElement`, no `By.css`, no `querySelector`. `renderShallow(X)` brings the same component up through the same `TestBed` with the children dropped and the template blank, and leaves inputs, signals, lifecycle hooks and DI exactly where they were; `fixture` is still a real `ComponentFixture`. What it buys is measured in `bench-angular/`: **0.24\xD7** the per-test cycle at 100 children and **0.05\xD7** at 400 \u2014 but at **zero** children the two are level (measurements straddle 1.0, and it is the noisiest row in the benchmark), so a leaf component gains nothing and this report is worth ignoring there. Reach for `{ keepTemplate: true }` when the component reads its own template through `viewChild` or content projection, which this rule cannot see from the spec."
342
+ };
343
+ function buildsDirectiveHarness(source) {
344
+ return source.includes("createDirectiveHost");
345
+ }
339
346
  function readsRenderedTemplate(source) {
340
347
  return TEMPLATE_READS.some((member) => source.includes(member));
341
348
  }
@@ -1656,13 +1663,11 @@ var preferRenderShallow = defineRule({
1656
1663
  description: "Render through renderShallow() when the spec never reads the rendered template",
1657
1664
  hasSuggestions: true,
1658
1665
  schema: [{ type: "object", properties: { templates: { enum: ["as-needed", "never"] } }, additionalProperties: false }],
1659
- messages: {
1660
- keepTemplate: '`keepTemplate: true` puts the real template back, and this project set `{ templates: "never" }`. Drop it \u2014 or, when the component genuinely reads its own template through `viewChild` or content projection, silence this line, because the alternative is a spec that cannot reach the component at all.',
1661
- preferRenderShallow: "`TestBed.createComponent` pays for compiling the template and instantiating the whole child subtree, and nothing in this file reads either \u2014 no `nativeElement`, no `debugElement`, no `By.css`, no `querySelector`. `renderShallow(X)` brings the same component up through the same `TestBed` with the children dropped and the template blank, and leaves inputs, signals, lifecycle hooks and DI exactly where they were; `fixture` is still a real `ComponentFixture`. What it buys is measured in `bench-angular/`: **0.24\xD7** the per-test cycle at 100 children and **0.05\xD7** at 400 \u2014 but at **zero** children the two are level (measurements straddle 1.0, and it is the noisiest row in the benchmark), so a leaf component gains nothing and this report is worth ignoring there. Reach for `{ keepTemplate: true }` when the component reads its own template through `viewChild` or content projection, which this rule cannot see from the spec."
1662
- },
1666
+ messages: RENDER_MESSAGES,
1663
1667
  create: (context) => ({
1664
1668
  'CallExpression[callee.object.name="TestBed"][callee.property.name="createComponent"]': (node) => {
1665
- if (templatePolicy(context) === "as-needed" && readsRenderedTemplate(context.sourceCode.getText())) {
1669
+ const source = context.sourceCode.getText();
1670
+ if (templatePolicy(context) === "as-needed" ? readsRenderedTemplate(source) : buildsDirectiveHarness(source)) {
1666
1671
  return;
1667
1672
  }
1668
1673
  const suggestion = renderShallowSuggestion(context, node);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-auto-spy",
3
- "version": "4.5.0",
3
+ "version": "4.5.1",
4
4
  "description": "Auto-generate fully-typed test spies from a class — across Vitest, Bun and node:test, 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",
@@ -78,7 +78,7 @@ describe('TaskService', () => {
78
78
 
79
79
  One `configureTestingModule` per `describe` — reconfiguring per `it()` recompiles the module every
80
80
  test. Use `mockReadonlyProp(component, 'selected', signal(true))` for the signals of the class under
81
- test, `await stable(fixture)` before asserting zoneless state, `renderShallow` for components. For an
81
+ test, `await stable(fixture)` before asserting zoneless state, `renderShallow` for components — `prefer-render-shallow` reports the `TestBed.createComponent` in a file that reads no markup back, and the rewrite is a suggestion rather than a `--fix` because `renderShallow` configures the module itself. For an
82
82
  `httpResource()`, `await expectRequest(url).flush(body)` from `vitest-auto-spy/angular-http` is the
83
83
  whole dance — the request is issued by `flushEffects()`, not on creation, and the value is settled
84
84
  before the promise resolves; by hand it is six steps and asserting early reads the resource's