I have several failing tests that only output [object ErrorEvent] thrown. I don\'t see anything in the console that helps me pinpoint the offending code. Is t
In my case the problem was with the service, as one of the object wil be undefined during tests running.
Service code sample was something like below access to dom,
const elem = this.document.querySelector(element) as HTMLElement;
elem.scrollIntoView({param1: ''});
The specs referring to this service were failing with the error '[object ErrorEvent] thrown'.
I mocked my service object inside all the specs which were referring to this and the issue got resolved.
Mock service
class MockService {
serviceMethod(div) : void {
testElement = document.querySelector('div') as HTMLElement;
return testElement;
}
}
And use this mock service object in providers as below,
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [Component],
providers: [
{ provide: Service, useClass: MockService },
],
})
.compileComponents();
}));