@ContentChild mocking fails with html attribute selection
See original GitHub issueWhen mocking a component that has @ContentChild
projection, the generated mock will be invalid if the @ContentChild
uses an HTML attribute selector.
e.g. @ContentChild('[projectedContent]'...
with <div projectedContent>This is not mockable</div>
This does not appear to be an issue when using Angular template reference selection
e.g. @ContentChild('projectedContent'...
with <div #projectedContent>This is mockable</div>
When running the tests, they fail with the error TypeError: Cannot read property 'undefined' of undefined
I’ve created a repo to demonstrate the issue at https://github.com/joebell1329/contentProjectionDemo
When running the tests in the demo, the issue seems to be with the generated HTML in ng://DynamicTestModule/MockOfNotMockableComponent.html
The error is thrown on the line <div *ngIf="mockRender_[projectedContent]" data-key="[projectedContent]">
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (5 by maintainers)
Hi @GerkinDev, yes, please create a new one with an example. Finally, this weekend I have my hands on the issues.
Hi,
I’m experiencing this issue as well. In my case, I want to use an optional
ContentChild
selected by attribute. The errorTypeError: Cannot read property 'undefined' of undefined
is thrown if I do not declare anng-template
with the selected attribute.Should I open a new issue with proper sample ?