firestore-jest-mock icon indicating copy to clipboard operation
firestore-jest-mock copied to clipboard

Requires wrong package for firebase 9

Open Otto-AA opened this issue 2 years ago • 4 comments

Description

I've tried to use mockFirebase, however it always logs "Module firebase not found, mocking skipped.".

The error comes from here:

https://github.com/Upstatement/firestore-jest-mock/blob/45f435c8b412f7bc9bc8e8d1fac797204e387efc/mocks/firebase.js#L41-L54

It tries to require.resolve('firebase'), however it seems like in Firebase 9 this is not possible anymore (I'm using e.g. require('firebase/firestore') so the mock should likely use similar imports).

Steps to reproduce

Create a project with firebase >= 9. Call mockFirebase().

See this repo for a minimal example: https://github.com/Otto-AA/firestore-mock-bug-demo

Expected result

It should mock firebase.

Actual result

It does not find the firebase module.

Environment

Otto-AA avatar Jan 11 '23 09:01 Otto-AA

Thanks for reporting! We'll have to add the new name spaces to the import checks

sbatson5 avatar Jan 22 '23 16:01 sbatson5

I'm using Firebase 9 and having a similar problem.

thachp avatar Jan 26 '23 22:01 thachp

Any fix for this? I'm experiencing the same issue.

ChaseIndustries avatar Apr 22 '23 01:04 ChaseIndustries

If you have the same problem, please simply upvote the issue. It's a bit annoying to receive emails for every "Same". Thank you!

Otto-AA avatar Apr 23 '23 15:04 Otto-AA