-
-
Notifications
You must be signed in to change notification settings - Fork 87
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: Mocking standalone components may cause warnings #6928
Comments
Hi @clusterberries, thanks for highlighting the issue. Working on its fix. |
The fix is here. However, even without
|
The right way is to import a mock of |
So, I found a way to fix that in a flexible way. In case of |
fix(core): respecting the order of declaration in TestBed #6928
v14.12.0 has been released and contains a fix for the issue. Feel free to reopen the issue or to submit a new one if you meet any problems. |
Hi @satanTime, thank you! It works excellently now |
Description of the bug
In my app, I have started using standalone components and found a bug related to it. Note that this issue does not occur with non-standalone components.
Steps:
SharedModule
with some components used across the application.StandaloneComponent
that uses components fromSharedModule
.MyComponent
(not standalone) usesStandaloneComponent
and also some components fromSharedModule
.MyComponent
and mock the dependencies usingMockComponent
like the following example:Result: After running this test there is a warning in the console
NG0304: 'app-shared2' is not a known element (used in the 'MyComponent' component template)
Workaround: mock the entire
SharedModule
instead of mocking separate components. However, this approach may cause performance issues ifSharedModule
contains a large number of components.An example of the bug
Link: https://stackblitz.com/edit/github-pyxbdq?devToolsHeight=33&file=src%2Ftest.spec.ts
Expected vs actual behavior
Actual result: a warning in the console
NG0304: 'app-shared2' is not a known element (used in the 'MyComponent' component template)
.Expected result: The warning should not appear, since the
SharedComponent2
is properly mocked.Thank you for checking this out!
The text was updated successfully, but these errors were encountered: