title: MatSnackBar error when using TestBed component creation and undefined fixture
body: <p><strong>[CONTEXT]:</strong> So here's the thing. I'm currently trying to build some unit tests for a component in angular 8 using jest, jasmine and angular TestBed module.
  This component is pretty basic, one datable, data table fetched from an API, and possibility to edit the data.</p>
  
  <p>Here's an sample of my spec file:</p>
  
  <pre><code>jest.mock('../../../services/external-actors.service');
  // jest.mock('@angular/material/snack-bar');
  jest.mock('@fuse/services/translation-loader.service');
  jest.mock('../../../services/snackbar.service');
  jest.mock('../../../services/permission/permission.service');
  
  describe('ListExternalActorsComponent', () =&gt; {
      beforeEach(async(() =&gt; {
  
          TestBed.configureTestingModule({
              imports: [
                  MatSnackBarModule,
                  MatTableModule,
                  MatMenuModule,
                  TranslateModule.forRoot({
                      loader: TranslateFakeLoader,
                  }),
              ],
              providers: [
                  MatSnackBar,
                  { provide: MatDialog },
                  // { provide: TranslateService },
                  { provide: FuseTranslationLoaderService },
                  { provide: SnackbarService },
                  { provide: PermissionService },
                  { provide: ExternalActorsService },
              ],
              declarations: [
                  ListExternalActorsComponent
              ],
              schemas: [NO_ERRORS_SCHEMA],
          }).compileComponents();
  
  
          beforeEach(inject([], () =&gt; { 
              fixture = TestBed.createComponent(ListExternalActorsComponent);
              component = fixture.componentInstance;
              fixture.detectChanges();
          }));
          afterEach(() =&gt; {
              fixture.destroy();
          });
      }));
  
      it('should instantiate', inject([], () =&gt; {
          expect(fixture).toBeDefined();
          console.log('FIXTURE &gt;&gt;&gt;&gt;&gt;', fixture);
          console.log('COMPONENT &gt;&gt;&gt;&gt;&gt;', component);
      }));
  });
  </code></pre>
  
  <p><strong>[PROBLEMS]:</strong></p>
  
  <ol>
  <li>The sample of code above is working when I launch my test but <code>fixture</code> and <code>component</code> are <em>undefined</em> and <code>expect(fixture).toBeDefined();</code> throw an error.</li>
  <li>When I try to move my component creation inside of the <code>it()</code> part like this:</li>
  </ol>
  
  <pre><code>it('should instantiate', inject([], () =&gt; {
          fixture = TestBed.createComponent(ListExternalActorsComponent);
          component = fixture.componentInstance;
          fixture.autoDetectChanges():
          console.log('FIXTURE &gt;&gt;&gt;&gt;&gt;', fixture);
          console.log('COMPONENT &gt;&gt;&gt;&gt;&gt;', component);
      }));
  </code></pre>
  
  <p>I got the error below caused by the component creation line (<code>TestBed.createComponent(ListExternalActorsComponent)</code>):</p>
  
  <pre><code>NullInjectorError: StaticInjectorError(DynamicTestModule)[ListExternalActorsComponent -&gt; MatSnackBar]: 
        StaticInjectorError(Platform: core)[ListExternalActorsComponent -&gt; MatSnackBar]: 
          NullInjectorError: No provider for MatSnackBar!Error: NullInjectorError: No provider for MatSnackBar!
  
        at NullInjector.get (../packages/core/src/di/injector_compatibility.ts:205:21) [angular]
        at resolveToken (../packages/core/src/di/injector.ts:315:20) [angular]
        at tryResolveToken (../packages/core/src/di/injector.ts:257:12) [angular]
        at StaticInjector.get (../packages/core/src/di/injector.ts:146:14) [angular]
        at resolveToken (../packages/core/src/di/injector.ts:315:20) [angular]
        at tryResolveToken (../packages/core/src/di/injector.ts:257:12) [angular]
        at StaticInjector.get (../packages/core/src/di/injector.ts:146:14) [angular]
        at resolveNgModuleDep (../packages/core/src/view/ng_module.ts:125:25) [angular]
        at NgModuleRef_.get (../packages/core/src/view/refs.ts:507:12) [angular]
        at resolveDep (../packages/core/src/view/provider.ts:423:43) [angular]
        at createClass (../packages/core/src/view/provider.ts:283:24) [angular]
        at createDirectiveInstance (../packages/core/src/view/provider.ts:136:20) [angular]
        at createViewNodes (../packages/core/src/view/view.ts:303:28) [angular]
        at createRootView (../packages/core/src/view/view.ts:210:3) [angular]
        at callWithDebugContext (../packages/core/src/view/services.ts:630:23) [angular]
        at Object.debugCreateRootView [as createRootView] (../packages/core/src/view/services.ts:122:10) [angular]
        at ComponentFactory_.create (../packages/core/src/view/refs.ts:93:27) [angular]
        at initComponent (../../packages/core/testing/src/test_bed.ts:589:28) [angular]
        at ProxyZoneSpec.onInvoke (node_modules/zone.js/dist/proxy.js:117:43) [angular]
        at Object.onInvoke (../packages/core/src/zone/ng_zone.ts:273:25) [angular]
        at NgZone.run (../packages/core/src/zone/ng_zone.ts:171:50) [ProxyZone]
        at TestBedViewEngine.createComponent (../../packages/core/testing/src/test_bed.ts:593:56) [ProxyZone]
        at Function.TestBedViewEngine.createComponent (../../packages/core/testing/src/test_bed.ts:232:36) [ProxyZone]
        at app/app/admin/external-actors/list-external-actors/list-external-actors.spec.ts:61:27 [ProxyZone]
        at TestBedViewEngine.execute (../../packages/core/testing/src/test_bed.ts:477:15) [ProxyZone]
        at ../../packages/core/testing/src/test_bed.ts:668:53 [ProxyZone]
        at ProxyZoneSpec.onInvoke (node_modules/zone.js/dist/proxy.js:117:43) [ProxyZone]
  </code></pre>
  
  <p>Any ideas which way of creating component with TestBed is the best/should be used and why this lovely MatSnackBar isn't working in some cases ?</p>
  
  <p>Thanks</p>