title: NullInjectorError: No provider for InjectionToken MatDialogData
body: <p>I'm getting this error when running jasmine tests on my Angular app.</p>
  
  <pre><code>Error: StaticInjectorError(DynamicTestModule)[MyEditDialogComponent -&gt; InjectionToken MatDialogData]: 
    StaticInjectorError(Platform: core)[MyEditDialogComponent -&gt; InjectionToken MatDialogData]: 
      NullInjectorError: No provider for InjectionToken MatDialogData!
  error properties: Object({ ngTempTokenPath: null, ngTokenPath: [ 'MyEditDialogComponent', InjectionToken MatDialogData ], ngDebugContext: DebugContext_({ view: Object({ def: Object({ factory: Function, nodeFlags: 33669121, rootNodeFlags: 33554433, nodeMatchedQueries: 0, flags: 0, nodes: [ Object({ nodeIndex: 0, parent: null, renderParent: null, bindingIndex: 0, outputIndex: 0, checkIndex: 0, flags: 33554433, childFlags: 114688, directChildFlags: 114688, childMatchedQueries: 0, matchedQueries: Object({  }), matchedQueryIds: 0, references: Object({  }), ngContentIndex: null, childCount: 1, bindings: [  ], bindingFlags: 0, outputs: [  ], element: Object({ ns: '', name: 'app-edit-ban-dialog', attrs: [  ], template: null, componentProvider: Object({ nodeIndex: 1, parent: &lt;circular reference: Object&gt;, renderParent: &lt;circular reference: Object&gt;, bindingIndex: 0, outputIndex: 0, checkIndex: 1, flags: 114688, childFlags: 0, directChildFlags: 0, childMatchedQueries: 0, matchedQueries: Object, matchedQueryIds: 0 ...
  Error: StaticInjectorError(DynamicTestModule)[MyEditDialogComponent -&gt; InjectionToken MatDialogData]: 
    StaticInjectorError(Platform: core)[MyEditDialogComponent -&gt; InjectionToken MatDialogData]: 
      NullInjectorError: No provider for InjectionToken MatDialogData!
  </code></pre>
  
  <p>I am importing in my component:</p>
  
  <pre><code>import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
  </code></pre>
  
  <p>In the component constructor I am Injecting data to the dialog:</p>
  
  <pre><code> @Inject(MAT_DIALOG_DATA) public data: {
          myData : MyData
      }
  </code></pre>
  
  <p>In my karma jasmin spec for the component I am importing:</p>
  
  <pre><code>import {
      MatFormFieldModule,
      MatInputModule,
      MatDialogModule,
      MatDialogRef,
      MAT_DIALOG_DATA,
      MatButtonModule,
      MatRadioModule,
      MatSelectModule
  } from '@angular/material';
  </code></pre>
  
  <p>In the karma/jasmine spec for the component, imports and providers in <code>beforeEach</code>:</p>
  
  <pre><code> beforeEach(async(() =&gt; {
      TestBed.configureTestingModule({
          declarations: [ MyFormComponent ],
          imports: [
              MatFormFieldModule,
              MatInputModule,
              MatDialogModule,                               
          ],
          providers: [
              { provide: MatDialogRef, useValue: {} },
              { provide: MAT_DIALOG_DATA, useValue: { myData: MyData } }
          ]
      }).compileComponents();
  }));
  </code></pre>
  
  <p>I've tried these answers but they don't fix the issue
  <a href="https://stackoverflow.com/questions/46706533/matdialog-error-no-provider-for-injectiontoken-mat-dialog-scroll-strategy">This</a>
  <a href="https://github.com/angular/components/issues/8419" rel="noreferrer">This</a></p>