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
[object ErrorEvent] thrown
I updated the node_modules as a solution I found in the following link How do I debug a "[object ErrorEvent] thrown" error in my Karma/Jasmine tests?
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?
PS - Let me know in the comments if you need more resources. Thanks!
SomeComponent.spec.ts
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', () => {
let component: SomeComponent;
let fixture: ComponentFixture<SomeComponent>;
beforeEach(async(() => {
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(() => {
fixture = TestBed.createComponent(SomeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});