I’m using ng2-dnd node module in my application and trying to unit test. I know that the services which ever we use in the component is to be declared under providers in the spec.ts file and I’ve added the DndModule in the imports of the spec.ts file
Now I’m getting this error
Error: StaticInjectorError(DynamicTestModule)[SortableComponent -> DragDropService]: StaticInjectorError(Platform: core)[SortableComponent -> DragDropService]: NullInjectorError: No provider for DragDropService!
Since DragDropService is the service inside the ng2-dnd module is it necessary to add it in our providers?
I’ve tried to add the DragDropService in the providers of the spec.ts
file and ran the test case again which throws the next error as,
Error: StaticInjectorError(DynamicTestModule)[SortableComponent -> DragDropConfig]: StaticInjectorError(Platform: core)[SortableComponent -> DragDropConfig]: NullInjectorError: No provider for DragDropConfig!
Once again DragDropConfig is inside ng2-dnd module. and the process goes on….
Is this the only way to run unit testing in Angular that adding all the services and directives used in the external node modules in the spec.ts file which ever we use or we can ignore the external modules?
Note : The Drag and drop inside my application is to be tested with the unit testing, ignoring doesn’t mean that the entire feature is ignored.
Source: New feed
Source Url How to overcome the No provider for Error for the external node modules used