diff --git a/libs/ng-mocks/src/lib/common/decorate.queries.ts b/libs/ng-mocks/src/lib/common/decorate.queries.ts
index 8609839342..4465dff7da 100644
--- a/libs/ng-mocks/src/lib/common/decorate.queries.ts
+++ b/libs/ng-mocks/src/lib/common/decorate.queries.ts
@@ -26,10 +26,13 @@ const generateFinalQueries = (queries: {
const scanKeys: string[] = [];
for (const key of Object.keys(queries)) {
- const query: Query & { ngMetadataName?: string } = queries[key];
- final.push([key, query]);
+ const query: Query & { ngMetadataName?: string; isSignal?: boolean } = queries[key];
- if (!query.isViewQuery && !isInternalKey(key)) {
+ if (!query.isSignal) {
+ final.push([key, query]);
+ }
+
+ if (!query.isViewQuery && !query.isSignal && !isInternalKey(key)) {
scanKeys.push(key);
final.push([`__ngMocksVcr_${key}`, cloneVcrQuery(query)]);
}
diff --git a/libs/ng-mocks/src/lib/mock-component/render/generate-template.ts b/libs/ng-mocks/src/lib/mock-component/render/generate-template.ts
index da227d836e..eb1e2186f1 100644
--- a/libs/ng-mocks/src/lib/mock-component/render/generate-template.ts
+++ b/libs/ng-mocks/src/lib/mock-component/render/generate-template.ts
@@ -3,7 +3,7 @@ import { Query, TemplateRef, ViewChild, ViewContainerRef } from '@angular/core';
const viewChildArgs: any = { read: ViewContainerRef, static: false };
const viewChildTemplate = (selector: string, key: string): string =>
- `
`;
+ `@if (ngMocksRender_${key}_${selector}) {
}`;
const isTemplateRefQuery = (query: Query): boolean => {
if (query.isViewQuery) {
@@ -27,10 +27,13 @@ export default (queries?: Record): string => {
}
for (const key of Object.keys(queries)) {
- const query: Query = queries[key];
+ const query: Query & { isSignal?: boolean } = queries[key];
if (!isTemplateRefQuery(query)) {
continue;
}
+ if (query.isSignal) {
+ continue;
+ }
if (typeof query.selector === 'string') {
const selector = query.selector.replace(new RegExp('\\W', 'mg'), '_');
queries[`__mockView_key_${selector}`] = new ViewChild(`key_${selector}`, viewChildArgs);
diff --git a/tests-e2e/src/issue-8634/test.spec.ts b/tests-e2e/src/issue-8634/test.spec.ts
new file mode 100644
index 0000000000..f37c4da9eb
--- /dev/null
+++ b/tests-e2e/src/issue-8634/test.spec.ts
@@ -0,0 +1,47 @@
+import {
+ Component,
+ ElementRef,
+ Input,
+ contentChild,
+ input,
+ viewChild,
+} from '@angular/core';
+import { MockBuilder, MockRender } from 'ng-mocks';
+
+@Component({
+ selector: 'app-nested',
+ standalone: true,
+ template: `Nested content
`,
+})
+class NestedComponent {
+ public readonly meowV = viewChild('meow');
+ public readonly meowC = contentChild('meow');
+
+ public readonly name = input.required();
+}
+
+@Component({
+ selector: 'app-target',
+ standalone: true,
+ imports: [NestedComponent],
+ template: `
+
+ name: {{ name }}
+ `,
+})
+class TargetComponent {
+ @Input() public readonly name: string = '';
+}
+
+describe('my sandbox', () => {
+ beforeEach(() => MockBuilder(TargetComponent));
+
+ it('should do something', () => {
+ const fixture = MockRender(TargetComponent, {
+ name: 'sandbox',
+ });
+ expect(fixture.nativeElement.innerHTML).toContain(
+ 'name: sandbox',
+ );
+ });
+});