firebase / firebase-functions-test

MIT License
232 stars 48 forks source link

bug: Running test locally in online mode trigger currently deployed function #117

Closed tzvc closed 2 years ago

tzvc commented 3 years ago

Version info

firebase-functions-test: 0.3.1

firebase-functions: 3.14.1

firebase-admin: 9.11.0

Test case

Steps to reproduce

Have a function deployed on your test project that listens to a firestore resource. Let's that a function that trigger when a document is created in /posts/{postId}.

Now, in your local test, create a document:

firestore.collection("/posts").doc().create({text: "my post"});

Expected behavior

The post is created in the remote database. No functions get triggered.

Actual behavior

The post is created in the remote database. The function listening to document creation deployed in the project gets triggered.

tzvc commented 3 years ago

I'm starting to think this is normal behavior and that functions should not be deployed on "test" firebase projects. Is that right ?

elvisun commented 2 years ago

This is working as intended that the online mode is talking to a real project. You can choose spin up an emulator and have your test talk to that instead.