1
votes

When I do karma unit test in Angular5, I have some issues.

Chrome 63.0.3239 (Windows 7 0.0.0): Executed 3 of 29 SUCCESS (0 secs / 2.516 secs) Chrome 63.0.3239 (Windows 7 0.0.0) ERROR Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'ng:///DynamicTestModule/FollowersItemComponent_Host.ngfactory.js'. Chrome 63.0.3239 (Windows 7 0.0.0) ERROR Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'ng:///DynamicTestModule/FollowersItemComponent_Host.ngfactory.js'.
at http://localhost:9876/_karma_webpack_/polyfills.bundle.js:2281 Chrome 63.0.3239 (Windows 7 0.0.0): Executed 3 of 29 ERROR (0 secs / 2.516 secs) Chrome 63.0.3239 (Windows 7 0.0.0) ERROR Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'ng:///DynamicTestModule/FollowersItemComponent_Host.ngfactory.js'. Chrome 63.0.3239 (Windows 7 0.0.0): Executed 3 of 29 ERROR (2.546 secs / 2.516 secs)

I am not sure why this problem happened. Please help me. Thanks.

1

1 Answers

1
votes

I don't know if you managed this, but this errors could come from any input the component is waiting :)

If you have @Input() in your component, then you need to provide this input in your tests. Usually you can do it in beforeEach method :

beforeEach(() => {
   fixture = TestBed.createComponent(YourComponent);
   component = fixture.componentInstance;
   component.yourInput = 'anyInput' 
});