Angular 9 firebase service: No provider for InjectionToken angularfire2.app.options, even with subs

2,793 views
Skip to first unread message

Wade McDaniel

unread,
Apr 30, 2020, 10:21:54 AM4/30/20
to Firebase Google Group
I'm trying to learn unit testing via Jest and I'm having trouble with AngularFire2 in Angular 9 in a Server-side Rendered app (SSR) I'm working on for my wife, and to get better at Angular.

I get a bunch of "should create" errors when I run `ng test --coverage` that look like this:

    NullInjectorError: R3InjectorError(DynamicTestModule)[FirebaseDataService -> AngularFireAuth -> InjectionToken angularfire2.app.options -> InjectionToken angularfire2.app.options]:
      NullInjectorError: No provider for InjectionToken angularfire2.app.options!


When I've searched on this error, and I've searched a bunch, I see that the solution is to sub the AngularFire modules so as to not actually talk to any database. I believe I've subbed the AngularFireDatabase, AngularFireAuth, and AngularFIreAnalytics modules, but I still get that same error whenever my FirebaseDataService get loaded.

I sub AngularFireAuthModule in app.component.spec.ts yet /services/firebasedata.service.spec.ts still has issues with AngularFireAuth

Can someone see where I'm messing up the subbing of AngularFireAuth for my authSub?

Thank you!

Kato Richardson

unread,
May 4, 2020, 2:07:56 PM5/4/20
to Firebase Google Group
Hi Wade,

Please submit this on the issue tracker for Angular.

☼, Kato

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/f27b8609-cb0a-4d14-9184-59e910efc7ab%40googlegroups.com.


--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Reply all
Reply to author
Forward
0 new messages