title: Karma unit testing error: Unexpected value imported by the module. Please add a @NgModule annotation
body: <p>I've created a fresh new component via:</p>
  
  <pre><code>ng g mytest1
  </code></pre>
  
  <p>Then I changed the constructor line to this:</p>
  
  <pre><code>constructor(private dialogRef: MatDialogRef&lt;Mytest1Component&gt;) { }
  </code></pre>
  
  <p>, and added the required import:</p>
  
  <pre><code>import { MatDialogRef } from '@angular/material';
  </code></pre>
  
  <p>After that I ran the Karma unit test project via:</p>
  
  <pre><code>ng test
  </code></pre>
  
  <p>The test failed. I got this error message:</p>
  
  <blockquote>
    <p>Error: StaticInjectorError(DynamicTestModule)[Mytest1Component -> MatDialogRef]: StaticInjectorError(Platform: core)[Mytest1Component -> MatDialogRef]: NullInjectorError: No provider for MatDialogRef!</p>
  </blockquote>
  
  <p>To fix that I added the Import statement in the beforeEach section:</p>
  
  <pre><code>import { MatDialogRef } from '@angular/material';
  
  //...
  
  beforeEach(async(() =&gt; {
      TestBed.configureTestingModule({
          declarations: [ Mytest1Component ],
          imports: [MatDialogRef],
      })
      .compileComponents();
  }));
  </code></pre>
  
  <p>Now I got this new error, which I am not able to fix:</p>
  
  <blockquote>
    <p>Failed: Unexpected value 'MatDialogRef' imported by the module 'DynamicTestModule'. Please add a @NgModule annotation.</p>
  </blockquote>
  
  <p>Can someone clarify where I should be adding the @NgModule annotation, or if I had done something completely wrong?</p>
  
  <p>Thank you.</p>