Karma, Jasmine, and unit testing errors
When running tests with the ng test
command, you will encounter some high-level errors that can mask the root cause of the actual underlying errors.
The general approach to resolving errors should be inside out, resolving child component issues first and leaving parent and root components for last.
NetworkError
Network errors can be caused by a multitude of underlying issues:
NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'ng:///DynamicTestModule/AppComponent.ngfactory.js'.
Working inside out, you should implement test doubles of services and provide the fakes to the appropriate components, as covered in the previous section. However, in parent components, you may still encounter errors even if you correctly provided fakes. Refer to the section on dealing with generic error events to uncover the underlying issues.
Generic ErrorEvents
Error events are generic...