ng-mocks
ng-mocks copied to clipboard
Bug: Erroneous test setup due to the usage of contentChildren
Description of the bug
Let's assume having a component SystemUnderTestComponent
as the SUT. This component internally renders ActionsComponent
, which will be mocked within the test setup. ActionsComponent
uses the new API contentChildren
for accessing its content children. Unfortunately this API causes problems for SystemUnderTestComponent
as the following error is thrown: TypeError: Cannot read properties of undefined (reading 'Symbol(SIGNAL)')
.
An example of the bug
https://codesandbox.io/p/sandbox/competent-fermat-llrjgt?file=%2Fsrc%2Ftest.spec.ts%3A35%2C35
Expected behavior
I would expect that the tests of SystemUnderTestComponent
are not influenced by internals of the mocked component ActionsComponent
.
Maybe this behavior is caused by the fact that ActionsComponent
is mocked and Angular can't find ActionComponent
?
Possibly duplicate of https://github.com/help-me-mom/ng-mocks/issues/8634
@andreandersson, definitely. I experienced the same problem with viewChild
as well.
Any news on this issue? This bug really prevents using the new API.
Same here. It seems that @ContentChildren(...)
still works fine, but contentChildren(...)
throws mentioned exception
@satanTime Any idea?
@PieterjanDeClippel has created a minimal repro here: https://github.com/PieterjanDeClippel/signaltesting/tree/master/src/app
As mentioned by others, the issue arises when we use for example:
MockDirective(BsCheckboxGroupDirective)
and the BsCheckboxGroupDirective
is using the new signal based queries.
Any news on this issue?
Any news on this issue?
A workaround in the meantime... 😕 https://stackoverflow.com/a/78736480/1277159