You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement (in-memory) unit tests for calls to Firebase firestore which actually test functionality (similar to SQLite)
What are We Currently Doing
We are currently jest mocking the firestore methods with empty mock functions, without really testing functionality. We need to expand on this to:
1 - Add get() method to the mocks
2 - Add unit tests to at least see that the methods are getting called with the correct parameters/data
Methods Tried in the Past
Firebase Emulation
This would be ideal BUT not ideal for in-memory local unit tests as it requires a separate process (not in-memory). We should might want to be setting this up in the future though, alongside BDD/integration testing
Firebase Functions Test
firebase-functions-test is also not ideal as it is built specifically for Cloud functions which we are not using (but can switch to)
Furthermore, Firebase reccomends using these for online tests, and dissuades from siloed offline testing:
Using offline mode is generally not recommended if you have Cloud Firestore or Realtime Database functions, since it greatly increases the complexity of your test code.
Ensure you are using the fork by dmurvihill not the main repo (original repo owner is not maintaining it)
Seems ideal for our purposes however when listening for doc changes triggers - it doesn't have the latest querySnapshot.docChanges() method. It might still be possible to use this package but would require moving to a firebase-functions implementation of triggers/listeners for Firebase doc changes
Have also made an issue for the above in the repo - worth revisiting if it gets fixed.
Briefly tried (which can be seen in the firebaseMocking`(https://github.com/mojaloop/pisp-demo-server/tree/firebaseMocking) implementation), to keep both sets of mocks and only use the npm package when doing unit tests on the firebase methods directly. It works but is too janky/messy/confusing to have.
What We Want To Do
Implement (in-memory) unit tests for calls to Firebase firestore which actually test functionality (similar to SQLite)
What are We Currently Doing
We are currently jest mocking the firestore methods with empty mock functions, without really testing functionality. We need to expand on this to:
get()
method to the mocksMethods Tried in the Past
Firebase Emulation
This would be ideal BUT not ideal for in-memory local unit tests as it requires a separate process (not in-memory). We should might want to be setting this up in the future though, alongside BDD/integration testing
Firebase Functions Test
firebase-functions-test
is also not ideal as it is built specifically for Cloud functions which we are not using (but can switch to)firebase-mock
dmurvihill
not the main repo (original repo owner is not maintaining it)querySnapshot.docChanges()
method. It might still be possible to use this package but would require moving to afirebase-functions
implementation of triggers/listeners for Firebase doc changesfirebaseMocking
(https://github.com/mojaloop/pisp-demo-server/tree/firebaseMocking) for attempted implementationfirebase-mock
+ Basic Jest Mockingts-mock-firebase
firebase-nightlight
The text was updated successfully, but these errors were encountered: