Unable to run tests when connected to two or more Firebase apps #2555
michaelyfan
started this conversation in
Ideas
Replies: 2 comments
-
AngularFireModule expects the options available to DI via the |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hey guy, I have problem too. Can u help me how to fix ? tks |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Version info
Angular: 9.0.2
Firebase: 7.8.0
AngularFire: ^6.0.0-rc.1
Other (e.g. Ionic/Cordova, Node, browser, operating system):
How to reproduce these conditions
Stackblitz example:
https://stackblitz.com/edit/angular-fire-start-nv2mnn
Steps to set up and reproduce
The Stackblitz example has a crude reproduction of my code.
Yes, I'm aware I intentionally left out
.initializeApp()
in my code. More on that below...Sample data and security rules
Firebase project with no security rules--this isn't really relevant to my issue
Debug output
When running
npm run test
, I receive this error in my Karma HTML runner:Screenshot:
There are many Google-able resolutions to this problem, all which involve invoking
.initializeApp()
. I'm aware I intentionally left that out. More on that below...Expected behavior
My tests run as normal!
Actual behavior
See "Debug output"
Special notes
I'm trying to connect my app to two Firebase projects at once. I've scoured around and there aren't really any official/standardized procedures for this, so I'm using this solution suggested in a comment on an open repo. I tried to recreate it as best as I could in the stackblitz.
The solution works well, but it doesn't require that I invoke
initializeApp
anywhere. So that thing where you gois not something that I have in my project.
I've always been a bit uncomfortable with this, since it doesn't seem like common practice at all, but I don't know how get over it, since doing the above would force me to choose a single Firebase project, which is what I'm trying to avoid all this time. I'm also worried that initializing w.r.t a single Firebase project, and then having providers for two Firebase projects, would cause some sort of unexpected behavior / conflict / headache which is why I haven't bothered.
So, how do I get past this? I'd like to connect to two Firebase projects, but I'd also like my tests to run, and know once and for all if what I'm doing is "the way" or not.
Beta Was this translation helpful? Give feedback.
All reactions