-
-
Notifications
You must be signed in to change notification settings - Fork 85
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: MockRender throws an error on mat-tab #8884
Comments
Error message hints that CommonModule is not available in your test case setup. Try adding missing imports.
|
I tried what you suggested, doesn't fix the problem. Sorry that's not it. You don't have to import CommonModule in any other Component Tests, and it's definitely imported into the Component being tested. I have used many of the Material Components in my application, not all of them, and so far I have only come across this problem is when a Mat Tab is used in a Component. This problem did not occur in version 16 of Angular. It appeared with Angular 17. When I upgraded to Angular 17 I also upgraded my version of ng-mocks to the latest. import { CommonModule } from '@angular/common'; @component({ } |
I have the same issue for my own component |
Use new angular control flow to avoid missing directive while mocking child templates Solves help-me-mom#8884
Use new angular control flow to avoid missing directive while mocking child templates Solves help-me-mom#8884
Use new angular control flow to avoid missing directive while mocking child templates Solves help-me-mom#8884
Hi, we have an error since we migrated from angular 16 to angular 17. We are currently on the latest version of ng-mocks (14.13.0, the previous version was 14.11.0). We are using the library NG-ZORRO, it's the equivalent of Angular Material. We also have this kind of error on unit tests :
Before this migration, the units tests were all good, but now, every files that mock We hope that this PR : #9314 will fix the problem. Can we have any update on when this fix will be release please ? Thx. |
Use new angular control flow to avoid missing directive while mocking child templates Solves help-me-mom#8884
v14.13.1 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. |
In Angular Version 17 MockRender throws errors when a Component contains a Material Tab
For each contained in a Components Template an error is written to the console for each element in the template. If you have 3 tabs you will get the same error repeated 3 times in the console.
The test still gets a PASS outcome despite the exceptions. The problem comes with DevOps Pipelines. If you include the execution of the tests as part of the pipeline the Release will fail due to these errors.
console.error
NG0303: Can't bind to 'ngIf' since it isn't a known property of 'div' (used in the '_MatTab' component template).
If the 'ngIf' is an Angular control flow directive, please make sure that either the 'NgIf' directive or the 'CommonModule' is included in the '@Component.imports' of this component.
PASS src/app/app.component.spec.ts
AppComponent
√ should create the app (310 ms)
I have attached a zip file containing a simple Angular Application that demonstrates the issue. I have removed the node modules to reduce the size of the file.
Expected vs actual behavior
The tests of the Component containing Material Tabs should pass without throwing errors.
mat-tab-error-issue.zip
The text was updated successfully, but these errors were encountered: