Component unit test complains about missing provider for factory (ngRedux)

282 views
Skip to first unread message

Tobias Krogh

unread,
Apr 28, 2016, 11:26:55 AM4/28/16
to AngularJS

Hi,

I am fairly new to Angular 2 so I want to apologize upfront if I just oversaw a small thing or this might be a stupid issue. I have a small Angular 2 app and recently integrated ng2-redux which worked like a charm.


I started creating a spec (based on Jasmine) for the app component I connected via ng2-redux (done by using "@Inject('ngRedux') ngRedux") and executing the tests via Karma are running into the following issue:


Failed: No provider for ngRedux! (App -> ngRedux)


I tried several things and also tried to find my way through a lot of documentation but can't seem to find the right solution. From what I understand I need to pass either a proper implementation or mock here:


// provide our implementations or mocks to the dependency injector
beforeEachProviders(() => [
  App
]);


I tried duplicating the conditions for the main bootstrap but when I do so (or any other way) there is an error occurring at _instantiateProvider in the injector.ts of angular 2 (no specific error message though). Am I missing something? I found nearly no documentation about adding a provider for the ngRedux factory or factories in general (hope I use the proper wording here).


Any help is welcome.


Cheers

Tobias Krogh

unread,
May 5, 2016, 7:44:38 AM5/5/16
to AngularJS
Solved with the help of the package authors. see https://github.com/angular-redux/ng2-redux/issues/51
Reply all
Reply to author
Forward
0 new messages