Closed hkaras19 closed 2 years ago
Update - I am able to get most functionality running with the following workaround:
const db = {}
const mockedFirestore = new FakeFirestore(db)
jest.mock("@react-native-firebase/firestore", () => () => mockedFirestore)
However, this is unable to access methods that are called as parameters. For example, firestore().collection()...
works fine, but firestore.FieldValue
does not.
I haven't personally used this for a react-native project (although I do have a RN project using firebase... we just don't have tests 😬 ). But this library does look for particular modules and we don't currently check for @react-native-firebase/firestore
. I don't believe the API's are much different, but we could add support for that and investigate the FieldValue
issue
I opened a PR to address this if you have time to test https://github.com/Upstatement/firestore-jest-mock/pull/142
Summary
Does this library support @react-native-firebase/firestore?
Basic example
I followed the setup instructions in the README for a react native project; however, I get the following error:
Error: You attempted to use a firebase module that's not installed natively on your iOS project by calling firebase.app().
This leads me to believe that the library does not support @react-native-firebase.
Motivation
It would be very helpful to apply this mocking to react native projects!