Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include firebase/admin with 'import' instead of 'require' #144

Open
xd2 opened this issue Sep 7, 2022 · 4 comments
Open

include firebase/admin with 'import' instead of 'require' #144

xd2 opened this issue Sep 7, 2022 · 4 comments

Comments

@xd2
Copy link

xd2 commented Sep 7, 2022

Summary

Would prefer import admin from 'firebase-admin' syntax instead of require('firebase-admin')

Relevant information

Including sdk with require('firebase-admin') syntax seems mandatory (regarding docs, sample and my own experience) to make firestore mock work.
Otherwise, the firestore mock is not initialised properly and the tests crash at the first collection call.

As moderns Typescript coders, my team and I would prefer a proper import admin from 'firebase-admin') style of include.
Is there a way to initialize the test, mocks etc properly without that ugly require thing ?
Even adding a jest.mock(admin.firestore...) or something would be more acceptable to us.

You guys did a great job, by the way ;-)

Environment (if relevant)

I can provide test sample if needed, but i gess my question is quite self explanatory.

@LucaDillenburg
Copy link

Any updates on this? Can't get the package to work with the import syntax in Typescript.

@Ananthnbhat
Copy link

I'm having the same issue. I use node js with typescript and tests are failing as it's not able to mock firebase-admin with the modern syntax.

@zzzbra
Copy link

zzzbra commented Mar 2, 2023

Grateful to have found this issue and know that I'm not the only one who was pulling their head out over this. Library is pretty perfect except for this fundamental limitation and while my code will technically run if I mix import and require syntax, I'm not gonna do that for the sake of my sanity.

@sbatson5 sbatson5 mentioned this issue May 27, 2023
1 task
@sbatson5
Copy link
Owner

Bumping to see if I could get a review for #167

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants