I'm trying to run jasmine karma with
ng test
Surprise with all the issues with Angular Materials. I see example of OLDER version of material many months ago when it was called md-icon
instead of mat-icon
etc...
Thus this doesn't fix the errors thrown
MaterialModule.forRoot()
Error
mat-icon is not a known element angular material
I was experiencing the same issues testing Material components.
Thanks to k.vincent for providing the correct answer for me in the comments.
For components using Material, ensure your *.spec file looks similar to this:
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
...
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ MyComponent ],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
})
.compileComponents();
}));