forwardRef in Standalone Components #11325
Unanswered
BillToBill
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I was in the process of converting a module-based project to standalone and had to convert an import to be a forwardRef. When attempting to mock a standalone component that uses forwardRef for one of its imports with "MockBuilder," I'm getting the NG0304 error. I can't share the exact code but the components and looks something like this:
@component({
selector: 'app-test',
templateUrl: './test.component.html',
styleUrls: ['./test.component.css'],
imports: [FirstComponent,
forwardRef(() => SecondComponent)]
})
export class TestComponent {...}
And the spec file looks something like this:
describe('TestComponent', () => {
beforeEach(() => {
return MockBuilder(TestComponent);
})
it('should create', () => {
const fixture = MockRender(TestComponent);
let component = fixture.componentInstance;
expect(component).toBeDefined();
});
Is there anything I'm missing with the set up of the component or the spec file? Or are forwardRef imports not really handled by ng-mocks?
Thanks for any ideas.
Beta Was this translation helpful? Give feedback.
All reactions