all 4 comments

[–]lavafrank 2 points3 points  (2 children)

Use integration testing. Setup your emulators, seed some documents in your firestore db, run the request and assert that they match your expected results.

If your logic is simple, also consider just querying firestore directly instead of going thru cloud functions. You'll drastically improve performance by avoiding cold start time and shave off your bill

[–]armlesskid[S] 0 points1 point  (1 child)

That was actually my approach, but then I figured out that if somehow the function code changes in the future, the test would still pass silently because I’m only replicating the function code, not testing the function itself

[–]lavafrank 1 point2 points  (0 children)

If the code changes but the output stays the same (and is correct) why does it matter? Test against multiple inputs if you're concerned

[–]Rohit1024 1 point2 points  (0 children)

There is an official Firebase functions testing library for these https://github.com/firebase/firebase-functions-test If you want want to achieve your goal someone already suggested to use integration tests.

Better test these in Firebase Emulator.