title: Angular 4 testing - [object ErrorEvent] thrown
body: <p>I'm in the process of completing the test bed for my angular application. But there is an issue in the karma-jasmine testing, which throws an error</p>
  
  <blockquote>
    <p>[object ErrorEvent] thrown</p>
  </blockquote>
  
  <p>I updated the node_modules as a solution I found in the following link
  <a href="https://stackoverflow.com/questions/45722256/how-do-i-debug-a-object-errorevent-thrown-error-in-my-karma-jasmine-tests">How do I debug a &quot;[object ErrorEvent] thrown&quot; error in my Karma/Jasmine tests?</a></p>
  
  <p>But now error throws at random times, sometimes test bed is completed without any fault, sometimes above error triggers. Any suggestions to avoid it permanently?</p>
  
  <p>PS - Let me know in the comments if you need more resources. Thanks!</p>
  
  <p><strong>SomeComponent.spec.ts</strong></p>
  
  <pre class="lang-js prettyprint-override"><code>import { RouterTestingModule } from '@angular/router/testing';
  import { FormsModule, ReactiveFormsModule } from '@angular/forms';
  import { NgModule } from '@angular/core';
  import { HttpClient, HttpClientModule } from '@angular/common/http';
  import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
  import { async, ComponentFixture, TestBed } from '@angular/core/testing';
  import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
  
  import { SomeComponent } from './some.component';
  import { HttpLoaderFactory } from '../app.module';
  import { AppRoutingModule } from '../app-routing.module';    
  import { SomeService } from './../services/some.service';
  
  describe('SomeComponent', () =&gt; {
    let component: SomeComponent;
    let fixture: ComponentFixture&lt;SomeComponent&gt;;
  
    beforeEach(async(() =&gt; {
      TestBed.configureTestingModule({
        imports: [
          TranslateModule.forRoot({
            loader: {
              provide: TranslateLoader,
              useFactory: HttpLoaderFactory,
              deps: [HttpClient]
            }
          }),
          HttpClientModule,
          AppRoutingModule,
          FormsModule,
          ReactiveFormsModule ,
          RouterTestingModule,
          NgbModule.forRoot(),
          FormsModule, 
          ReactiveFormsModule,
        ],
        declarations: [
          SomeComponent
         ],
        providers: [
          SomeService
         ]
      })
      .compileComponents();
    }));
  
    beforeEach(() =&gt; {
      fixture = TestBed.createComponent(SomeComponent);
      component = fixture.componentInstance;
      fixture.detectChanges();
    });
  
    it('should create', () =&gt; {
      expect(component).toBeTruthy();
    });
  });
  </code></pre>