Join the Stack Overflow Community
Stack Overflow is a community of 6.4 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

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. ("

share|improve this question
    
Please reproduce it here plnkr.co/edit/2Gq4ZR7iBmZYrDVXuI55?p=preview – yurzui 6 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.