title: Error: Template parse errors: There is no directive with "exportAs" set to "matAutocomplete" (""auto" [formControl] ="..."
body: <p>I am writing unit test to check if component is getting created successfully. I see the following error
   Error: Template parse errors: There is no directive with "exportAs" set to "matAutocomplete" (""auto"  [formControl</p>
  
  <p>This is my template.html which contains auto-complete directive</p>
  
  <pre><code>&lt;mat-form-field &gt;
    &lt;input matInput [matAutocomplete]="auto"  [formControl]="customerFilterControl"&gt;
    &lt;mat-autocomplete panelWidth ="450px" #auto="matAutocomplete" [displayWith] = "displayFn" style="width:750px;"&gt;
       &lt;mat-option  *ngFor="let customer of filteredOptions | async" [value] ="customer.AccountID + '('+ customer.AccountName + ')'" (click)="onCustomerChange(customer)"&gt;
        {{customer.AccountID}} ({{customer.AccountName}})
       &lt;/mat-option&gt;
    &lt;/mat-autocomplete&gt;
  &lt;/mat-form-field&gt;
  </code></pre>
  
  <p>This is the unit test spec.file, I have tried the following things,</p>
  
  <pre><code>import { ActualComponent } from './ActualComponent';
  import { NO_ERRORS_SCHEMA,CUSTOM_ELEMENTS_SCHEMA,Directive } from '@angular/core'; 
  
  @Directive({
    selector:'&lt;matAutocomplete&gt;',
  })
  export class matAutocomplete{}
  
   beforeEach(()=&gt;{
    TestBed.configureTestingModule({
         imports:[....],
        declarations:[...matAutocomplete],(1)
         ...
       schemas:[NO_ERRORS_SCHEMA,CUSTOM_ELEMENTS_SCHEMA] //this didn't fix (2)
  })
  
    it('should create', () =&gt; {
      expect(component).toBeTruthy();
    })
  
  </code></pre>
  
  <p>I expected test to pass for  (1) defining directive "matAutocomplete" and declaring in spec file (2) decalring schemas in testbed config But still test is not passing! Does anyone have suggestion for me?</p>