Skip to content

Importing a recursive cycle of standalone components into TestBed causes an infinite loop #49469

@atscott

Description

@atscott

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

No

Description

Importing a recursive cycle of standalone components into TestBed.configureTestingModule causes an infinite loop in queueTypesFromModulesArrayRecur.

Please provide a link to a minimal reproduction of the bug

it('should render a recursive cycle of standalone components', () => {
@Component({
selector: 'cmp-a',
standalone: true,
template: '<ng-template [ngIf]="false"><cmp-c></cmp-c></ng-template>A',
imports: [forwardRef(() => StandaloneCmpC)],
})
class StandaloneCmpA {
}
@Component({
selector: 'cmp-b',
standalone: true,
template: '(<cmp-a></cmp-a>)B',
imports: [StandaloneCmpA],
})
class StandaloneCmpB {
}
@Component({
selector: 'cmp-c',
standalone: true,
template: '(<cmp-b></cmp-b>)C',
imports: [StandaloneCmpB],
})
class StandaloneCmpC {
}
const fixture = TestBed.createComponent(StandaloneCmpC);
fixture.detectChanges();
expect(fixture.nativeElement.textContent).toBe('((A)B)C');

Right before the TestBed.createComponent, add TestBed.configureTestingModule({imports: [StandaloneCmpC]});

Please provide the exception or error you saw


    RangeError: Maximum call stack size exceeded

    at queueTypesFromModulesArrayRecur

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: coreIssues related to the framework runtimearea: testingIssues related to Angular testing features, such as TestBedcross-cutting: standaloneIssues related to the NgModule-less worldstate: has PR

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions