Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Erroneous test setup due to the usage of contentChildren #8895

Open
LukasMachetanz opened this issue May 6, 2024 · 7 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@LukasMachetanz
Copy link

LukasMachetanz commented May 6, 2024

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?

@LukasMachetanz LukasMachetanz added the bug Something isn't working label May 6, 2024
@andreandersson
Copy link

Possibly duplicate of #8634

@LukasMachetanz
Copy link
Author

@andreandersson, definitely. I experienced the same problem with viewChild as well.

@LukasMachetanz
Copy link
Author

Any news on this issue? This bug really prevents using the new API.

@PieterjanDeClippel
Copy link

PieterjanDeClippel commented Jul 7, 2024

Same here. It seems that @ContentChildren(...) still works fine, but contentChildren(...) throws mentioned exception

@satanTime Any idea?

@wall-street-dev
Copy link

@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.

@squelix
Copy link

squelix commented Jul 16, 2024

Any news on this issue?

@wall-street-dev
Copy link

wall-street-dev commented Jul 16, 2024

Any news on this issue?

A workaround in the meantime... 😕
https://stackoverflow.com/a/78736480/1277159

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants