I'm using Angular Material 2 inside my components template. When I run basic unit test I get Template parse errors. I've tried to import the Angular Material 2 library into the test directly but this has no effect, If I import the AppModule I get even more errors. Whats the best approach to circumvent this error? Do I need to import something else?
Thanks in adavance.
-- my component
<md-card>
<md-select placeholder="Food" [formControl]="foodControl">
<md-option *ngFor="let food of foods" [value]="food.value"> {{ food.viewValue }} </md-option>
</md-select>
</md-card>
-- unit test
import { Component } from '@angular/core';
import { MaterialModule } from '@angular/material';
import { TestBed, inject, async } from '@angular/core/testing';
import { MyComponent } from './MyComponent.component';
describe('testing', () => {
beforeEach(() => {
TestBed.configureTestingModule(
{
imports: [MaterialModule],
declarations: [MyComponent, TestComponent]
});
});
it('should ...', () => {
const fixture = TestBed.createComponent(TestComponent);
});
});
@Component(
{
selector: 'my-test',
template: '<div></div>'
}
)
class TestComponent {
}
-- error message relating to material2
Uncaught Error: Template parse errors: 'md-nav-list' is not a known element: 1. If 'md-nav-list' is an Angular component, then verify that it is part of this module. 2. If 'md-nav-list' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("